Copyright | (c) Leo D 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | leo@apotheca.io |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
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 BotanCipherStruct
- newtype BotanCipher = MkBotanCipher {}
- botan_cipher_destroy :: FinalizerPtr BotanCipherStruct
- pattern BOTAN_CIPHER_MODE_CBC :: (Eq a, IsString a) => a
- pattern BOTAN_CIPHER_MODE_CFB :: (Eq a, IsString a) => a
- pattern BOTAN_CIPHER_MODE_XTS :: (Eq a, IsString a) => a
- pattern BOTAN_CBC_PADDING_PKCS7 :: (Eq a, IsString a) => a
- pattern BOTAN_CBC_PADDING_ONE_AND_ZEROS :: (Eq a, IsString a) => a
- pattern BOTAN_CBC_PADDING_X9_23 :: (Eq a, IsString a) => a
- pattern BOTAN_CBC_PADDING_ESP :: (Eq a, IsString a) => a
- pattern BOTAN_CBC_PADDING_CTS :: (Eq a, IsString a) => a
- pattern BOTAN_CBC_PADDING_NO_PADDING :: (Eq a, IsString a) => a
- pattern BOTAN_AEAD_CHACHA20POLY1305 :: (Eq a, IsString a) => a
- pattern BOTAN_AEAD_MODE_GCM :: (Eq a, IsString a) => a
- pattern BOTAN_AEAD_MODE_OCB :: (Eq a, IsString a) => a
- pattern BOTAN_AEAD_MODE_EAX :: (Eq a, IsString a) => a
- pattern BOTAN_AEAD_MODE_SIV :: (Eq a, IsString a) => a
- pattern BOTAN_AEAD_MODE_CCM :: (Eq a, IsString a) => a
- pattern BOTAN_CIPHER_INIT_FLAG_MASK_DIRECTION :: (Eq a, Num a) => a
- pattern BOTAN_CIPHER_INIT_FLAG_ENCRYPT :: (Eq a, Num a) => a
- pattern BOTAN_CIPHER_INIT_FLAG_DECRYPT :: (Eq a, Num a) => a
- botan_cipher_init :: Ptr BotanCipher -> ConstPtr CChar -> Word32 -> IO CInt
- botan_cipher_name :: BotanCipher -> Ptr CChar -> Ptr CSize -> IO CInt
- botan_cipher_output_length :: BotanCipher -> CSize -> Ptr CSize -> IO CInt
- botan_cipher_valid_nonce_length :: BotanCipher -> CSize -> IO CInt
- botan_cipher_get_tag_length :: BotanCipher -> Ptr CSize -> IO CInt
- botan_cipher_get_default_nonce_length :: BotanCipher -> Ptr CSize -> IO CInt
- botan_cipher_get_update_granularity :: BotanCipher -> Ptr CSize -> IO CInt
- botan_cipher_get_ideal_update_granularity :: BotanCipher -> Ptr CSize -> IO CInt
- botan_cipher_query_keylen :: BotanCipher -> Ptr CSize -> Ptr CSize -> IO CInt
- botan_cipher_get_keyspec :: BotanCipher -> Ptr CSize -> Ptr CSize -> Ptr CSize -> IO CInt
- botan_cipher_set_key :: BotanCipher -> ConstPtr Word8 -> CSize -> IO CInt
- botan_cipher_reset :: BotanCipher -> IO CInt
- botan_cipher_set_associated_data :: BotanCipher -> ConstPtr Word8 -> CSize -> IO CInt
- botan_cipher_start :: BotanCipher -> ConstPtr Word8 -> CSize -> IO CInt
- pattern BOTAN_CIPHER_UPDATE_FLAG_NONE :: (Eq a, Num a) => a
- pattern BOTAN_CIPHER_UPDATE_FLAG_FINAL :: (Eq a, Num a) => a
- botan_cipher_update :: BotanCipher -> Word32 -> Ptr Word8 -> CSize -> Ptr CSize -> ConstPtr Word8 -> CSize -> Ptr CSize -> IO CInt
- botan_cipher_clear :: BotanCipher -> IO CInt
Documentation
data BotanCipherStruct Source #
Opaque Cipher struct
newtype BotanCipher Source #
Botan Cipher object
Instances
Storable BotanCipher Source # | |
Defined in Botan.Bindings.Cipher sizeOf :: BotanCipher -> Int # alignment :: BotanCipher -> Int # peekElemOff :: Ptr BotanCipher -> Int -> IO BotanCipher # pokeElemOff :: Ptr BotanCipher -> Int -> BotanCipher -> IO () # peekByteOff :: Ptr b -> Int -> IO BotanCipher # pokeByteOff :: Ptr b -> Int -> BotanCipher -> IO () # peek :: Ptr BotanCipher -> IO BotanCipher # poke :: Ptr BotanCipher -> BotanCipher -> IO () # | |
Eq BotanCipher Source # | |
Defined in Botan.Bindings.Cipher (==) :: BotanCipher -> BotanCipher -> Bool # (/=) :: BotanCipher -> BotanCipher -> Bool # | |
Ord BotanCipher Source # | |
Defined in Botan.Bindings.Cipher compare :: BotanCipher -> BotanCipher -> Ordering # (<) :: BotanCipher -> BotanCipher -> Bool # (<=) :: BotanCipher -> BotanCipher -> Bool # (>) :: BotanCipher -> BotanCipher -> Bool # (>=) :: BotanCipher -> BotanCipher -> Bool # max :: BotanCipher -> BotanCipher -> BotanCipher # min :: BotanCipher -> BotanCipher -> BotanCipher # |
botan_cipher_destroy :: FinalizerPtr BotanCipherStruct Source #
Destroy the cipher object
pattern BOTAN_CIPHER_MODE_CBC :: (Eq a, IsString a) => a Source #
pattern BOTAN_CIPHER_MODE_CFB :: (Eq a, IsString a) => a Source #
pattern BOTAN_CIPHER_MODE_XTS :: (Eq a, IsString a) => a Source #
pattern BOTAN_CBC_PADDING_PKCS7 :: (Eq a, IsString a) => a Source #
pattern BOTAN_CBC_PADDING_ONE_AND_ZEROS :: (Eq a, IsString a) => a Source #
pattern BOTAN_CBC_PADDING_X9_23 :: (Eq a, IsString a) => a Source #
pattern BOTAN_CBC_PADDING_ESP :: (Eq a, IsString a) => a Source #
pattern BOTAN_CBC_PADDING_CTS :: (Eq a, IsString a) => a Source #
pattern BOTAN_CBC_PADDING_NO_PADDING :: (Eq a, IsString a) => a Source #
pattern BOTAN_AEAD_CHACHA20POLY1305 :: (Eq a, IsString a) => a Source #
pattern BOTAN_AEAD_MODE_GCM :: (Eq a, IsString a) => a Source #
pattern BOTAN_AEAD_MODE_OCB :: (Eq a, IsString a) => a Source #
pattern BOTAN_AEAD_MODE_EAX :: (Eq a, IsString a) => a Source #
pattern BOTAN_AEAD_MODE_SIV :: (Eq a, IsString a) => a Source #
pattern BOTAN_AEAD_MODE_CCM :: (Eq a, IsString a) => a Source #
pattern BOTAN_CIPHER_INIT_FLAG_MASK_DIRECTION :: (Eq a, Num a) => a Source #
pattern BOTAN_CIPHER_INIT_FLAG_ENCRYPT :: (Eq a, Num a) => a Source #
pattern BOTAN_CIPHER_INIT_FLAG_DECRYPT :: (Eq a, Num a) => a Source #
Initialize a cipher object
Return the name of the cipher object
botan_cipher_output_length Source #
Return the output length of this cipher, for a particular input length.
botan_cipher_valid_nonce_length Source #
:: BotanCipher | cipher |
-> CSize | nl |
-> IO CInt |
Return if the specified nonce length is valid for this cipher (0 SUCCESS if valid, 1 INVALID_IDENTIFIER if not)
botan_cipher_get_tag_length Source #
:: BotanCipher | cipher |
-> Ptr CSize | tag_size |
-> IO CInt |
Get the tag length of the cipher (0 for non-AEAD modes)
botan_cipher_get_default_nonce_length Source #
:: BotanCipher | cipher |
-> Ptr CSize | nl |
-> IO CInt |
Get the default nonce length of this cipher
botan_cipher_get_update_granularity Source #
:: BotanCipher | cipher |
-> Ptr CSize | ug |
-> IO CInt |
Return the update granularity of the cipher; botan_cipher_update must be called with blocks of this size, except for the final.
botan_cipher_get_ideal_update_granularity Source #
:: BotanCipher | cipher |
-> Ptr CSize | ug |
-> IO CInt |
botan_cipher_query_keylen Source #
Get information about the key lengths. Prefer botan_cipher_get_keyspec
botan_cipher_get_keyspec Source #
Get information about the supported key lengths.
Set the key for this cipher object
:: BotanCipher | cipher |
-> IO CInt |
botan_cipher_set_associated_data Source #
Set the associated data. Will fail if cipher is not an AEAD
Begin processing a new message using the provided nonce
pattern BOTAN_CIPHER_UPDATE_FLAG_NONE :: (Eq a, Num a) => a Source #
pattern BOTAN_CIPHER_UPDATE_FLAG_FINAL :: (Eq a, Num a) => a Source #
:: BotanCipher | cipher |
-> Word32 | flags |
-> Ptr Word8 | output[] |
-> CSize | output_size |
-> Ptr CSize | output_written |
-> ConstPtr Word8 | input_bytes[] |
-> CSize | input_size |
-> Ptr CSize | input_consumed |
-> IO CInt |
Encrypt some data
:: BotanCipher | hash |
-> IO CInt |
Reset the key, nonce, AD and all other state on this cipher object