First Attempt at Crypto Library

Dominic Steinitz dominic.steinitz@blueyonder.co.uk
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:

    Codec.Encryption.DES
    Codec.Encryption.RSA
    Codec.Encryption.Blowfish

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
schemes.

Are we saying that there should be:

    Codec.Encryption.Modes
    Codec.Encryption.Padding

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] ->
       [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" <dominic.steinitz@blueyonder.co.uk>
To: "Simon Peyton-Jones" <simonpj@microsoft.com>; "Simon Marlow"
<simonmar@microsoft.com>
Cc: <libraries-request@haskell.org>
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
> http://www.itl.nist.gov/fipspubs/fip81.htm (except I couldn't find an
> example with PKCS#5 padding). I'm not sure what the next steps are.
>
> Dominic Steinitz
>