Index: tests/lib/crypto/hmac_md5_test.dart |
diff --git a/tests/lib/crypto/hmac_md5_test.dart b/tests/lib/crypto/hmac_md5_test.dart |
index 24753bfc12d59f2d0e469e819e113938b0572296..f47c7109191cb1fe84bc01d991df1bcd874e79ab 100644 |
--- a/tests/lib/crypto/hmac_md5_test.dart |
+++ b/tests/lib/crypto/hmac_md5_test.dart |
@@ -71,7 +71,7 @@ var hmac_md5_keys = |
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, |
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa ] ]; |
-var hmac_md5_macs = |
+var hmac_md5_string_macs = |
const [ '9294727a3638bb1c13f48ef8158bfc9d', |
'750c783e6ab0b503eaa86e310a5db738', |
'56be34521d144c88dbb8c733f0e8b3f6', |
@@ -80,13 +80,34 @@ var hmac_md5_macs = |
'6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd', |
'6f630fad67cda0ee1fb1f562db3aa53e' ]; |
-void testStandardVectors(inputs, keys, macs) { |
+var hmac_md5_macs = |
+ const [ const [0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, 0x13, 0xf4, |
+ 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d], |
+ const [0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, 0xea, 0xa8, |
+ 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38], |
+ const [0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, 0xdb, 0xb8, |
+ 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6], |
+ const [0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea, 0x3a, 0x75, |
+ 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79], |
+ const [0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00, 0xf9, 0xba, |
+ 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c], |
+ const [0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f, 0x0b, 0x62, |
+ 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd], |
+ const [0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee, 0x1f, 0xb1, |
+ 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e]]; |
+ |
+void testStandardVectors(inputs, keys, string_macs, macs) { |
for (var i = 0; i < inputs.length; i++) { |
- var d = new HMAC(new MD5(), keys[i]).update(inputs[i]).digest(); |
- Expect.isTrue(CryptoUtils.bytesToHex(d).startsWith(macs[i]), '$i'); |
+ var h = new HMAC(new MD5(), keys[i]); |
+ var d = h.update(inputs[i]).digest(); |
+ Expect.isTrue(CryptoUtils.bytesToHex(d).startsWith(string_macs[i]), '$i'); |
+ Expect.isTrue(h.verify(macs[i])); |
+ Expect.isFalse(h.verify(macs[(i+1)%macs.length])); |
+ Expect.throws(() => h.verify([])); |
} |
} |
void main() { |
- testStandardVectors(hmac_md5_inputs, hmac_md5_keys, hmac_md5_macs); |
+ testStandardVectors(hmac_md5_inputs, hmac_md5_keys, |
+ hmac_md5_string_macs, hmac_md5_macs); |
} |