public void Destroy_Success() { var testKey = OtpCalculationTests.RfcTestKey; KeyUtilities.Destroy(testKey); CollectionAssert.AreNotEqual(OtpCalculationTests.RfcTestKey, testKey); }
/// <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); }
public void Destroy_Empty() { KeyUtilities.Destroy(new byte[] { }); // just make sure this doesn't blow up }
public void Destroy_NullArgument() { new Action(() => KeyUtilities.Destroy(null)).ShouldThrow <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: sensitiveData"); }