75 lines
2.5 KiB
Java
75 lines
2.5 KiB
Java
package com.facetec.sdk;
|
|
|
|
import com.google.common.primitives.UnsignedBytes;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.security.MessageDigest;
|
|
import javax.crypto.Mac;
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class bl {
|
|
private static final char[] d = "0123456789ABCDEF".toCharArray();
|
|
|
|
bl() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static String e(String str) throws Exception {
|
|
return a(c(str.getBytes(StandardCharsets.UTF_8)));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static byte[] d(String str) throws Exception {
|
|
return c(str.getBytes(StandardCharsets.UTF_8));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static byte[] c(byte[]... bArr) throws Exception {
|
|
return MessageDigest.getInstance(McElieceCCA2KeyGenParameterSpec.SHA256).digest(a(bArr));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static String e(byte[] bArr, String str) throws Exception {
|
|
return a(c(bArr, str.getBytes(StandardCharsets.UTF_8)));
|
|
}
|
|
|
|
public static byte[] a(byte[] bArr, String str) throws Exception {
|
|
return c(bArr, str.getBytes(StandardCharsets.UTF_8));
|
|
}
|
|
|
|
private static byte[] c(byte[] bArr, byte[]... bArr2) throws Exception {
|
|
SecretKeySpec secretKeySpec = new SecretKeySpec(bArr, "HmacSHA256");
|
|
Mac mac = Mac.getInstance("HmacSHA256");
|
|
mac.init(secretKeySpec);
|
|
return mac.doFinal(a(bArr2));
|
|
}
|
|
|
|
private static byte[] a(byte[]... bArr) {
|
|
int i = 0;
|
|
for (byte[] bArr2 : bArr) {
|
|
i += bArr2.length;
|
|
}
|
|
byte[] bArr3 = new byte[i];
|
|
int i2 = 0;
|
|
for (byte[] bArr4 : bArr) {
|
|
System.arraycopy(bArr4, 0, bArr3, i2, bArr4.length);
|
|
i2 += bArr4.length;
|
|
}
|
|
return bArr3;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static String a(byte[] bArr) {
|
|
char[] cArr = new char[bArr.length << 1];
|
|
for (int i = 0; i < bArr.length; i++) {
|
|
byte b = bArr[i];
|
|
int i2 = i << 1;
|
|
char[] cArr2 = d;
|
|
cArr[i2] = cArr2[(b & UnsignedBytes.MAX_VALUE) >>> 4];
|
|
cArr[i2 + 1] = cArr2[b & 15];
|
|
}
|
|
return new String(cArr);
|
|
}
|
|
}
|