Copyright | (c) Thomas DuBuisson 2017 (c) Max Amanshauser 2021 |
---|---|
License | MIT |
Maintainer | max@lambdalifting.org |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Secret-key authenticated encryption with additional data (AEAD): Crypto.Saltine.Core.AEAD.ChaCha20Poly1305IETF
Generating nonces for the functions in this module randomly is not recommended, due to the risk of generating collisions.
Synopsis
- data Key
- data Nonce
- aead :: Key -> Nonce -> ByteString -> ByteString -> ByteString
- aeadOpen :: Key -> Nonce -> ByteString -> ByteString -> Maybe ByteString
- aeadDetached :: Key -> Nonce -> ByteString -> ByteString -> (ByteString, ByteString)
- aeadOpenDetached :: Key -> Nonce -> ByteString -> ByteString -> ByteString -> Maybe ByteString
- newKey :: IO Key
- newNonce :: IO Nonce
Documentation
An opaque ChaCha20Poly1305IETF
cryptographic key.
Instances
Eq Key Source # | |
Data Key Source # | |
Defined in Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Key -> c Key # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Key # dataTypeOf :: Key -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Key) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key) # gmapT :: (forall b. Data b => b -> b) -> Key -> Key # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r # gmapQ :: (forall d. Data d => d -> u) -> Key -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Key -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Key -> m Key # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key # | |
Ord Key Source # | |
Show Key Source # | |
Generic Key Source # | |
NFData Key Source # | |
Hashable Key Source # | |
IsEncoding Key Source # | |
Defined in Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF encode :: Key -> ByteString Source # decode :: ByteString -> Maybe Key Source # encoded :: (Choice p, Applicative f) => p Key (f Key) -> p ByteString (f ByteString) Source # | |
type Rep Key Source # | |
Defined in Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF type Rep Key = D1 ('MetaData "Key" "Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF" "saltine-0.2.0.1-inplace" 'True) (C1 ('MetaCons "Key" 'PrefixI 'True) (S1 ('MetaSel ('Just "unKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
An opaque ChaCha20Poly1305IETF
nonce.
Instances
Eq Nonce Source # | |
Data Nonce Source # | |
Defined in Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Nonce -> c Nonce # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Nonce # dataTypeOf :: Nonce -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Nonce) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Nonce) # gmapT :: (forall b. Data b => b -> b) -> Nonce -> Nonce # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Nonce -> r # gmapQ :: (forall d. Data d => d -> u) -> Nonce -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Nonce -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Nonce -> m Nonce # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Nonce -> m Nonce # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Nonce -> m Nonce # | |
Ord Nonce Source # | |
Show Nonce Source # | |
Generic Nonce Source # | |
NFData Nonce Source # | |
Hashable Nonce Source # | |
IsNonce Nonce Source # | |
IsEncoding Nonce Source # | |
Defined in Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF encode :: Nonce -> ByteString Source # decode :: ByteString -> Maybe Nonce Source # encoded :: (Choice p, Applicative f) => p Nonce (f Nonce) -> p ByteString (f ByteString) Source # | |
type Rep Nonce Source # | |
Defined in Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF type Rep Nonce = D1 ('MetaData "Nonce" "Crypto.Saltine.Internal.AEAD.ChaCha20Poly1305IETF" "saltine-0.2.0.1-inplace" 'True) (C1 ('MetaCons "Nonce" 'PrefixI 'True) (S1 ('MetaSel ('Just "unNonce") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
:: Key | |
-> Nonce | |
-> ByteString | Message |
-> ByteString | AAD |
-> ByteString | Ciphertext |
Encrypts a message. It is infeasible for an attacker to decrypt
the message so long as the Nonce
is never repeated.
:: Key | |
-> Nonce | |
-> ByteString | Ciphertext |
-> ByteString | AAD |
-> Maybe ByteString | Message |
Decrypts a message. Returns Nothing
if the keys and message do
not match.
:: Key | |
-> Nonce | |
-> ByteString | Message |
-> ByteString | AAD |
-> (ByteString, ByteString) | Tag, Ciphertext |
Encrypts a message. It is infeasible for an attacker to decrypt
the message so long as the Nonce
is never repeated.
:: Key | |
-> Nonce | |
-> ByteString | Tag |
-> ByteString | Ciphertext |
-> ByteString | AAD |
-> Maybe ByteString | Message |
Decrypts a message. Returns Nothing
if the keys and message do
not match.