what-the-bank/sources/org/bouncycastle/crypto/modes/gcm/Tables1kGCMExponentiator.java

49 lines
1.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.modes.gcm;
import java.util.Vector;
import org.bouncycastle.util.Arrays;
/* loaded from: classes6.dex */
public class Tables1kGCMExponentiator implements GCMExponentiator {
private Vector lookupPowX2;
@Override // org.bouncycastle.crypto.modes.gcm.GCMExponentiator
public void init(byte[] bArr) {
int[] asInts = GCMUtil.asInts(bArr);
Vector vector = this.lookupPowX2;
if (vector == null || !Arrays.areEqual(asInts, (int[]) vector.elementAt(0))) {
Vector vector2 = new Vector(8);
this.lookupPowX2 = vector2;
vector2.addElement(asInts);
}
}
@Override // org.bouncycastle.crypto.modes.gcm.GCMExponentiator
public void exponentiateX(long j, byte[] bArr) {
int[] oneAsInts = GCMUtil.oneAsInts();
int i = 0;
while (j > 0) {
if ((1 & j) != 0) {
ensureAvailable(i);
GCMUtil.multiply(oneAsInts, (int[]) this.lookupPowX2.elementAt(i));
}
i++;
j >>>= 1;
}
GCMUtil.asBytes(oneAsInts, bArr);
}
private void ensureAvailable(int i) {
int size = this.lookupPowX2.size();
if (size <= i) {
int[] iArr = (int[]) this.lookupPowX2.elementAt(size - 1);
do {
iArr = Arrays.clone(iArr);
GCMUtil.multiply(iArr, iArr);
this.lookupPowX2.addElement(iArr);
size++;
} while (size <= i);
}
}
}