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

24 lines
849 B
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.crypto.prng;
/* loaded from: classes6.dex */
public class EntropyUtil {
public static byte[] generateSeed(EntropySource entropySource, int i) {
byte[] bArr = new byte[i];
if ((i << 3) <= entropySource.entropySize()) {
System.arraycopy(entropySource.getEntropy(), 0, bArr, 0, i);
} else {
int entropySize = entropySource.entropySize() / 8;
for (int i2 = 0; i2 < i; i2 += entropySize) {
byte[] entropy = entropySource.getEntropy();
int i3 = i - i2;
if (entropy.length <= i3) {
System.arraycopy(entropy, 0, bArr, i2, entropy.length);
} else {
System.arraycopy(entropy, 0, bArr, i2, i3);
}
}
}
return bArr;
}
}