raaz-0.2.1: The raaz cryptographic library.

Safe Haskell | None
Language | Haskell2010

Raaz.Cipher

Contents

- Ciphers

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

- class Cipher cipher => StreamCipher cipher
- transform :: (StreamCipher c, Recommendation c) => c -> Key c -> ByteString -> ByteString
- chacha20 :: ChaCha20
- class (Primitive cipher, Implementation cipher ~ SomeCipherI cipher, Describable cipher) => Cipher cipher
- aes128cbc :: AES 128 CBC
- aes192cbc :: AES 192 CBC
- aes256cbc :: AES 256 CBC

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

Instances

StreamCipher ChaCha20 Source # |
Instance details Defined in Raaz.Cipher.ChaCha20.Internal

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

Cipher ChaCha20 Source # |
Instance details Defined in Raaz.Cipher.ChaCha20.Internal
Cipher (AES 128 CBC) Source # |
Instance details Defined in Raaz.Cipher.AES.Internal
Cipher (AES 192 CBC) Source # |
Instance details Defined in Raaz.Cipher.AES.Internal
Cipher (AES 256 CBC) Source # |
Instance details Defined in Raaz.Cipher.AES.Internal

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.