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