Exemple #1
0
        public HMACSHA256Cng(byte[] key, CngProvider algorithmProvider)
        {
            if (key == null)
                throw new ArgumentNullException("key");
            if (algorithmProvider == null)
                throw new ArgumentNullException("algorithmProvider");

            HashName = "SHA256";

            m_hmac = new BCryptHMAC(CngAlgorithm.Sha256, algorithmProvider, HashName, BlockSize, key);
        }
Exemple #2
0
        /// <summary>
        ///     Constructs a HMACSHA512Cng object using the given key, which will calculate the HMAC using the
        ///     given algorithm provider and key.
        /// </summary>
        /// <param name="key">key to use when calculating the HMAC</param>
        /// <param name="algorithmProvider">algorithm provider to calculate the HMAC in</param>
        /// <exception cref="ArgumentNullException">
        ///     if <paramref name="key"/> or <paramref name="algorithmProvider"/> are null
        /// </exception>
        public HMACSHA512Cng(byte[] key, CngProvider algorithmProvider)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (algorithmProvider == null)
            {
                throw new ArgumentNullException("algorithmProvider");
            }

            m_hmac   = new BCryptHMAC(CngAlgorithm.Sha512, algorithmProvider, "SHA512", BlockSize, key);
            HashName = m_hmac.HashName;
        }
Exemple #3
0
        public HMACSHA384Cng(byte[] key, CngProvider algorithmProvider)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (algorithmProvider == null)
            {
                throw new ArgumentNullException("algorithmProvider");
            }

            HashName = "SHA384";

            m_hmac = new BCryptHMAC(CngAlgorithm.Sha384, algorithmProvider, HashName, BlockSize, key);
        }