if (numBytes * 8 <= entropySource.entropySize()) byte[] ent = entropySource.getEntropy(); int entSize = entropySource.entropySize() / 8; byte[] ent = entropySource.getEntropy();
/** * Reseed the RNG. */ void reseed() { V = entropySource.getEntropy(); reseedCounter = 1; }
if (entropySource.entropySize() < securityStrength)
private byte[] getEntropy() { byte[] entropy = _entropySource.getEntropy(); if (entropy.length < (_securityStrength + 7) / 8) { throw new IllegalStateException("Insufficient entropy provided by entropy source"); } return entropy; } }
if (entropySource.entropySize() < securityStrength)
if (entropySource.entropySize() < securityStrength) byte[] entropy = entropySource.getEntropy(); // Get_entropy_input
private byte[] getEntropy() { byte[] entropy = _entropySource.getEntropy(); if (entropy.length < (_securityStrength + 7) / 8) { throw new IllegalStateException("Insufficient entropy provided by entropy source"); } return entropy; }
if (entropySource.entropySize() < securityStrength)
if (entropySource.entropySize() < securityStrength) byte[] entropy = entropySource.getEntropy(); byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString); byte[] seed = Utils.hash_df(_digest, seedMaterial, _seedLength);
private byte[] getEntropy() { byte[] entropy = _entropySource.getEntropy(); if (entropy.length < (_securityStrength + 7) / 8) { throw new IllegalStateException("Insufficient entropy provided by entropy source"); } return entropy; }
if (entropySource.entropySize() < securityStrength || entropySource.entropySize() > MAX_ENTROPY_LENGTH)
if (entropySource.entropySize() < securityStrength) _hMac = hMac; byte[] entropy = entropySource.getEntropy(); byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString);
private byte[] getEntropy() { byte[] entropy = _entropySource.getEntropy(); if (entropy.length < (_securityStrength + 7) / 8) { throw new IllegalStateException("Insufficient entropy provided by entropy source"); } return entropy; }
if (entropySource.entropySize() < securityStrength || entropySource.entropySize() > MAX_ENTROPY_LENGTH) byte[] entropy = entropySource.getEntropy(); byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString);
/** * Reseed the RNG. */ void reseed() { V = entropySource.getEntropy(); if (V.length != engine.getBlockSize()) { throw new IllegalStateException("Insufficient entropy returned"); } reseedCounter = 1; }
/** * Reseed the DRBG. * * @param additionalInput additional input to be added to the DRBG in this step. */ public void reseed(byte[] additionalInput) { byte[] entropy = _entropySource.getEntropy(); byte[] seedMaterial = Arrays.concatenate(entropy, additionalInput); hmac_DRBG_Update(seedMaterial); _reseedCounter = 1; } }
private void CTR_DRBG_Reseed_algorithm(EntropySource entropy, byte[] additionalInput) { byte[] seedMaterial = Arrays.concatenate(entropy.getEntropy(), additionalInput); seedMaterial = Block_Cipher_df(seedMaterial, _seedLength); CTR_DRBG_Update(seedMaterial, _Key, _V); _reseedCounter = 1; }
/** * Reseed the DRBG. * * @param additionalInput additional input to be added to the DRBG in this step. */ public void reseed(byte[] additionalInput) { if (Utils.isTooLarge(additionalInput, MAX_ADDITIONAL_INPUT / 8)) { throw new IllegalArgumentException("Additional input string too large"); } byte[] entropy = _entropySource.getEntropy(); byte[] seedMaterial = Arrays.concatenate(pad8(_s, _seedlen), entropy, additionalInput); _s = Utils.hash_df(_digest, seedMaterial, _seedlen); _reseedCounter = 0; }
byte[] entropy = _entropySource.getEntropy(); byte[] seedMaterial = Arrays.concatenate(ONE, _V, entropy, additionalInput); byte[] seed = Utils.hash_df(_digest, seedMaterial, _seedLength);
private static SecureRandom createBaseRandom(boolean isPredictionResistant) { if (System.getProperty("org.bouncycastle.drbg.entropysource") != null) { EntropySourceProvider entropyProvider = createEntropySource(); EntropySource initSource = entropyProvider.get(16 * 8); byte[] personalisationString = isPredictionResistant ? generateDefaultPersonalizationString(initSource.getEntropy()) : generateNonceIVPersonalizationString(initSource.getEntropy()); return new SP800SecureRandomBuilder(entropyProvider) .setPersonalizationString(personalisationString) .buildHash(new SHA512Digest(), Arrays.concatenate(initSource.getEntropy(), initSource.getEntropy()), isPredictionResistant); } else { SecureRandom randomSource = new HybridSecureRandom(); // needs to be done late, can't use static byte[] personalisationString = isPredictionResistant ? generateDefaultPersonalizationString(randomSource.generateSeed(16)) : generateNonceIVPersonalizationString(randomSource.generateSeed(16)); return new SP800SecureRandomBuilder(randomSource, true) .setPersonalizationString(personalisationString) .buildHash(new SHA512Digest(), randomSource.generateSeed(32), isPredictionResistant); } }