[Haskell-cafe] haskell crypto is reaaaaaaaaaally slow

Donald Bruce Stewart dons at cse.unsw.edu.au
Wed Jun 20 02:50:57 EDT 2007


ttmrichter:
> 
>    On Wed, 2007-20-06 at 15:21 +1000, Donald Bruce Stewart
>    wrote:
> 
>     -- unsigned char *MD5(const unsigned char *d, unsigned long n, un
> signed char *md);
>     foreign import ccall "openssl/md5.h MD5" c_md5
>         :: Ptr CChar -> CULong -> Ptr CChar -> IO (Ptr Word8)
> 
> ByteStrings were designed for this zero-copy passing of big data to C
> ,
> by the way, so its a perfect fit.
> 
>    I'm not so sure I like the idea of having to do this by

You don't *have* to do it via C, but you *can* do it, if you want.

>    passing it over to C.  Crypto sounds like exactly the kind
>    of application that would require the certainty of FP
>    reasoning.  Is there no way to make it work reasonably
>    efficiently in Haskell proper?

Sure, why not? We've a good native code compiler, after all. Write an
md5 over ByteString -- it should be pretty competitive. Here's a
reference C implementation to start from:

    http://www.cse.unsw.edu.au/~dons/tmp/md5.c

-- Don


More information about the Haskell-Cafe mailing list