48 lines
1.7 KiB
Java
48 lines
1.7 KiB
Java
|
package org.bouncycastle.crypto.prng;
|
||
|
|
||
|
import java.security.SecureRandom;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class BasicEntropySourceProvider implements EntropySourceProvider {
|
||
|
private final boolean _predictionResistant;
|
||
|
private final SecureRandom _sr;
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.prng.EntropySourceProvider
|
||
|
public EntropySource get(int i) {
|
||
|
return new EntropySource(this, i) { // from class: org.bouncycastle.crypto.prng.BasicEntropySourceProvider.1
|
||
|
final BasicEntropySourceProvider 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() {
|
||
|
if ((this.this$0._sr instanceof SP800SecureRandom) || (this.this$0._sr instanceof X931SecureRandom)) {
|
||
|
byte[] bArr = new byte[(this.val$bitsRequired + 7) / 8];
|
||
|
this.this$0._sr.nextBytes(bArr);
|
||
|
return bArr;
|
||
|
}
|
||
|
return this.this$0._sr.generateSeed((this.val$bitsRequired + 7) / 8);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.crypto.prng.EntropySource
|
||
|
public int entropySize() {
|
||
|
return this.val$bitsRequired;
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
this.val$bitsRequired = i;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public BasicEntropySourceProvider(SecureRandom secureRandom, boolean z) {
|
||
|
this._sr = secureRandom;
|
||
|
this._predictionResistant = z;
|
||
|
}
|
||
|
}
|