} // end cctr internal PBKDF2_HMACNotBuildInAdapter(IHash a_underlyingHash, byte[] a_password, byte[] a_salt, UInt32 a_iterations) { if (a_password == null) { throw new ArgumentNullHashLibException(EmptyPassword); } if (a_salt == null) { throw new ArgumentNullHashLibException(EmptySalt); } if (a_iterations <= 0) { throw new ArgumentOutOfRangeHashLibException(IterationTooSmall); } var hash = a_underlyingHash?.Clone() ?? throw new ArgumentNullHashLibException(UninitializedInstance); hmacNotBuiltIn = HMACNotBuildInAdapter.CreateHMAC(hash, a_password); BlockSize = hmacNotBuiltIn.HashSize; buffer = new byte[BlockSize]; // Copy Password Password = a_password.DeepCopy(); // Copy Salt Salt = a_salt.DeepCopy(); IterationCount = a_iterations; Initialize(); } // end constructor
internal PBKDF2HMACNotBuiltIn(IHash underlyingHash, byte[] password, byte[] salt, uint iterations) { if (password == null) { throw new ArgumentNullException(nameof(password)); } if (salt == null) { throw new ArgumentNullException(nameof(salt)); } if (iterations <= 0) { throw new ArgumentException(IterationTooSmall); } _password = ArrayUtils.Clone(password); _salt = ArrayUtils.Clone(salt); var hash = underlyingHash?.Clone() ?? throw new ArgumentNullException(nameof(underlyingHash)); _hmacNotBuiltIn = HMACNotBuiltIn.CreateHMAC(hash, _password); _iterations = iterations; _blockSize = _hmacNotBuiltIn.HashSize; _buffer = new byte[_blockSize]; Initialize(); }
internal HMACNotBuiltInToHMACAdapter(IHMACNotBuiltIn hmacNotBuiltIn) { _hmacNotBuiltIn = hmacNotBuiltIn != null ? (IHMACNotBuiltIn)hmacNotBuiltIn.Clone() : throw new ArgumentNullException(nameof(hmacNotBuiltIn)); BlockSizeValue = hmacNotBuiltIn.BlockSize; HashSizeValue = hmacNotBuiltIn.HashSize * 8; Initialize(); }
CreateHMACFromHMACNotBuiltIn(IHMACNotBuiltIn hmacNotBuiltIn) => new HMACNotBuiltInToHMACAdapter(hmacNotBuiltIn);