Maintainer | John Galt <jgalt@centromere.net> |
---|---|
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- class Cipher c where
- data Ciphertext c :: *
- data SymmetricKey c :: *
- data Nonce c :: *
- cipherName :: proxy c -> ScrubbedBytes
- cipherEncrypt :: SymmetricKey c -> Nonce c -> AssocData -> Plaintext -> Ciphertext c
- cipherDecrypt :: SymmetricKey c -> Nonce c -> AssocData -> Ciphertext c -> Maybe Plaintext
- cipherZeroNonce :: Nonce c
- cipherIncNonce :: Nonce c -> Nonce c
- cipherBytesToSym :: ScrubbedBytes -> SymmetricKey c
- cipherTextToBytes :: Ciphertext c -> ScrubbedBytes
- cipherBytesToText :: ScrubbedBytes -> Ciphertext c
- newtype Plaintext = Plaintext ScrubbedBytes
- newtype AssocData = AssocData ScrubbedBytes
Classes
Typeclass for ciphers.
data Ciphertext c :: * Source
Represents encrypted data containing an authentication tag.
data SymmetricKey c :: * Source
Represents a symmetric key.
Represents a nonce.
cipherName :: proxy c -> ScrubbedBytes Source
Returns the name of the cipher. This is used when generating the handshake name.
cipherEncrypt :: SymmetricKey c -> Nonce c -> AssocData -> Plaintext -> Ciphertext c Source
Encrypts data.
cipherDecrypt :: SymmetricKey c -> Nonce c -> AssocData -> Ciphertext c -> Maybe Plaintext Source
Decrypts data. Will fail catastrophically if the authentication tag is invalid.
cipherZeroNonce :: Nonce c Source
Returns a Nonce set to zero.
cipherIncNonce :: Nonce c -> Nonce c Source
Increments a nonce.
cipherBytesToSym :: ScrubbedBytes -> SymmetricKey c Source
Imports a symmetric key. If the input is greater than 32 bytes, it is truncated.
cipherTextToBytes :: Ciphertext c -> ScrubbedBytes Source
Exports a Ciphertext. The authentication tag follows the actual ciphertext.
cipherBytesToText :: ScrubbedBytes -> Ciphertext c Source
Imports a Ciphertext.
Types
Represents plaintext which can be encrypted.