Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Unified Diff: sdk/lib/crypto/crypto.dart

Issue 11417138: Add verify method to HMAC instances to have a comparison utility that does not leak information thr… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/crypto/hmac.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/crypto/crypto.dart
diff --git a/sdk/lib/crypto/crypto.dart b/sdk/lib/crypto/crypto.dart
index 1064ca01a40e0686d092aa7d146fae629dc0fb0a..078b21dc93d9bf0f72770bf627001193866dba61 100644
--- a/sdk/lib/crypto/crypto.dart
+++ b/sdk/lib/crypto/crypto.dart
@@ -44,7 +44,10 @@ abstract class Hash {
Hash newInstance();
/**
- * Block size of the hash in bytes.
+ * Internal block size of the hash in bytes.
+ *
+ * This is exposed for use by the HMAC class which needs to know the
+ * block size for the [Hash] it is using.
*/
int get blockSize;
}
@@ -95,6 +98,18 @@ abstract class HMAC {
* as a list of bytes.
*/
List<int> digest();
+
+ /**
+ * Verify that the HMAC computed for the data so far matches the
+ * given message digest.
+ *
+ * This method should be used instead of memcmp-style comparisons
+ * to avoid leaking information via timing.
+ *
+ * Throws an exception if the given digest does not have the same
+ * size as the digest computed by this HMAC instance.
+ */
+ bool verify(List<int> digest);
}
/**
« no previous file with comments | « no previous file | sdk/lib/crypto/hmac.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698