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

Unified Diff: lib/crypto/crypto.dart

Issue 10170027: Implement HMAC support in lib/crypto. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months 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 | lib/crypto/sha1.dart » ('j') | lib/crypto/sha_utils.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/crypto/crypto.dart
diff --git a/lib/crypto/crypto.dart b/lib/crypto/crypto.dart
index 6a839974017206c69f7f1bc73cea24a0209bca80..6b2c9f32d86779d1c75b43ccd6536d2eed06d6db 100644
--- a/lib/crypto/crypto.dart
+++ b/lib/crypto/crypto.dart
@@ -4,6 +4,7 @@
#library('crypto');
+#source('hmac.dart');
#source('sha_utils.dart');
#source('sha1.dart');
#source('sha256.dart');
@@ -12,10 +13,14 @@
* Interface for cryptographic hash functions.
*
* The [update] method is used to add data to the hash. The [digest] method
- * is used to extract the message digest. Once the [digest] method has been
- * called the CryptoHash object is in an invalid state and should not be
- * used again. If [digest] or [update] are called after the first call to
- * [digest] a CryptoHashException is thrown.
+ * is used to extract the message digest.
+ *
+ * Once the [digest] method has been called the CryptoHash object is in an
+ * invalid state and should not be used again. If [digest] or [update] are
+ * called after the first call to [digest] a CryptoHashException is thrown.
Ben Laurie (Google) 2012/04/27 13:26:33 I still say you should be able to call [digest] a
Mads Ager (google) 2012/04/30 07:56:57 OK, allowed multiple calls to digest to extract th
+ *
+ * If multiple instances of a given CryptoHash is needed the [newInstance]
+ * method can provide a new instance.
*/
interface CryptoHash {
/**
@@ -28,6 +33,16 @@ interface CryptoHash {
* a list of bytes.
*/
List<int> digest();
+
+ /**
+ * Returns a new instance of this hash function.
+ */
+ CryptoHash newInstance();
+
+ /**
+ * Block size of the hash in bytes.
+ */
+ int get blockSize();
}
/**
@@ -46,6 +61,31 @@ interface SHA256 extends CryptoHash default _SHA256 {
/**
+ * Hash-based Message Authentication Code support.
+ *
+ * The [update] method is used to add data to the message. The [digest] method
+ * is used to extract the message authentication code.
+ */
+interface HMAC default _HMAC {
Ben Laurie (Google) 2012/04/27 13:26:33 Why CryptoHash and not CryptoHMAC?
Mads Ager (google) 2012/04/30 07:56:57 Yeah, good question. There is next to zero chance
+ /**
+ * Create an [HMAC] object from a [CryptoHash] and a key.
+ */
+ HMAC(CryptoHash hash, List<int> key);
+
+ /**
+ * Add a list of bytes to the message.
+ */
+ HMAC update(List<int> data);
+
+ /**
+ * Perform the actual computation and extract the message digest
+ * as a list of bytes.
+ */
+ List<int> digest();
+}
+
+
+/**
* CryptoHashExceptions are thrown on invalid use of a CryptoHash
* object.
*/
« no previous file with comments | « no previous file | lib/crypto/sha1.dart » ('j') | lib/crypto/sha_utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698