Ejemplo n.º 1
0
 public HMacSP800Drbg(IMac hMac, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce)
 {
     if (securityStrength > DrbgUtilities.GetMaxSecurityStrength(hMac))
     {
         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");
     }
     mHMac             = hMac;
     mSecurityStrength = securityStrength;
     mEntropySource    = entropySource;
     byte[] entropy      = GetEntropy();
     byte[] seedMaterial = Arrays.ConcatenateAll(entropy, nonce, personalizationString);
     mK = new byte[hMac.GetMacSize()];
     mV = new byte[mK.Length];
     Arrays.Fill(mV, 1);
     hmac_DRBG_Update(seedMaterial);
     mReseedCounter = 1L;
 }
Ejemplo 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;
 }