public void TestDataHashCreateWithInvalidValueLengthFromBytes() { HashingException ex = Assert.Throws <HashingException>(delegate { new DataHash(new byte[] { 1, 1, 2, 3, 4, 5, 6 }); }); Assert.That(ex.Message, Does.StartWith("Hash size(6) does not match SHA-256 size(32)")); }
public void TestDataHashCreateWithZeroLengthBytes() { HashingException ex = Assert.Throws <HashingException>(delegate { new DataHash(new byte[] { }); }); Assert.That(ex.Message, Does.StartWith("Hash imprint is too short.")); }
public void TestDataHashCreateWithInvalidAlgorithmFromBytes() { HashingException ex = Assert.Throws <HashingException>(delegate { new DataHash(new byte[] { 255 }); }); Assert.That(ex.Message, Does.StartWith("Hash algorithm id(255) is unknown")); }
public void TestDataHashCreateWithInvalidValueLength() { HashingException ex = Assert.Throws <HashingException>(delegate { new DataHash(HashAlgorithm.Sha2256, new byte[] { 1, 1 }); }); Assert.That(ex.Message, Does.StartWith("Hash size(2) does not match SHA-256 size(32)")); }
public void TestDataHasherWithAlgorithmNotImplemented() { HashingException ex = Assert.Throws <HashingException>(delegate { CryptoTestFactory.CreateDataHasher(HashAlgorithm.Sha3256); }); Assert.That(ex.Message, Does.StartWith("Hash algorithm(SHA3-256) is not supported")); }
public void LergacyUseDeprecatedHmacAlgoTest() { KsiService service = GetService(PduVersion.v1, HashAlgorithm.Sha2256, HashAlgorithm.Sha1); HashingException ex = Assert.Throws <HashingException>(delegate { service.Extend(1510056000L); }); Assert.That(ex.Message.StartsWith("Hash algorithm SHA1 is deprecated since 2016-07-01 and can not be used for HMAC"), "Unexpected inner exception message: " + ex.Message); }
public void UseDeprecatedHmacAlgoTest() { KsiService service = GetService(PduVersion.v2, HashAlgorithm.Sha1, HashAlgorithm.Sha2256); Ksi ksi = new Ksi(service); HashingException ex = Assert.Throws <HashingException>(delegate { SignHash(ksi); }); Assert.That(ex.Message.StartsWith("Hash algorithm SHA1 is deprecated since 2016-07-01 and can not be used for HMAC"), "Unexpected inner exception message: " + ex.Message); }
public void TestDataHasherWithAddingDataAfterHashHasBeenCalculated() { IDataHasher hasher = CryptoTestFactory.CreateDataHasher(); byte[] data = System.Text.Encoding.UTF8.GetBytes(Resources.DataHasher_TestString); hasher.AddData(data); hasher.GetHash(); HashingException ex = Assert.Throws <HashingException>(delegate { hasher.AddData(data); }); Assert.That(ex.Message, Does.StartWith("Output hash has already been calculated")); }