what-the-bank/sources/org/bouncycastle/crypto/digests/SHA3Digest.java

57 lines
1.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.digests;
/* loaded from: classes6.dex */
public class SHA3Digest extends KeccakDigest {
@Override // org.bouncycastle.crypto.digests.KeccakDigest, org.bouncycastle.crypto.Digest
public String getAlgorithmName() {
StringBuilder sb = new StringBuilder("SHA3-");
sb.append(this.fixedOutputLength);
return sb.toString();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // org.bouncycastle.crypto.digests.KeccakDigest
public int doFinal(byte[] bArr, int i, byte b, int i2) {
if (i2 < 0 || i2 > 7) {
throw new IllegalArgumentException("'partialBits' must be in the range [0,7]");
}
int i3 = (b & ((1 << i2) - 1)) | (2 << i2);
int i4 = i2 + 2;
if (i4 >= 8) {
this.oneByte[0] = (byte) i3;
absorb(this.oneByte, 0, 8L);
i4 = i2 - 6;
i3 >>>= 8;
}
return super.doFinal(bArr, i, (byte) i3, i4);
}
@Override // org.bouncycastle.crypto.digests.KeccakDigest, org.bouncycastle.crypto.Digest
public int doFinal(byte[] bArr, int i) {
absorb(new byte[]{2}, 0, 2L);
return super.doFinal(bArr, i);
}
private static int checkBitLength(int i) {
if (i == 224 || i == 256 || i == 384 || i == 512) {
return i;
}
StringBuilder sb = new StringBuilder("'bitLength' ");
sb.append(i);
sb.append(" not supported for SHA-3");
throw new IllegalArgumentException(sb.toString());
}
public SHA3Digest(SHA3Digest sHA3Digest) {
super(sHA3Digest);
}
public SHA3Digest(int i) {
super(checkBitLength(i));
}
public SHA3Digest() {
this(256);
}
}