raaz-0.2.0: The raaz cryptographic library.

Safe HaskellNone
LanguageHaskell2010

Raaz.Cipher

Contents

Description

This module exposes all the ciphers provided by raaz. The interface here is pretty low level and it is usually the case that you would not need to work at this level of detail.

Synopsis

Ciphers

The raaz library exposes symmetric key encryption using instances of the class Cipher. For a cipher c, the type family Key c gives the type of its key. As of now, we only support the safe usage of stream ciphers. Encryption and Decryption are the same for stream ciphers and we call this combinator transform. Block ciphers do not have a natural way to handle streams that are of size less than their block size. A future release will handle these issues.

If you are thinking of encryption using private keys consider encrypted-authenticated modes. Currently we do not have support for this either but hopefully this will also be fixed soon.

TODO: Fix the above documentation when it is done.

class Cipher cipher => StreamCipher cipher Source #

Class that captures stream ciphers. An instance of StreamCipher should be an instance of Cipher, with the following additional constraints.

  1. The encryption and decryption should be the same algorithm.
  2. Encryption/decryption can be applied to a messages of length l even if l is not a multiple of block length.
  3. The encryption of a prefix of a length l of a message m should be the same as the l length prefix of the encryption of m.

It is the duty of the implementer of the cipher to ensure that the above conditions are true before declaring an instance of a stream cipher.

transform :: (StreamCipher c, Recommendation c) => c -> Key c -> ByteString -> ByteString Source #

Transform a given bytestring using the recommended implementation of a stream cipher.

chacha20 :: ChaCha20 Source #

The chacha20 stream cipher.

class (Primitive cipher, Implementation cipher ~ SomeCipherI cipher, Describable cipher) => Cipher cipher Source #

Class capturing ciphers. The implementation of this class should give an encryption and decryption algorithm for messages of length which is a multiple of the block size. Needless to say, the encryption and decryption should be inverses of each other for such messages.

Instances

aes128cbc :: AES 128 CBC Source #

128-bit aes cipher in CBC mode.

aes192cbc :: AES 192 CBC Source #

128-bit aes cipher in CBC mode.

aes256cbc :: AES 256 CBC Source #

128-bit aes cipher in CBC mode.