Base64InputStream.smali
6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
.class public Lcom/brplug/base64/Base64InputStream;
.super Ljava/io/InputStream;
# instance fields
.field private buffer:[I
.field private bufferCounter:I
.field private eof:Z
.field private inputStream:Ljava/io/InputStream;
# direct methods
.method public constructor <init>(Ljava/io/InputStream;)V
.locals 1
invoke-direct {p0}, Ljava/io/InputStream;-><init>()V
const/4 v0, 0x0
iput v0, p0, Lcom/brplug/base64/Base64InputStream;->bufferCounter:I
iput-boolean v0, p0, Lcom/brplug/base64/Base64InputStream;->eof:Z
iput-object p1, p0, Lcom/brplug/base64/Base64InputStream;->inputStream:Ljava/io/InputStream;
return-void
.end method
.method private acquire()V
.locals 10
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
const/4 v0, 0x4
new-array v1, v0, [C
const/4 v2, 0x0
move v3, v2
:cond_0
iget-object v4, p0, Lcom/brplug/base64/Base64InputStream;->inputStream:Ljava/io/InputStream;
invoke-virtual {v4}, Ljava/io/InputStream;->read()I
move-result v4
const/4 v5, -0x1
const-string v6, "Bad base64 stream"
const/4 v7, 0x1
if-ne v4, v5, :cond_2
if-nez v3, :cond_1
new-array v0, v2, [I
iput-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
iput-boolean v7, p0, Lcom/brplug/base64/Base64InputStream;->eof:Z
return-void
:cond_1
new-instance v0, Ljava/io/IOException;
invoke-direct {v0, v6}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw v0
:cond_2
int-to-char v4, v4
sget-object v8, Lcom/brplug/base64/Shared;->chars:Ljava/lang/String;
invoke-virtual {v8, v4}, Ljava/lang/String;->indexOf(I)I
move-result v8
if-ne v8, v5, :cond_5
sget-char v8, Lcom/brplug/base64/Shared;->pad:C
if-ne v4, v8, :cond_3
goto :goto_0
:cond_3
const/16 v8, 0xd
if-eq v4, v8, :cond_6
const/16 v8, 0xa
if-ne v4, v8, :cond_4
goto :goto_1
:cond_4
new-instance v0, Ljava/io/IOException;
invoke-direct {v0, v6}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw v0
:cond_5
:goto_0
add-int/lit8 v8, v3, 0x1
aput-char v4, v1, v3
move v3, v8
:cond_6
:goto_1
if-lt v3, v0, :cond_0
move v3, v2
move v4, v3
:goto_2
if-ge v3, v0, :cond_a
aget-char v8, v1, v3
sget-char v9, Lcom/brplug/base64/Shared;->pad:C
if-eq v8, v9, :cond_8
if-nez v4, :cond_7
goto :goto_3
:cond_7
new-instance v0, Ljava/io/IOException;
invoke-direct {v0, v6}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw v0
:cond_8
if-nez v4, :cond_9
move v4, v7
:cond_9
:goto_3
add-int/lit8 v3, v3, 0x1
goto :goto_2
:cond_a
const/4 v3, 0x3
aget-char v4, v1, v3
sget-char v8, Lcom/brplug/base64/Shared;->pad:C
const/4 v9, 0x2
if-ne v4, v8, :cond_d
iget-object v4, p0, Lcom/brplug/base64/Base64InputStream;->inputStream:Ljava/io/InputStream;
invoke-virtual {v4}, Ljava/io/InputStream;->read()I
move-result v4
if-ne v4, v5, :cond_c
iput-boolean v7, p0, Lcom/brplug/base64/Base64InputStream;->eof:Z
aget-char v4, v1, v9
sget-char v5, Lcom/brplug/base64/Shared;->pad:C
if-ne v4, v5, :cond_b
goto :goto_4
:cond_b
move v7, v9
goto :goto_4
:cond_c
new-instance v0, Ljava/io/IOException;
invoke-direct {v0, v6}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
throw v0
:cond_d
move v7, v3
:goto_4
move v4, v2
move v5, v4
:goto_5
if-ge v4, v0, :cond_f
aget-char v6, v1, v4
sget-char v8, Lcom/brplug/base64/Shared;->pad:C
if-eq v6, v8, :cond_e
sget-object v6, Lcom/brplug/base64/Shared;->chars:Ljava/lang/String;
aget-char v8, v1, v4
invoke-virtual {v6, v8}, Ljava/lang/String;->indexOf(I)I
move-result v6
rsub-int/lit8 v8, v4, 0x3
mul-int/lit8 v8, v8, 0x6
shl-int/2addr v6, v8
or-int/2addr v5, v6
:cond_e
add-int/lit8 v4, v4, 0x1
goto :goto_5
:cond_f
new-array v0, v7, [I
iput-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
:goto_6
if-ge v2, v7, :cond_10
iget-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
rsub-int/lit8 v1, v2, 0x2
mul-int/lit8 v1, v1, 0x8
ushr-int v1, v5, v1
and-int/lit16 v1, v1, 0xff
aput v1, v0, v2
add-int/lit8 v2, v2, 0x1
goto :goto_6
:cond_10
return-void
.end method
# virtual methods
.method public close()V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
iget-object v0, p0, Lcom/brplug/base64/Base64InputStream;->inputStream:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
return-void
.end method
.method public read()I
.locals 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
iget-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
if-eqz v0, :cond_0
iget v1, p0, Lcom/brplug/base64/Base64InputStream;->bufferCounter:I
array-length v0, v0
if-ne v1, v0, :cond_3
:cond_0
iget-boolean v0, p0, Lcom/brplug/base64/Base64InputStream;->eof:Z
const/4 v1, -0x1
if-eqz v0, :cond_1
return v1
:cond_1
invoke-direct {p0}, Lcom/brplug/base64/Base64InputStream;->acquire()V
iget-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
array-length v0, v0
if-nez v0, :cond_2
const/4 v0, 0x0
iput-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
return v1
:cond_2
const/4 v0, 0x0
iput v0, p0, Lcom/brplug/base64/Base64InputStream;->bufferCounter:I
:cond_3
iget-object v0, p0, Lcom/brplug/base64/Base64InputStream;->buffer:[I
iget v1, p0, Lcom/brplug/base64/Base64InputStream;->bufferCounter:I
add-int/lit8 v2, v1, 0x1
iput v2, p0, Lcom/brplug/base64/Base64InputStream;->bufferCounter:I
aget v0, v0, v1
return v0
.end method