Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- 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
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 Key
ctransform
. 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.
- The encryption and decryption should be the same algorithm.
- Encryption/decryption can be applied to a messages of length
l
even ifl
is not a multiple of block length. - The encryption of a prefix of a length
l
of a messagem
should be the same as thel
length prefix of the encryption ofm
.
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.
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.