Rabbit-R1/original r1/java/sources/io/sentry/vendor/Base64.java

299 lines
13 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package io.sentry.vendor;
import com.google.android.exoplayer2.C;
import java.io.UnsupportedEncodingException;
/* loaded from: classes3.dex */
public class Base64 {
static final /* synthetic */ boolean $assertionsDisabled = false;
public static final int CRLF = 4;
public static final int DEFAULT = 0;
public static final int NO_CLOSE = 16;
public static final int NO_PADDING = 1;
public static final int NO_WRAP = 2;
public static final int URL_SAFE = 8;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public static abstract class Coder {
public int op;
public byte[] output;
public abstract int maxOutputSize(int i);
public abstract boolean process(byte[] bArr, int i, int i2, boolean z);
Coder() {
}
}
public static byte[] decode(String str, int i) {
return decode(str.getBytes(), i);
}
public static byte[] decode(byte[] bArr, int i) {
return decode(bArr, 0, bArr.length, i);
}
public static byte[] decode(byte[] bArr, int i, int i2, int i3) {
Decoder decoder = new Decoder(i3, new byte[(i2 * 3) / 4]);
if (!decoder.process(bArr, i, i2, true)) {
throw new IllegalArgumentException("bad base-64");
}
if (decoder.op == decoder.output.length) {
return decoder.output;
}
byte[] bArr2 = new byte[decoder.op];
System.arraycopy(decoder.output, 0, bArr2, 0, decoder.op);
return bArr2;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public static class Decoder extends Coder {
private static final int[] DECODE = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 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, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
private static final int[] DECODE_WEBSAFE = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 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, -1, -1, -1, -1, 63, -1, 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
private static final int EQUALS = -2;
private static final int SKIP = -1;
private final int[] alphabet;
private int state;
private int value;
public Decoder(int i, byte[] bArr) {
this.output = bArr;
this.alphabet = (i & 8) == 0 ? DECODE : DECODE_WEBSAFE;
this.state = 0;
this.value = 0;
}
@Override // io.sentry.vendor.Base64.Coder
public int maxOutputSize(int i) {
return ((i * 3) / 4) + 10;
}
@Override // io.sentry.vendor.Base64.Coder
public boolean process(byte[] bArr, int i, int i2, boolean z) {
int i3 = this.state;
if (i3 == 6) {
return false;
}
int i4 = i2 + i;
int i5 = this.value;
byte[] bArr2 = this.output;
int[] iArr = this.alphabet;
int i6 = 0;
int i7 = i5;
int i8 = i3;
int i9 = i;
while (i9 < i4) {
if (i8 == 0) {
while (true) {
int i10 = i9 + 4;
if (i10 > i4 || (i7 = (iArr[bArr[i9] & 255] << 18) | (iArr[bArr[i9 + 1] & 255] << 12) | (iArr[bArr[i9 + 2] & 255] << 6) | iArr[bArr[i9 + 3] & 255]) < 0) {
break;
}
bArr2[i6 + 2] = (byte) i7;
bArr2[i6 + 1] = (byte) (i7 >> 8);
bArr2[i6] = (byte) (i7 >> 16);
i6 += 3;
i9 = i10;
}
if (i9 >= i4) {
break;
}
}
int i11 = i9 + 1;
int i12 = iArr[bArr[i9] & 255];
if (i8 != 0) {
if (i8 == 1) {
if (i12 < 0) {
if (i12 != -1) {
this.state = 6;
return false;
}
}
i12 |= i7 << 6;
} else if (i8 == 2) {
if (i12 < 0) {
if (i12 == -2) {
bArr2[i6] = (byte) (i7 >> 4);
i6++;
i8 = 4;
} else if (i12 != -1) {
this.state = 6;
return false;
}
}
i12 |= i7 << 6;
} else if (i8 != 3) {
if (i8 != 4) {
if (i8 == 5 && i12 != -1) {
this.state = 6;
return false;
}
} else if (i12 == -2) {
i8++;
} else if (i12 != -1) {
this.state = 6;
return false;
}
} else if (i12 >= 0) {
int i13 = i12 | (i7 << 6);
bArr2[i6 + 2] = (byte) i13;
bArr2[i6 + 1] = (byte) (i13 >> 8);
bArr2[i6] = (byte) (i13 >> 16);
i6 += 3;
i7 = i13;
i8 = 0;
} else if (i12 == -2) {
bArr2[i6 + 1] = (byte) (i7 >> 2);
bArr2[i6] = (byte) (i7 >> 10);
i6 += 2;
i8 = 5;
} else if (i12 != -1) {
this.state = 6;
return false;
}
i8++;
i7 = i12;
} else {
if (i12 < 0) {
if (i12 != -1) {
this.state = 6;
return false;
}
}
i8++;
i7 = i12;
}
i9 = i11;
}
if (!z) {
this.state = i8;
this.value = i7;
this.op = i6;
return true;
}
if (i8 == 1) {
this.state = 6;
return false;
}
if (i8 == 2) {
bArr2[i6] = (byte) (i7 >> 4);
i6++;
} else if (i8 == 3) {
int i14 = i6 + 1;
bArr2[i6] = (byte) (i7 >> 10);
i6 += 2;
bArr2[i14] = (byte) (i7 >> 2);
} else if (i8 == 4) {
this.state = 6;
return false;
}
this.state = i8;
this.op = i6;
return true;
}
}
public static String encodeToString(byte[] bArr, int i) {
try {
return new String(encode(bArr, i), C.ASCII_NAME);
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
public static String encodeToString(byte[] bArr, int i, int i2, int i3) {
try {
return new String(encode(bArr, i, i2, i3), C.ASCII_NAME);
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
public static byte[] encode(byte[] bArr, int i) {
return encode(bArr, 0, bArr.length, i);
}
public static byte[] encode(byte[] bArr, int i, int i2, int i3) {
Encoder encoder = new Encoder(i3, null);
int i4 = (i2 / 3) * 4;
if (encoder.do_padding) {
if (i2 % 3 > 0) {
i4 += 4;
}
} else {
int i5 = i2 % 3;
if (i5 == 1) {
i4 += 2;
} else if (i5 == 2) {
i4 += 3;
}
}
if (encoder.do_newline && i2 > 0) {
i4 += (((i2 - 1) / 57) + 1) * (encoder.do_cr ? 2 : 1);
}
encoder.output = new byte[i4];
encoder.process(bArr, i, i2, true);
return encoder.output;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public static class Encoder extends Coder {
static final /* synthetic */ boolean $assertionsDisabled = false;
private static final byte[] ENCODE = {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, 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, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47};
private static final byte[] ENCODE_WEBSAFE = {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, 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, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95};
public static final int LINE_GROUPS = 19;
private final byte[] alphabet;
private int count;
public final boolean do_cr;
public final boolean do_newline;
public final boolean do_padding;
private final byte[] tail;
int tailLen;
public Encoder(int i, byte[] bArr) {
this.output = bArr;
this.do_padding = (i & 1) == 0;
boolean z = (i & 2) == 0;
this.do_newline = z;
this.do_cr = (i & 4) != 0;
this.alphabet = (i & 8) == 0 ? ENCODE : ENCODE_WEBSAFE;
this.tail = new byte[2];
this.tailLen = 0;
this.count = z ? 19 : -1;
}
@Override // io.sentry.vendor.Base64.Coder
public int maxOutputSize(int i) {
return ((i * 8) / 5) + 10;
}
/* JADX ERROR: JadxOverflowException in pass: RegionMakerVisitor
jadx.core.utils.exceptions.JadxOverflowException: Regions count limit reached
at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:59)
at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:31)
at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:19)
*/
/* JADX WARN: Removed duplicated region for block: B:19:0x0094 */
/* JADX WARN: Removed duplicated region for block: B:28:0x00e6 A[SYNTHETIC] */
@Override // io.sentry.vendor.Base64.Coder
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public boolean process(byte[] r18, int r19, int r20, boolean r21) {
/*
Method dump skipped, instructions count: 477
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: io.sentry.vendor.Base64.Encoder.process(byte[], int, int, boolean):boolean");
}
}
private Base64() {
}
}