Hi,

> If you decide to code the solution and provide the patch, I will be
> happy to apply it to cryptokit (if the main author of cryptokit accepts
> it, of course).

I'm attaching the patches adding support for HMAC-SHA256 and HMAC-RIPEMD160
(I don't need the latter, but for the sake of completeness it seemed silly
not to support it as well).  Note that these are *very* straightforward
patches -- kudos to Xavier for making Cryptokit so easy to extend.

The caveat is that I'm not a cryptographer.  I did, however, verify that
these new HMACs pass all the test cases listed in RFC4231 (for HMAC-SHA256)
and RFC2286 (for HMAC-RIPEMD160).

Thanks for your attention!
Cheers,
Dario Teixeira


      
--- cryptokit.mli.old	2010-07-21 22:10:37.000000000 +0100
+++ cryptokit.mli	2010-07-21 22:13:09.000000000 +0100
@@ -483,6 +483,16 @@
         applied to SHA-1.  The returned hash values are 160 bits (20 bytes)
         long.  The [key] argument is the MAC key; it can have any length,
         but a minimal length of 20 bytes is recommended. *)
+  val hmac_sha256: string -> hash
+    (** [hmac_sha256 key] returns a MAC based on the HMAC construction (RFC2104)
+        applied to SHA-256.  The returned hash values are 256 bits (32 bytes)
+        long.  The [key] argument is the MAC key; it can have any length,
+        but a minimal length of 32 bytes is recommended. *)
+  val hmac_ripemd160: string -> hash
+    (** [hmac_ripemd160 key] returns a MAC based on the HMAC construction (RFC2104)
+        applied to RIPEMD-160.  The returned hash values are 160 bits (20 bytes)
+        long.  The [key] argument is the MAC key; it can have any length,
+        but a minimal length of 20 bytes is recommended. *)
   val hmac_md5: string -> hash
     (** [hmac_md5 key] returns a MAC based on the HMAC construction (RFC2104)
         applied to MD5.  The returned hash values are 128 bits (16 bytes)
--- cryptokit.ml.old	2010-07-21 19:33:24.000000000 +0100
+++ cryptokit.ml	2010-07-21 22:03:48.000000000 +0100
@@ -947,9 +947,13 @@
 module MAC = struct
 
 module HMAC_SHA1 = HMAC(struct class h = Hash.sha1  let blocksize = 64 end)
+module HMAC_SHA256 = HMAC(struct class h = Hash.sha256  let blocksize = 64 end)
+module HMAC_RIPEMD160 = HMAC(struct class h = Hash.ripemd160  let blocksize = 64 end)
 module HMAC_MD5  = HMAC(struct class h = Hash.md5  let blocksize = 64 end)
 
 let hmac_sha1 key = new HMAC_SHA1.hmac key
+let hmac_sha256 key = new HMAC_SHA256.hmac key
+let hmac_ripemd160 key = new HMAC_RIPEMD160.hmac key
 let hmac_md5 key = new HMAC_MD5.hmac key
 
 let aes ?iv ?pad key =
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to