Safe Haskell | Safe-Infered |
---|
- data Key
- newtype IV = IV ByteString
- initKey :: ByteString -> Key
- genCTR :: Key -> IV -> Int -> ByteString
- encryptECB :: Key -> ByteString -> ByteString
- encryptCBC :: Key -> IV -> ByteString -> ByteString
- encryptCTR :: Key -> IV -> ByteString -> ByteString
- encryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteString
- encryptGCM :: Key -> IV -> ByteString -> ByteString -> (ByteString, ByteString)
- decryptECB :: Key -> ByteString -> ByteString
- decryptCBC :: Key -> IV -> ByteString -> ByteString
- decryptCTR :: Key -> IV -> ByteString -> ByteString
- decryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteString
- decryptGCM :: Key -> IV -> ByteString -> ByteString -> (ByteString, ByteString)
data types
creation
initKey :: ByteString -> KeySource
initialize key
misc
:: Key | Cipher Key. |
-> IV | usually a 128 bit integer. |
-> Int | length of bytes required. |
-> ByteString |
generate a counter mode pad. this is generally xor-ed to an input to make the standard counter mode block operations.
if the length requested is not a multiple of the block cipher size, more data will be returned, so that the returned bytestring is a multiple of the block cipher size.
encryption
encryptECB :: Key -> ByteString -> ByteStringSource
encrypt using Electronic Code Book (ECB)
encryptCBC :: Key -> IV -> ByteString -> ByteStringSource
encrypt using Cipher Block Chaining (CBC)
encryptCTR :: Key -> IV -> ByteString -> ByteStringSource
encrypt using Counter mode (CTR)
in CTR mode encryption and decryption is the same operation.
encryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteStringSource
encrypt using XTS
the first key is the normal block encryption key the second key is used for the initial block tweak
:: Key | Key |
-> IV | initial vector |
-> ByteString | data to authenticate (AAD) |
-> ByteString | data to encrypt |
-> (ByteString, ByteString) | ciphertext and tag |
encrypt using Galois counter mode (GCM) return the encrypted bytestring and the tag associated
note: encrypted data is identical to CTR mode in GCM, however a tag is also computed.
decryption
decryptECB :: Key -> ByteString -> ByteStringSource
decrypt using Electronic Code Book (ECB)
decryptCBC :: Key -> IV -> ByteString -> ByteStringSource
decrypt using Cipher block chaining (CBC)
decryptCTR :: Key -> IV -> ByteString -> ByteStringSource
decrypt using Counter mode (CTR).
in CTR mode encryption and decryption is the same operation.
decryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteStringSource
decrypt using XTS
decryptGCM :: Key -> IV -> ByteString -> ByteString -> (ByteString, ByteString)Source
decrypt using Galois Counter Mode (GCM)