Esempio n. 1
0
 public void Reseed(byte[] additionalInput)
 {
     byte[] entropy      = GetEntropy();
     byte[] seedMaterial = Arrays.ConcatenateAll(ONE, mV, entropy, additionalInput);
     byte[] array        = mV = DrbgUtilities.HashDF(mDigest, seedMaterial, mSeedLength);
     byte[] array2       = new byte[mV.Length + 1];
     array2[0] = 0;
     Array.Copy(mV, 0, array2, 1, mV.Length);
     mC             = DrbgUtilities.HashDF(mDigest, array2, mSeedLength);
     mReseedCounter = 1L;
 }
Esempio n. 2
0
 public HashSP800Drbg(IDigest digest, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce)
 {
     if (securityStrength > DrbgUtilities.GetMaxSecurityStrength(digest))
     {
         throw new ArgumentException("Requested security strength is not supported by the derivation function");
     }
     if (entropySource.EntropySize < securityStrength)
     {
         throw new ArgumentException("Not enough entropy for security strength required");
     }
     mDigest           = digest;
     mEntropySource    = entropySource;
     mSecurityStrength = securityStrength;
     mSeedLength       = (int)seedlens[digest.AlgorithmName];
     byte[] entropy      = GetEntropy();
     byte[] seedMaterial = Arrays.ConcatenateAll(entropy, nonce, personalizationString);
     byte[] array        = mV = DrbgUtilities.HashDF(mDigest, seedMaterial, mSeedLength);
     byte[] array2       = new byte[mV.Length + 1];
     Array.Copy(mV, 0, array2, 1, mV.Length);
     mC             = DrbgUtilities.HashDF(mDigest, array2, mSeedLength);
     mReseedCounter = 1L;
 }