Copyright | (c) Leo D 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | leo@apotheca.io |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
A block cipher by itself, is only able to securely encrypt a single data block. To be able to securely encrypt data of arbitrary length, a mode of operation applies the block cipher’s single block operation repeatedly to encrypt an entire message.
Synopsis
- data Cipher
- newtype AEAD = MkAEAD {}
- aead :: Cipher -> Maybe AEAD
- unsafeAEAD :: Cipher -> AEAD
- isAEAD :: Cipher -> Bool
- ciphers :: [Cipher]
- cbcPaddings :: [CBCPadding]
- aeads :: [AEAD]
- type CipherKey = CipherKey
- type CipherNonce = ByteString
- data CBCPadding
- type AEADAssociatedData = ByteString
- cipherName :: Cipher -> CipherName
- cipherKeySpec :: Cipher -> CipherKeySpec
- cipherDefaultNonceSize :: Cipher -> Int
- cipherNonceSizeIsValid :: Int -> Cipher -> Bool
- cipherTagSize :: Cipher -> Maybe Int
- cipherUpdateGranularity :: Cipher -> Int
- cipherIdealUpdateGranularity :: Cipher -> Int
- cipherOutputLength :: Cipher -> CipherDirection -> Int -> Int
- cipherEncrypt :: Cipher -> CipherKey -> CipherNonce -> ByteString -> Ciphertext
- cipherDecrypt :: Cipher -> CipherKey -> CipherNonce -> Ciphertext -> Maybe ByteString
- cipherEncryptLazy :: Cipher -> CipherKey -> CipherNonce -> ByteString -> LazyCiphertext
- cipherDecryptLazy :: Cipher -> CipherKey -> CipherNonce -> LazyCiphertext -> Maybe ByteString
- aeadEncrypt :: AEAD -> CipherKey -> CipherNonce -> AEADAssociatedData -> ByteString -> Ciphertext
- aeadDecrypt :: AEAD -> CipherKey -> CipherNonce -> AEADAssociatedData -> Ciphertext -> Maybe ByteString
- data MutableCipher = MkMutableCipher {}
- destroyCipher :: MonadIO m => MutableCipher -> m ()
- data CipherDirection
- data CipherUpdate
- newCipher :: MonadIO m => Cipher -> CipherDirection -> m MutableCipher
- getCipherName :: MonadIO m => MutableCipher -> m ByteString
- getCipherKeySpec :: MonadIO m => MutableCipher -> m CipherKeySpec
- getCipherDefaultNonceSize :: MonadIO m => MutableCipher -> m Int
- getCipherNonceSizeIsValid :: MonadIO m => MutableCipher -> Int -> m Bool
- getCipherTagSize :: MonadIO m => MutableCipher -> m Int
- getCipherUpdateGranularity :: MonadIO m => MutableCipher -> m Int
- getCipherIdealUpdateGranularity :: MonadIO m => MutableCipher -> m Int
- getCipherEstimateOutputLength :: MonadIO m => MutableCipher -> Int -> m Int
- getCipherOutputLength :: MonadIO m => MutableCipher -> Int -> m Int
- setCipherKey :: MonadIO m => MutableCipher -> CipherKey -> m ()
- setAEADAssociatedData :: MonadIO m => MutableCipher -> ByteString -> m ()
- clearCipher :: MonadIO m => MutableCipher -> m ()
- resetCipher :: MonadIO m => MutableCipher -> m ()
- startCipher :: MonadIO m => MutableCipher -> CipherNonce -> m ()
- updateCipher :: MonadIO m => MutableCipher -> ByteString -> m (Int, ByteString)
- finalizeCipher :: MonadIO m => MutableCipher -> ByteString -> m ByteString
- finalizeResetCipher :: MonadIO m => MutableCipher -> ByteString -> m ByteString
- finalizeClearCipher :: MonadIO m => MutableCipher -> ByteString -> m ByteString
- cbc :: BlockCipher -> Cipher
- cbcWith :: BlockCipher -> CBCPadding -> Cipher
- cfb :: BlockCipher -> Cipher
- cfbWith :: BlockCipher -> Int -> Cipher
- xts :: BlockCipher -> Cipher
- chaCha20Poly1305 :: Cipher
- gcm :: BlockCipher128 -> Cipher
- gcmWith :: BlockCipher128 -> Int -> Cipher
- ocb :: BlockCipher128 -> Cipher
- ocbWith :: BlockCipher128 -> Int -> Cipher
- eax :: BlockCipher -> Cipher
- eaxWith :: BlockCipher -> Int -> Cipher
- siv :: BlockCipher128 -> Cipher
- ccm :: BlockCipher128 -> Cipher
- ccmWith :: BlockCipher128 -> Int -> Int -> Cipher
Thing
Usage
Idiomatic interface
Cipher data type
CBC BlockCipher CBCPadding | |
CFB BlockCipher Int | |
XTS BlockCipher | |
ChaCha20Poly1305 | |
GCM BlockCipher128 Int | |
OCB BlockCipher128 Int | |
EAX BlockCipher Int | |
SIV BlockCipher128 | |
CCM BlockCipher128 Int Int |
AEAD data type
unsafeAEAD :: Cipher -> AEAD Source #
Enumerations
cbcPaddings :: [CBCPadding] Source #
Associated types
type CipherNonce = ByteString Source #
data CBCPadding Source #
Instances
Show CBCPadding Source # | |
Defined in Botan.Cipher showsPrec :: Int -> CBCPadding -> ShowS # show :: CBCPadding -> String # showList :: [CBCPadding] -> ShowS # | |
Eq CBCPadding Source # | |
Defined in Botan.Cipher (==) :: CBCPadding -> CBCPadding -> Bool # (/=) :: CBCPadding -> CBCPadding -> Bool # | |
Ord CBCPadding Source # | |
Defined in Botan.Cipher compare :: CBCPadding -> CBCPadding -> Ordering # (<) :: CBCPadding -> CBCPadding -> Bool # (<=) :: CBCPadding -> CBCPadding -> Bool # (>) :: CBCPadding -> CBCPadding -> Bool # (>=) :: CBCPadding -> CBCPadding -> Bool # max :: CBCPadding -> CBCPadding -> CBCPadding # min :: CBCPadding -> CBCPadding -> CBCPadding # |
type AEADAssociatedData = ByteString Source #
Accessors
cipherName :: Cipher -> CipherName Source #
cipherKeySpec :: Cipher -> CipherKeySpec Source #
cipherDefaultNonceSize :: Cipher -> Int Source #
cipherUpdateGranularity :: Cipher -> Int Source #
cipherOutputLength :: Cipher -> CipherDirection -> Int -> Int Source #
Idiomatic algorithm
cipherEncrypt :: Cipher -> CipherKey -> CipherNonce -> ByteString -> Ciphertext Source #
cipherDecrypt :: Cipher -> CipherKey -> CipherNonce -> Ciphertext -> Maybe ByteString Source #
cipherEncryptLazy :: Cipher -> CipherKey -> CipherNonce -> ByteString -> LazyCiphertext Source #
cipherDecryptLazy :: Cipher -> CipherKey -> CipherNonce -> LazyCiphertext -> Maybe ByteString Source #
aeadEncrypt :: AEAD -> CipherKey -> CipherNonce -> AEADAssociatedData -> ByteString -> Ciphertext Source #
aeadDecrypt :: AEAD -> CipherKey -> CipherNonce -> AEADAssociatedData -> Ciphertext -> Maybe ByteString Source #
Mutable interface
Tagged mutable context
data MutableCipher Source #
Destructor
destroyCipher :: MonadIO m => MutableCipher -> m () Source #
Associated types
data CipherDirection Source #
Instances
Show CipherDirection Source # | |
Defined in Botan.Cipher showsPrec :: Int -> CipherDirection -> ShowS # show :: CipherDirection -> String # showList :: [CipherDirection] -> ShowS # | |
Eq CipherDirection Source # | |
Defined in Botan.Cipher (==) :: CipherDirection -> CipherDirection -> Bool # (/=) :: CipherDirection -> CipherDirection -> Bool # | |
Ord CipherDirection Source # | |
Defined in Botan.Cipher compare :: CipherDirection -> CipherDirection -> Ordering # (<) :: CipherDirection -> CipherDirection -> Bool # (<=) :: CipherDirection -> CipherDirection -> Bool # (>) :: CipherDirection -> CipherDirection -> Bool # (>=) :: CipherDirection -> CipherDirection -> Bool # max :: CipherDirection -> CipherDirection -> CipherDirection # min :: CipherDirection -> CipherDirection -> CipherDirection # |
data CipherUpdate Source #
Instances
Show CipherUpdate Source # | |
Defined in Botan.Cipher showsPrec :: Int -> CipherUpdate -> ShowS # show :: CipherUpdate -> String # showList :: [CipherUpdate] -> ShowS # | |
Eq CipherUpdate Source # | |
Defined in Botan.Cipher (==) :: CipherUpdate -> CipherUpdate -> Bool # (/=) :: CipherUpdate -> CipherUpdate -> Bool # | |
Ord CipherUpdate Source # | |
Defined in Botan.Cipher compare :: CipherUpdate -> CipherUpdate -> Ordering # (<) :: CipherUpdate -> CipherUpdate -> Bool # (<=) :: CipherUpdate -> CipherUpdate -> Bool # (>) :: CipherUpdate -> CipherUpdate -> Bool # (>=) :: CipherUpdate -> CipherUpdate -> Bool # max :: CipherUpdate -> CipherUpdate -> CipherUpdate # min :: CipherUpdate -> CipherUpdate -> CipherUpdate # |
Initializers
newCipher :: MonadIO m => Cipher -> CipherDirection -> m MutableCipher Source #
Accessors
getCipherName :: MonadIO m => MutableCipher -> m ByteString Source #
getCipherKeySpec :: MonadIO m => MutableCipher -> m CipherKeySpec Source #
getCipherDefaultNonceSize :: MonadIO m => MutableCipher -> m Int Source #
getCipherNonceSizeIsValid :: MonadIO m => MutableCipher -> Int -> m Bool Source #
getCipherTagSize :: MonadIO m => MutableCipher -> m Int Source #
getCipherUpdateGranularity :: MonadIO m => MutableCipher -> m Int Source #
getCipherIdealUpdateGranularity :: MonadIO m => MutableCipher -> m Int Source #
getCipherEstimateOutputLength :: MonadIO m => MutableCipher -> Int -> m Int Source #
getCipherOutputLength :: MonadIO m => MutableCipher -> Int -> m Int Source #
Warning: Needs to be confirmed accurate, use getCipherEstimateOutputLength
setCipherKey :: MonadIO m => MutableCipher -> CipherKey -> m () Source #
setAEADAssociatedData :: MonadIO m => MutableCipher -> ByteString -> m () Source #
Accessory functions
clearCipher :: MonadIO m => MutableCipher -> m () Source #
resetCipher :: MonadIO m => MutableCipher -> m () Source #
Mutable algorithm
startCipher :: MonadIO m => MutableCipher -> CipherNonce -> m () Source #
updateCipher :: MonadIO m => MutableCipher -> ByteString -> m (Int, ByteString) Source #
finalizeCipher :: MonadIO m => MutableCipher -> ByteString -> m ByteString Source #
finalizeResetCipher :: MonadIO m => MutableCipher -> ByteString -> m ByteString Source #
finalizeClearCipher :: MonadIO m => MutableCipher -> ByteString -> m ByteString Source #
Algorithm references
cbc :: BlockCipher -> Cipher Source #
cbcWith :: BlockCipher -> CBCPadding -> Cipher Source #
cfb :: BlockCipher -> Cipher Source #
xts :: BlockCipher -> Cipher Source #
gcm :: BlockCipher128 -> Cipher Source #
ocb :: BlockCipher128 -> Cipher Source #
eax :: BlockCipher -> Cipher Source #
siv :: BlockCipher128 -> Cipher Source #
ccm :: BlockCipher128 -> Cipher Source #