caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Re: Cryptokit and HMAC-SHA256
@ 2010-07-21 21:22 Dario Teixeira
  2010-07-22  8:37 ` Goswin von Brederlow
  0 siblings, 1 reply; 5+ messages in thread
From: Dario Teixeira @ 2010-07-21 21:22 UTC (permalink / raw)
  To: caml-list, Sylvain Le Gall

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

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


      

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cryptokit.mli.patch --]
[-- Type: text/x-diff; name="cryptokit.mli.patch", Size: 1205 bytes --]

--- 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)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: cryptokit.ml.patch --]
[-- Type: text/x-diff; name="cryptokit.ml.patch", Size: 691 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 =

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-07-22 13:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 21:22 [Caml-list] Re: Cryptokit and HMAC-SHA256 Dario Teixeira
2010-07-22  8:37 ` Goswin von Brederlow
2010-07-22  8:49   ` Sylvain Le Gall
2010-07-22  9:44     ` [Caml-list] " Dario Teixeira
2010-07-22 13:24     ` Goswin von Brederlow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).