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

42 lines
1.5 KiB
Java

package org.bouncycastle.crypto.prng;
import java.security.SecureRandom;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.Pack;
/* loaded from: classes6.dex */
public class X931SecureRandomBuilder {
private byte[] dateTimeVector;
private EntropySourceProvider entropySourceProvider;
private SecureRandom random;
public X931SecureRandomBuilder setDateTimeVector(byte[] bArr) {
this.dateTimeVector = bArr;
return this;
}
public X931SecureRandom build(BlockCipher blockCipher, KeyParameter keyParameter, boolean z) {
if (this.dateTimeVector == null) {
this.dateTimeVector = new byte[blockCipher.getBlockSize()];
Pack.longToBigEndian(System.currentTimeMillis(), this.dateTimeVector, 0);
}
blockCipher.init(true, keyParameter);
return new X931SecureRandom(this.random, new X931RNG(blockCipher, this.dateTimeVector, this.entropySourceProvider.get(blockCipher.getBlockSize() << 3)), z);
}
public X931SecureRandomBuilder(EntropySourceProvider entropySourceProvider) {
this.random = null;
this.entropySourceProvider = entropySourceProvider;
}
public X931SecureRandomBuilder(SecureRandom secureRandom, boolean z) {
this.random = secureRandom;
this.entropySourceProvider = new BasicEntropySourceProvider(secureRandom, z);
}
public X931SecureRandomBuilder() {
this(new SecureRandom(), false);
}
}