what-the-bank/sources/com/facetec/sdk/mt.java

338 lines
9.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.facetec.sdk;
import com.google.common.primitives.UnsignedBytes;
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
/* loaded from: classes.dex */
public class mt implements Serializable, Comparable<mt> {
private transient String b;
transient int c;
final byte[] e;
private static char[] d = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
public static final mt a = d(new byte[0]);
@Override // java.lang.Comparable
public /* synthetic */ int compareTo(mt mtVar) {
mt mtVar2 = mtVar;
int i = i();
int i2 = mtVar2.i();
int min = Math.min(i, i2);
for (int i3 = 0; i3 < min; i3++) {
int d2 = d(i3) & UnsignedBytes.MAX_VALUE;
int d3 = mtVar2.d(i3) & UnsignedBytes.MAX_VALUE;
if (d2 != d3) {
return d2 < d3 ? -1 : 1;
}
}
if (i == i2) {
return 0;
}
return i < i2 ? -1 : 1;
}
/* JADX INFO: Access modifiers changed from: package-private */
public mt(byte[] bArr) {
this.e = bArr;
}
public static mt d(byte... bArr) {
if (bArr == null) {
throw new IllegalArgumentException("data == null");
}
return new mt((byte[]) bArr.clone());
}
public static mt c(String str) {
if (str == null) {
throw new IllegalArgumentException("s == null");
}
mt mtVar = new mt(str.getBytes(ng.e));
mtVar.b = str;
return mtVar;
}
public String b() {
String str = this.b;
if (str != null) {
return str;
}
String str2 = new String(this.e, ng.e);
this.b = str2;
return str2;
}
public String e() {
return mu.e(this.e);
}
public mt d() {
return b(McElieceCCA2KeyGenParameterSpec.SHA1);
}
public mt a() {
return b(McElieceCCA2KeyGenParameterSpec.SHA256);
}
private mt b(String str) {
try {
return d(MessageDigest.getInstance(str).digest(this.e));
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
}
public static mt e(String str) {
if (str == null) {
throw new IllegalArgumentException("base64 == null");
}
byte[] d2 = mu.d(str);
if (d2 != null) {
return new mt(d2);
}
return null;
}
public String c() {
byte[] bArr = this.e;
char[] cArr = new char[bArr.length << 1];
int length = bArr.length;
int i = 0;
int i2 = 0;
while (i2 < length) {
byte b = bArr[i2];
char[] cArr2 = d;
cArr[i] = cArr2[(b >> 4) & 15];
cArr[i + 1] = cArr2[b & 15];
i2++;
i += 2;
}
return new String(cArr);
}
public static mt d(String str) {
if (str.length() % 2 != 0) {
throw new IllegalArgumentException("Unexpected hex string: ".concat(String.valueOf(str)));
}
int length = str.length() / 2;
byte[] bArr = new byte[length];
for (int i = 0; i < length; i++) {
int i2 = i << 1;
bArr[i] = (byte) ((d(str.charAt(i2)) << 4) + d(str.charAt(i2 + 1)));
}
return d(bArr);
}
private static int d(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'a' && c <= 'f') {
return c - 'W';
}
if (c < 'A' || c > 'F') {
throw new IllegalArgumentException("Unexpected hex digit: ".concat(String.valueOf(c)));
}
return c - '7';
}
public mt f() {
int i = 0;
while (true) {
byte[] bArr = this.e;
if (i >= bArr.length) {
return this;
}
byte b = bArr[i];
if (b >= 65 && b <= 90) {
byte[] bArr2 = (byte[]) bArr.clone();
bArr2[i] = (byte) (b + 32);
for (int i2 = i + 1; i2 < bArr2.length; i2++) {
byte b2 = bArr2[i2];
if (b2 >= 65 && b2 <= 90) {
bArr2[i2] = (byte) (b2 + 32);
}
}
return new mt(bArr2);
}
i++;
}
}
public mt e(int i, int i2) {
if (i < 0) {
throw new IllegalArgumentException("beginIndex < 0");
}
byte[] bArr = this.e;
if (i2 > bArr.length) {
StringBuilder sb = new StringBuilder("endIndex > length(");
sb.append(this.e.length);
sb.append(")");
throw new IllegalArgumentException(sb.toString());
}
int i3 = i2 - i;
if (i3 < 0) {
throw new IllegalArgumentException("endIndex < beginIndex");
}
if (i == 0 && i2 == bArr.length) {
return this;
}
byte[] bArr2 = new byte[i3];
System.arraycopy(bArr, i, bArr2, 0, i3);
return new mt(bArr2);
}
public byte d(int i) {
return this.e[i];
}
public int i() {
return this.e.length;
}
public byte[] g() {
return (byte[]) this.e.clone();
}
/* JADX INFO: Access modifiers changed from: package-private */
public void c(ms msVar) {
byte[] bArr = this.e;
msVar.d(bArr, 0, bArr.length);
}
public boolean b(int i, mt mtVar, int i2, int i3) {
return mtVar.c(0, this.e, 0, i3);
}
public boolean c(int i, byte[] bArr, int i2, int i3) {
if (i < 0) {
return false;
}
byte[] bArr2 = this.e;
return i <= bArr2.length - i3 && i2 >= 0 && i2 <= bArr.length - i3 && ng.c(bArr2, i, bArr, i2, i3);
}
public final boolean e(mt mtVar) {
return b(0, mtVar, 0, mtVar.i());
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof mt) {
mt mtVar = (mt) obj;
int i = mtVar.i();
byte[] bArr = this.e;
if (i == bArr.length && mtVar.c(0, bArr, 0, bArr.length)) {
return true;
}
}
return false;
}
public int hashCode() {
int i = this.c;
if (i != 0) {
return i;
}
int hashCode = Arrays.hashCode(this.e);
this.c = hashCode;
return hashCode;
}
public String toString() {
if (this.e.length == 0) {
return "[size=0]";
}
String b = b();
int length = b.length();
int i = 0;
int i2 = 0;
while (true) {
if (i >= length) {
i = b.length();
break;
}
if (i2 == 64) {
break;
}
int codePointAt = b.codePointAt(i);
if ((!Character.isISOControl(codePointAt) || codePointAt == 10 || codePointAt == 13) && codePointAt != 65533) {
i2++;
i += Character.charCount(codePointAt);
}
}
i = -1;
if (i == -1) {
if (this.e.length <= 64) {
StringBuilder sb = new StringBuilder("[hex=");
sb.append(c());
sb.append("]");
return sb.toString();
}
StringBuilder sb2 = new StringBuilder("[size=");
sb2.append(this.e.length);
sb2.append(" hex=");
sb2.append(e(0, 64).c());
sb2.append("…]");
return sb2.toString();
}
String replace = b.substring(0, i).replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r");
if (i < b.length()) {
StringBuilder sb3 = new StringBuilder("[size=");
sb3.append(this.e.length);
sb3.append(" text=");
sb3.append(replace);
sb3.append("…]");
return sb3.toString();
}
StringBuilder sb4 = new StringBuilder("[text=");
sb4.append(replace);
sb4.append("]");
return sb4.toString();
}
private void readObject(ObjectInputStream objectInputStream) throws IOException {
int readInt = objectInputStream.readInt();
if (objectInputStream == null) {
throw new IllegalArgumentException("in == null");
}
if (readInt < 0) {
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(readInt)));
}
byte[] bArr = new byte[readInt];
int i = 0;
while (i < readInt) {
int read = objectInputStream.read(bArr, i, readInt - i);
if (read == -1) {
throw new EOFException();
}
i += read;
}
mt mtVar = new mt(bArr);
try {
Field declaredField = mt.class.getDeclaredField("e");
declaredField.setAccessible(true);
declaredField.set(this, mtVar.e);
} catch (IllegalAccessException unused) {
throw new AssertionError();
} catch (NoSuchFieldException unused2) {
throw new AssertionError();
}
}
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
objectOutputStream.writeInt(this.e.length);
objectOutputStream.write(this.e);
}
}