Safe Haskell | None |
---|
- class Cipher cipher where
- cipherInit :: Key cipher -> cipher
- cipherName :: cipher -> String
- cipherKeySize :: cipher -> KeySizeSpecifier
- class Cipher cipher => BlockCipher cipher where
- blockSize :: cipher -> Int
- ecbEncrypt :: cipher -> ByteString -> ByteString
- ecbDecrypt :: cipher -> ByteString -> ByteString
- cbcEncrypt :: cipher -> IV cipher -> ByteString -> ByteString
- cbcDecrypt :: cipher -> IV cipher -> ByteString -> ByteString
- ctrCombine :: cipher -> IV cipher -> ByteString -> ByteString
- xtsEncrypt :: (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString
- xtsDecrypt :: (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString
- aeadInit :: Byteable iv => AEADMode -> cipher -> iv -> Maybe (AEAD cipher)
- class Cipher cipher => StreamCipher cipher where
- streamEncrypt :: cipher -> ByteString -> (ByteString, cipher)
- streamDecrypt :: cipher -> ByteString -> (ByteString, cipher)
- data AES128
- data AES192
- data AES256
- data Blowfish
- data DES
- data DES_EEE3
- data DES_EDE3
- data DES_EEE2
- data DES_EDE2
- data Camellia128
Cipher classes
class Cipher cipher where
Symmetric cipher class.
cipherInit :: Key cipher -> cipher
Initialize a cipher context from a key
cipherName :: cipher -> String
Cipher name
cipherKeySize :: cipher -> KeySizeSpecifier
return the size of the key required for this cipher. Some cipher accept any size for key
class Cipher cipher => BlockCipher cipher where
Symmetric block cipher class
Return the size of block required for this block cipher
ecbEncrypt :: cipher -> ByteString -> ByteString
Encrypt using the ECB mode.
input need to be a multiple of the blocksize
ecbDecrypt :: cipher -> ByteString -> ByteString
Decrypt using the ECB mode.
input need to be a multiple of the blocksize
cbcEncrypt :: cipher -> IV cipher -> ByteString -> ByteString
encrypt using the CBC mode.
input need to be a multiple of the blocksize
cbcDecrypt :: cipher -> IV cipher -> ByteString -> ByteString
decrypt using the CBC mode.
input need to be a multiple of the blocksize
ctrCombine :: cipher -> IV cipher -> ByteString -> ByteString
combine using the CTR mode.
CTR mode produce a stream of randomized data that is combined (by XOR operation) with the input stream.
encryption and decryption are the same operation.
input can be of any size
xtsEncrypt :: (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString
encrypt using the XTS mode.
input need to be a multiple of the blocksize
xtsDecrypt :: (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString
decrypt using the XTS mode.
input need to be a multiple of the blocksize
aeadInit :: Byteable iv => AEADMode -> cipher -> iv -> Maybe (AEAD cipher)
Initialize a new AEAD State
When Nothing is returns, it means the mode is not handled.
class Cipher cipher => StreamCipher cipher where
Symmetric stream cipher class
streamEncrypt :: cipher -> ByteString -> (ByteString, cipher)
Encrypt using the stream cipher
streamDecrypt :: cipher -> ByteString -> (ByteString, cipher)
Decrypt using the stream cipher
Cipher implementations
data DES_EEE3
3DES with 3 different keys used all in the same direction
data DES_EDE3
3DES with 3 different keys used in alternative direction
data DES_EEE2
3DES where the first and third keys are equal, used in the same direction
data DES_EDE2
3DES where the first and third keys are equal, used in alternative direction