botan-bindings
Copyright(c) 2023-2024 Apotheca Labs
(c) 2024-2025 Haskell Foundation
LicenseBSD-3-Clause
Maintainerjoris@well-typed.com, leo@apotheca.io
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageGHC2021

Botan.Bindings.Cipher

Description

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

Documentation

data BotanCipherStruct Source #

Opaque Cipher struct

newtype BotanCipher Source #

Botan Cipher object

Constructors

MkBotanCipher 

Fields

Instances

Instances details
Storable BotanCipher Source # 
Instance details

Defined in Botan.Bindings.Cipher

Methods

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 # 
Instance details

Defined in Botan.Bindings.Cipher

Methods

(==) :: BotanCipher -> BotanCipher -> Bool

(/=) :: BotanCipher -> BotanCipher -> Bool

Ord BotanCipher Source # 
Instance details

Defined in Botan.Bindings.Cipher

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 #

botan_cipher_init Source #

Arguments

:: Ptr BotanCipher

cipher

-> ConstPtr CChar

name

-> Word32

flags

-> IO CInt 

Initialize a cipher object

botan_cipher_name Source #

Arguments

:: BotanCipher

cipher

-> Ptr CChar

name

-> Ptr CSize

name_len

-> IO CInt 

Return the name of the cipher object

botan_cipher_output_length Source #

Arguments

:: BotanCipher

cipher

-> CSize

in_len

-> Ptr CSize

out_len

-> IO CInt 

Return the output length of this cipher, for a particular input length.

botan_cipher_valid_nonce_length Source #

Arguments

:: 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 #

Arguments

:: 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 #

Arguments

:: BotanCipher

cipher

-> Ptr CSize

nl

-> IO CInt 

Get the default nonce length of this cipher

botan_cipher_get_update_granularity Source #

Arguments

:: 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 #

Arguments

:: BotanCipher

cipher

-> Ptr CSize

ug

-> IO CInt 

botan_cipher_query_keylen Source #

Arguments

:: BotanCipher

cipher

-> Ptr CSize

out_minimum_keylength

-> Ptr CSize

out_maximum_keylength

-> IO CInt 

Get information about the key lengths. Prefer botan_cipher_get_keyspec

botan_cipher_get_keyspec Source #

Arguments

:: BotanCipher

cipher

-> Ptr CSize

min_keylen

-> Ptr CSize

max_keylen

-> Ptr CSize

mod_keylen

-> IO CInt 

Get information about the supported key lengths.

botan_cipher_set_key Source #

Arguments

:: BotanCipher

cipher

-> ConstPtr Word8

key

-> CSize

key_len

-> IO CInt 

Set the key for this cipher object

botan_cipher_reset Source #

Arguments

:: BotanCipher

cipher

-> IO CInt 

botan_cipher_set_associated_data Source #

Arguments

:: BotanCipher

cipher

-> ConstPtr Word8

ad

-> CSize

ad_len

-> IO CInt 

Set the associated data. Will fail if cipher is not an AEAD

botan_cipher_start Source #

Arguments

:: BotanCipher

cipher

-> ConstPtr Word8

nonce

-> CSize

nonce_len

-> IO CInt 

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 #

botan_cipher_update Source #

Arguments

:: 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

botan_cipher_clear Source #

Arguments

:: BotanCipher

hash

-> IO CInt 

Reset the key, nonce, AD and all other state on this cipher object