what-the-bank/sources/o/C13177fSy.java

121 lines
3.7 KiB
Java

package o;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Mac;
import o.uAf;
/* renamed from: o.fSy, reason: case insensitive filesystem */
/* loaded from: classes2.dex */
public final class C13177fSy implements InterfaceC16851roi {
private static uAf.RVV a = uAf.RVV.ALGORITHM_REQUIRES_BORINGCRYPTO;
private final String b;
private final int c;
private final Key d;
private final ThreadLocal<Mac> e;
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
public C13177fSy(String str, Key key) throws GeneralSecurityException {
char c;
int i;
ThreadLocal<Mac> threadLocal = new ThreadLocal<Mac>(this) { // from class: o.fSy.5
private C13177fSy c;
{
this.c = this;
}
/* JADX INFO: Access modifiers changed from: private */
@Override // java.lang.ThreadLocal
/* renamed from: c, reason: merged with bridge method [inline-methods] */
public Mac initialValue() {
try {
Mac e = YYT.b.e(this.c.b);
e.init(this.c.d);
return e;
} catch (GeneralSecurityException e2) {
throw new IllegalStateException(e2);
}
}
};
this.e = threadLocal;
if (!a.d()) {
throw new GeneralSecurityException("Can not use HMAC in FIPS-mode, as BoringCrypto module is not available.");
}
this.b = str;
this.d = key;
if (key.getEncoded().length < 16) {
throw new InvalidAlgorithmParameterException("key size too small, need at least 16 bytes");
}
str.hashCode();
switch (str.hashCode()) {
case -1823053428:
if (str.equals("HMACSHA1")) {
c = 0;
break;
}
c = 65535;
break;
case 392315023:
if (str.equals("HMACSHA224")) {
c = 1;
break;
}
c = 65535;
break;
case 392315118:
if (str.equals("HMACSHA256")) {
c = 2;
break;
}
c = 65535;
break;
case 392316170:
if (str.equals("HMACSHA384")) {
c = 3;
break;
}
c = 65535;
break;
case 392317873:
if (str.equals("HMACSHA512")) {
c = 4;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
if (c == 0) {
i = 20;
} else if (c == 1) {
i = 28;
} else if (c == 2) {
i = 32;
} else if (c == 3) {
i = 48;
} else {
if (c != 4) {
throw new NoSuchAlgorithmException("unknown Hmac algorithm: ".concat(String.valueOf(str)));
}
i = 64;
}
this.c = i;
threadLocal.get();
}
@Override // o.InterfaceC16851roi
public final byte[] c(byte[] bArr, int i) throws GeneralSecurityException {
if (i > this.c) {
throw new InvalidAlgorithmParameterException("tag size too big");
}
this.e.get().update(bArr);
return Arrays.copyOf(this.e.get().doFinal(), i);
}
}