what-the-bank/sources/org/bouncycastle/pqc/crypto/gmss/util/GMSSRandom.java

42 lines
1.2 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.pqc.crypto.gmss.util;
import com.google.common.primitives.UnsignedBytes;
import org.bouncycastle.crypto.Digest;
/* loaded from: classes6.dex */
public class GMSSRandom {
private Digest messDigestTree;
public byte[] nextSeed(byte[] bArr) {
byte[] bArr2 = new byte[bArr.length];
this.messDigestTree.update(bArr, 0, bArr.length);
byte[] bArr3 = new byte[this.messDigestTree.getDigestSize()];
this.messDigestTree.doFinal(bArr3, 0);
addByteArrays(bArr, bArr3);
addOne(bArr);
return bArr3;
}
private void addOne(byte[] bArr) {
byte b = 1;
for (int i = 0; i < bArr.length; i++) {
int i2 = (bArr[i] & UnsignedBytes.MAX_VALUE) + b;
bArr[i] = (byte) i2;
b = (byte) (i2 >> 8);
}
}
private void addByteArrays(byte[] bArr, byte[] bArr2) {
byte b = 0;
for (int i = 0; i < bArr.length; i++) {
int i2 = (bArr[i] & UnsignedBytes.MAX_VALUE) + (bArr2[i] & UnsignedBytes.MAX_VALUE) + b;
bArr[i] = (byte) i2;
b = (byte) (i2 >> 8);
}
}
public GMSSRandom(Digest digest) {
this.messDigestTree = digest;
}
}