Esempio n. 1
0
        public void Destroy_Success()
        {
            var testKey = OtpCalculationTests.RfcTestKey;

            KeyUtilities.Destroy(testKey);
            CollectionAssert.AreNotEqual(OtpCalculationTests.RfcTestKey, testKey);
        }
Esempio n. 2
0
        /// <summary>
        /// Uses the key to get an HMAC using the specified algorithm and data
        /// </summary>
        /// <param name="mode">The HMAC algorithm to use</param>
        /// <param name="data">The data used to compute the HMAC</param>
        /// <returns>HMAC of the key and data</returns>
        public byte[] ComputeHmac(OtpHashMode mode, byte[] data)
        {
            byte[] hashedValue;
            using (var hmac = CreateHmacHash(mode))
            {
                var key = GetCopyOfKey();
                try
                {
                    hmac.Key    = key;
                    hashedValue = hmac.ComputeHash(data);
                }
                finally
                {
                    KeyUtilities.Destroy(key);
                }
            }

            return(hashedValue);
        }
Esempio n. 3
0
 public void Destroy_Empty()
 {
     KeyUtilities.Destroy(new byte[] { }); // just make sure this doesn't blow up
 }
Esempio n. 4
0
 public void Destroy_NullArgument()
 {
     new Action(() => KeyUtilities.Destroy(null)).ShouldThrow <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: sensitiveData");
 }