Index: sdk/lib/crypto/hmac.dart |
diff --git a/sdk/lib/crypto/hmac.dart b/sdk/lib/crypto/hmac.dart |
index c73bd8fec54e03bf95eef3b41e2282991d2d4d8c..d7e3d98055b79d5ffe45f65acaa81d7b5b756a35 100644 |
--- a/sdk/lib/crypto/hmac.dart |
+++ b/sdk/lib/crypto/hmac.dart |
@@ -49,6 +49,20 @@ class _HMAC implements HMAC { |
return _hash.update(padding).update(innerHash).digest(); |
} |
+ bool verify(List<int> digest) { |
+ var computedDigest = this.digest(); |
+ if (digest.length != computedDigest.length) { |
+ throw new ArgumentError( |
+ 'Invalid digest size: ${digest.length} in HMAC.verify. ' |
+ 'Expected: ${_hash.blockSize}.'); |
+ } |
+ int result = 0; |
+ for (var i = 0; i < digest.length; i++) { |
+ result |= digest[i] ^ computedDigest[i]; |
+ } |
+ return result == 0; |
+ } |
+ |
// HMAC internal state. |
Hash _hash; |
List<int> _key; |