public Rfc2898DeriveBytes(string password, int saltSize, int iterations, HashAlgorithmName hashAlgorithm) { if (saltSize < 0) { throw new ArgumentOutOfRangeException(nameof(saltSize), SR.ArgumentOutOfRange_NeedNonNegNum); } if (saltSize < MinimumSaltSize) { throw new ArgumentException(SR.Cryptography_PasswordDerivedBytes_FewBytesSalt, nameof(saltSize)); } if (iterations <= 0) { throw new ArgumentOutOfRangeException(nameof(iterations), SR.ArgumentOutOfRange_NeedPosNum); } _salt = Helpers.GenerateRandom(saltSize); _iterations = (uint)iterations; _password = Encoding.UTF8.GetBytes(password); HashAlgorithm = hashAlgorithm; _hmac = OpenHmac(); // _blockSize is in bytes, HashSize is in bits. _blockSize = _hmac.HashSize >> 3; Initialize(); }
public Rfc2898DeriveBytes(string password, int saltSize, int iterations) { if (saltSize < 0) { throw new ArgumentOutOfRangeException(nameof(saltSize), SR.ArgumentOutOfRange_NeedNonNegNum); } if (saltSize < MinimumSaltSize) { throw new ArgumentException(SR.Cryptography_PasswordDerivedBytes_FewBytesSalt, nameof(saltSize)); } if (iterations <= 0) { throw new ArgumentOutOfRangeException(nameof(iterations), SR.ArgumentOutOfRange_NeedPosNum); } _salt = Helpers.GenerateRandom(saltSize); _iterations = (uint)iterations; _password = Encoding.UTF8.GetBytes(password); _hmacSha1 = new HMACSHA1(_password); Initialize(); }
public HMACSHA1() : this(Helpers.GenerateRandom(BlockSize)) { }
public HMACGost3411() : this(Helpers.GenerateRandom(BlockSize)) { }
public HMACSHA512() : this(Helpers.GenerateRandom(128)) { }
public HMACSHA1() : this(Helpers.GenerateRandom(64)) { }
public void GenerateKey() { byte[] key = Helpers.GenerateRandom(AsymmetricAlgorithmHelpers.BitsToBytes(_outer.BaseKeySize)); SetKey(key); }
public void GenerateIV() { byte[] iv = Helpers.GenerateRandom(AsymmetricAlgorithmHelpers.BitsToBytes(_outer.BlockSize)); _outer.IV = iv; }
public HMACMD5() : this(Helpers.GenerateRandom(64)) { }