botan-bindings-0.0.1.0: Raw Botan bindings
Copyright(c) Leo D 2023
LicenseBSD-3-Clause
Maintainerleo@apotheca.io
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Botan.Bindings.Hash

Description

Hash functions are one-way functions, which map data of arbitrary size to a fixed output length. Most of the hash functions in Botan are designed to be cryptographically secure, which means that it is computationally infeasible to create a collision (finding two inputs with the same hash) or preimages (given a hash output, generating an arbitrary input with the same hash). But note that not all such hash functions meet their goals, in particular MD4 and MD5 are trivially broken. However they are still included due to their wide adoption in various protocols.

Using a hash function is typically split into three stages: initialization, update, and finalization (often referred to as a IUF interface). The initialization stage is implicit: after creating a hash function object, it is ready to process data. Then update is called one or more times. Calling update several times is equivalent to calling it once with all of the arguments concatenated. After completing a hash computation (eg using hashFinal), the internal state is reset to begin hashing a new message.

Synopsis

Documentation

data BotanHashStruct Source #

Opaque Hash struct

botan_hash_destroy :: FinalizerPtr BotanHashStruct Source #

Frees all resources of the hash object

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

botan_hash_init Source #

Arguments

:: Ptr BotanHash

hash: hash object

-> ConstPtr CChar

hash_name: name of the hash function, e.g., "SHA-384"

-> Word32

flags: should be 0 in current API revision, all other uses are reserved and return BOTAN_FFI_ERROR_BAD_FLAG

-> IO CInt 

Initialize a hash function object

botan_hash_name Source #

Arguments

:: BotanHash

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

botan_hash_copy_state Source #

Arguments

:: Ptr BotanHash

dest: destination hash object

-> BotanHash

source: source hash object

-> IO CInt

0 on success, a negative value on failure

Copy the state of a hash function object

botan_hash_output_length Source #

Arguments

:: BotanHash

hash: hash object

-> Ptr CSize

output_length: output buffer to hold the hash function output length

-> IO CInt

0 on success, a negative value on failure

Writes the output length of the hash function to *output_length

botan_hash_block_size Source #

Arguments

:: BotanHash

hash: hash object

-> Ptr CSize

block_size: output buffer to hold the hash function block size

-> IO CInt

0 on success, a negative value on failure

Writes the block size of the hash function to *block_size

botan_hash_update Source #

Arguments

:: BotanHash

hash: hash object

-> ConstPtr Word8

in: input buffer

-> CSize

in_len: number of bytes to read from the input buffer

-> IO CInt

0 on success, a negative value on failure

Send more input to the hash function

botan_hash_final Source #

Arguments

:: BotanHash

hash: hash object

-> Ptr Word8

out[]: output buffer

-> IO CInt

0 on success, a negative value on failure

Finalizes the hash computation and writes the output to out[0:botan_hash_output_length()] then reinitializes for computing another digest as if botan_hash_clear had been called.

botan_hash_clear Source #

Arguments

:: BotanHash

hash: hash object

-> IO CInt 

Reinitializes the state of the hash computation. A hash can be computed (with update/final) immediately.

botan_pkcs_hash_id Source #

Arguments

:: ConstPtr CChar

hash_name

-> Ptr Word8

pkcs_id[]

-> Ptr CSize

pkcs_id_len

-> IO CInt