what-the-bank/sources/org/bouncycastle/crypto/prng/drbg/Utils.java

83 lines
3.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.prng.drbg;
import java.util.Hashtable;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.pqc.jcajce.spec.McElieceCCA2KeyGenParameterSpec;
import org.bouncycastle.util.Integers;
/* loaded from: classes6.dex */
class Utils {
static final Hashtable maxSecurityStrengths;
/* JADX INFO: Access modifiers changed from: package-private */
public static boolean isTooLarge(byte[] bArr, int i) {
return bArr != null && bArr.length > i;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static byte[] hash_df(Digest digest, byte[] bArr, int i) {
int i2 = (i + 7) / 8;
byte[] bArr2 = new byte[i2];
int digestSize = i2 / digest.getDigestSize();
int digestSize2 = digest.getDigestSize();
byte[] bArr3 = new byte[digestSize2];
int i3 = 1;
int i4 = 0;
for (int i5 = 0; i5 <= digestSize; i5++) {
digest.update((byte) i3);
digest.update((byte) (i >> 24));
digest.update((byte) (i >> 16));
digest.update((byte) (i >> 8));
digest.update((byte) i);
digest.update(bArr, 0, bArr.length);
digest.doFinal(bArr3, 0);
int i6 = i5 * digestSize2;
int i7 = i2 - i6;
if (i7 > digestSize2) {
i7 = digestSize2;
}
System.arraycopy(bArr3, 0, bArr2, i6, i7);
i3++;
}
int i8 = i % 8;
if (i8 != 0) {
int i9 = 8 - i8;
int i10 = 0;
while (i4 != i2) {
int i11 = bArr2[i4] & 255;
bArr2[i4] = (byte) ((i10 << (8 - i9)) | (i11 >>> i9));
i4++;
i10 = i11;
}
}
return bArr2;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static int getMaxSecurityStrength(Mac mac) {
String algorithmName = mac.getAlgorithmName();
return ((Integer) maxSecurityStrengths.get(algorithmName.substring(0, algorithmName.indexOf("/")))).intValue();
}
/* JADX INFO: Access modifiers changed from: package-private */
public static int getMaxSecurityStrength(Digest digest) {
return ((Integer) maxSecurityStrengths.get(digest.getAlgorithmName())).intValue();
}
Utils() {
}
static {
Hashtable hashtable = new Hashtable();
maxSecurityStrengths = hashtable;
hashtable.put(McElieceCCA2KeyGenParameterSpec.SHA1, Integers.valueOf(128));
hashtable.put(McElieceCCA2KeyGenParameterSpec.SHA224, Integers.valueOf(192));
hashtable.put(McElieceCCA2KeyGenParameterSpec.SHA256, Integers.valueOf(256));
hashtable.put(McElieceCCA2KeyGenParameterSpec.SHA384, Integers.valueOf(256));
hashtable.put(McElieceCCA2KeyGenParameterSpec.SHA512, Integers.valueOf(256));
hashtable.put("SHA-512/224", Integers.valueOf(192));
hashtable.put("SHA-512/256", Integers.valueOf(256));
}
}