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 HaskellSafe-Inferred
LanguageGHC2021

Botan.Bindings.BlockCipher

Description

This module is based on the Block Ciphers section of the C Botan FFI documentation, and on the Block Ciphers section of the C++ API reference.

Synopsis

Documentation

data BotanBlockCipherStruct Source #

Opaque BlockCipher struct

botan_block_cipher_destroy :: FinalizerPtr BotanBlockCipherStruct Source #

Destroy a block cipher object

NOTE: this a binding to the address of the botan_block_cipher_destroy C function.

botan_block_cipher_init Source #

Arguments

:: Ptr BotanBlockCipher

bc

-> ConstPtr CChar

cipher_name

-> IO CInt 

Initialize a block cipher object

botan_block_cipher_clear Source #

Arguments

:: BotanBlockCipher

bc

-> IO CInt

0 on success, a negative value on failure

Reinitializes the block cipher

botan_block_cipher_set_key Source #

Arguments

:: BotanBlockCipher

bc

-> ConstPtr Word8

key[]

-> CSize

len

-> IO CInt 

Set the key for a block cipher instance

botan_block_cipher_block_size Source #

Arguments

:: BotanBlockCipher

bc

-> IO CInt 

Return the positive block size of this block cipher, or negative to indicate an error

botan_block_cipher_encrypt_blocks Source #

Arguments

:: BotanBlockCipher

bc

-> ConstPtr Word8

in[]

-> Ptr Word8

out[]

-> CSize

blocks

-> IO CInt 

Encrypt one or more blocks with the cipher

botan_block_cipher_decrypt_blocks Source #

Arguments

:: BotanBlockCipher

bc

-> ConstPtr Word8

in[]

-> Ptr Word8

out[]

-> CSize

blocks

-> IO CInt 

Decrypt one or more blocks with the cipher

botan_block_cipher_name Source #

Arguments

:: BotanBlockCipher

cipher: the object to read

-> Ptr CChar

name: output buffer

-> Ptr CSize

name_len: on input, the length of buffer, on success the number of bytes written

-> IO CInt 

Get the name of this block cipher

botan_block_cipher_get_keyspec Source #

Arguments

:: BotanBlockCipher

cipher: the object to read

-> Ptr CSize

out_minimum_keylength: if non-NULL, will be set to minimum keylength of cipher

-> Ptr CSize

out_maximum_keylength: if non-NULL, will be set to maximum keylength of cipher

-> Ptr CSize

out_keylength_modulo: if non-NULL will be set to byte multiple of valid keys

-> IO CInt 

Get the key length limits of this block cipher

Available ciphers

A number of algorithms are available to be used as block ciphers. An algorithm is selected by passing the algorithm specification name of the algorithm as a string to the block cipher functions. In some cases an algorithm specification name is just the algorithm name, like "AES-128". In other cases an algorithm specification name is a combination of an algorithm name paired with some parameters, such as "Cascade(Serpent, AES-256)" where Cascade is the algorithm name followed by a 2-tuple of parameters. Pattern synonyms are included for each available algorithm name. Where necessary, such as in the Cascade case, these algorithm names should be manually extended to full algorithm specification names.

WARNING: 64-bit block ciphers should be avoided.

WARNING: the Kuznyechik block ciphier is not included because its security is disputed.

See the Available Ciphers section of the C++ API reference for more information about available ciphers.

pattern BOTAN_BLOCK_CIPHER_AES_128 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_AES_128 @String
"AES-128"

pattern BOTAN_BLOCK_CIPHER_AES_192 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_AES_192 @String
"AES-192"

pattern BOTAN_BLOCK_CIPHER_AES_256 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_AES_256 @String
"AES-256"

pattern BOTAN_BLOCK_CIPHER_ARIA_128 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_ARIA_128 @String
"ARIA-128"

pattern BOTAN_BLOCK_CIPHER_ARIA_192 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_ARIA_192 @String
"ARIA-192"

pattern BOTAN_BLOCK_CIPHER_ARIA_256 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_ARIA_256 @String
"ARIA-256"

pattern BOTAN_BLOCK_CIPHER_BLOWFISH :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_BLOWFISH @String
"Blowfish"

pattern BOTAN_BLOCK_CIPHER_CAMELLIA_128 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_CAMELLIA_128 @String
"Camellia-128"

pattern BOTAN_BLOCK_CIPHER_CAMELLIA_192 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_CAMELLIA_192 @String
"Camellia-192"

pattern BOTAN_BLOCK_CIPHER_CAMELLIA_256 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_CAMELLIA_256 @String
"Camellia-256"

pattern BOTAN_BLOCK_CIPHER_CASCADE :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_CASCADE @String
"Cascade"

pattern BOTAN_BLOCK_CIPHER_CAST_128 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_CAST_128 @String
"CAST-128"

pattern BOTAN_BLOCK_CIPHER_DES :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_DES @String
"DES"

pattern BOTAN_BLOCK_CIPHER_TRIPLEDES :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_TRIPLEDES @String
"TripleDES"

pattern BOTAN_BLOCK_CIPHER_GOST_28147_89 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_GOST_28147_89 @String
"GOST-28147-89"

pattern BOTAN_BLOCK_CIPHER_IDEA :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_IDEA @String
"IDEA"

pattern BOTAN_BLOCK_CIPHER_LION :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_LION @String
"Lion"

pattern BOTAN_BLOCK_CIPHER_NOEKEON :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_NOEKEON @String
"Noekeon"

pattern BOTAN_BLOCK_CIPHER_SEED :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_SEED @String
"SEED"

pattern BOTAN_BLOCK_CIPHER_SERPENT :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_SERPENT @String
"Serpent"

pattern BOTAN_BLOCK_CIPHER_SHACAL2 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_SHACAL2 @String
"SHACAL2"

pattern BOTAN_BLOCK_CIPHER_SM4 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_SM4 @String
"SM4"

pattern BOTAN_BLOCK_CIPHER_THREEFISH_512 :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_THREEFISH_512 @String
"Threefish-512"

pattern BOTAN_BLOCK_CIPHER_TWOFISH :: (Eq a, IsString a) => a Source #

>>> BOTAN_BLOCK_CIPHER_TWOFISH @String
"Twofish"