what-the-bank/sources/org/bouncycastle/util/test/TestRandomEntropySourceProv...

46 lines
1.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.util.test;
import java.security.SecureRandom;
import org.bouncycastle.crypto.prng.EntropySource;
import org.bouncycastle.crypto.prng.EntropySourceProvider;
/* loaded from: classes6.dex */
public class TestRandomEntropySourceProvider implements EntropySourceProvider {
private final boolean _predictionResistant;
private final SecureRandom _sr = new SecureRandom();
@Override // org.bouncycastle.crypto.prng.EntropySourceProvider
public EntropySource get(int i) {
return new EntropySource(this, i) { // from class: org.bouncycastle.util.test.TestRandomEntropySourceProvider.1
final TestRandomEntropySourceProvider this$0;
final int val$bitsRequired;
@Override // org.bouncycastle.crypto.prng.EntropySource
public boolean isPredictionResistant() {
return this.this$0._predictionResistant;
}
@Override // org.bouncycastle.crypto.prng.EntropySource
public byte[] getEntropy() {
byte[] bArr = new byte[(this.val$bitsRequired + 7) / 8];
this.this$0._sr.nextBytes(bArr);
return bArr;
}
@Override // org.bouncycastle.crypto.prng.EntropySource
public int entropySize() {
return this.val$bitsRequired;
}
{
this.this$0 = this;
this.val$bitsRequired = i;
}
};
}
public TestRandomEntropySourceProvider(boolean z) {
this._predictionResistant = z;
}
}