First Attempt at Crypto Library

Dominic Steinitz
Wed, 23 Apr 2003 21:55:35 +0100

I'm not sure where we are on the name for the proposed crypto library. Are
we going for:


If so I'm not sure how modes such as Cipher Block Chaining (see below) fit
in as they apply to all block ciphers. There is also the issue of padding

Are we saying that there should be:


I'm not sure what will happen when we add asymmetric algorithms but it seems
ok for now.

Should what Codec.Encryption.DES exports be des & unDes or should they be
encrypt and decrypt? I presume the latter.

-- * CBC or Cipher Block Chaining Mode

-- | In CBC or Cipher Block Chaining mode each block is XORed with
-- the previous enciphered block before encryption.  For the first
-- block we start with an initialization vector.

cbc :: Bits block =>
       (key -> block -> block) ->
       block ->
       key ->
       [block] ->

cbc e iv k ps =
   ciphers where
      ciphers = map (e k) feedIns
      feedIns = zipWith xor (iv : ciphers) ps

Dominic Steinitz
----- Original Message -----
From: "Dominic Steinitz" <>
To: "Simon Peyton-Jones" <>; "Simon Marlow"
Cc: <>
Sent: Monday, April 21, 2003 6:46 PM
Subject: First Attempt at Crypto Library

> Simon, Simon,
> Here's my first attempt at a crypto library. It compiles and I can run a
> test using ghc-inplace. The test checks with the example in
> (except I couldn't find an
> example with PKCS#5 padding). I'm not sure what the next steps are.
> Dominic Steinitz