BeeCrypt 4.2.1
beecrypt.h File Reference

BeeCrypt API, headers. More...

#include "beecrypt/api.h"
#include "beecrypt/memchunk.h"
#include "beecrypt/mpnumber.h"
Include dependency graph for beecrypt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  entropySource
 This struct holds information and pointers to code specific to each source of entropy. More...
struct  randomGenerator
 This struct holds information and pointers to code specific to each pseudo-random number generator. More...
struct  randomGeneratorContext
struct  hashFunction
struct  hashFunctionContext
struct  keyedHashFunction
struct  keyedHashFunctionContext
struct  blockCipherRaw
struct  blockCipherMode
struct  blockCipher
 Holds information and pointers to code specific to each cipher. More...
struct  blockCipherContext
 Holds a pointer to a blockcipher as well as its parameters. More...

Typedefs

typedef int(* entropyNext) (byte *, size_t)
 Prototype definition for an entropy-generating function.
typedef void randomGeneratorParam
typedef int(* randomGeneratorSetup) (randomGeneratorParam *)
typedef int(* randomGeneratorSeed) (randomGeneratorParam *, const byte *, size_t)
typedef int(* randomGeneratorNext) (randomGeneratorParam *, byte *, size_t)
typedef int(* randomGeneratorCleanup) (randomGeneratorParam *)
typedef void hashFunctionParam
typedef int(* hashFunctionReset) (hashFunctionParam *)
typedef int(* hashFunctionUpdate) (hashFunctionParam *, const byte *, size_t)
typedef int(* hashFunctionDigest) (hashFunctionParam *, byte *)
typedef void keyedHashFunctionParam
typedef int(* keyedHashFunctionSetup) (keyedHashFunctionParam *, const byte *, size_t)
typedef int(* keyedHashFunctionReset) (keyedHashFunctionParam *)
typedef int(* keyedHashFunctionUpdate) (keyedHashFunctionParam *, const byte *, size_t)
typedef int(* keyedHashFunctionDigest) (keyedHashFunctionParam *, byte *)
typedef void blockCipherParam
 Placeholder type definition for blockcipher parameters.
typedef int(* blockCipherSetup) (blockCipherParam *, const byte *, size_t, cipherOperation)
 Prototype definition for a setup function.
typedef int(* blockCipherSetIV) (blockCipherParam *, const byte *)
 Prototype definition for an initialization vector setup function.
typedef int(* blockCipherSetCTR) (blockCipherParam *, const byte *, size_t)
 Prototype definition for an initialization vector setup function.
typedef int(* blockCipherRawcrypt) (blockCipherParam *, uint32_t *, const uint32_t *)
 Prototype for a raw encryption or decryption function.
typedef int(* blockCipherModcrypt) (blockCipherParam *, uint32_t *, const uint32_t *, unsigned int)
 Prototype for a encryption or decryption function which operates on multiple blocks in a certain mode.
typedef uint32_t *(* blockCipherFeedback) (blockCipherParam *)

Enumerations

enum  cipherOperation { NOCRYPT , ENCRYPT , DECRYPT }
 Specifies whether to perform encryption or decryption. More...

Functions

int entropySourceCount (void)
 This function returns the number of entropy sources implemented by the library.
const entropySourceentropySourceGet (int n)
 This function returns the n -th entropy source implemented by the library.
const entropySourceentropySourceFind (const char *name)
 This function returns the entropy source specified by the given name.
const entropySourceentropySourceDefault (void)
 This functions returns the default entropy source; the default value can be specified by setting environment variable BEECRYPT_ENTROPY.
int entropyGatherNext (byte *, size_t)
 This function gathers size bytes of entropy into data.
int randomGeneratorCount (void)
const randomGeneratorrandomGeneratorGet (int)
const randomGeneratorrandomGeneratorFind (const char *)
const randomGeneratorrandomGeneratorDefault (void)
int randomGeneratorContextInit (randomGeneratorContext *, const randomGenerator *)
int randomGeneratorContextFree (randomGeneratorContext *)
int randomGeneratorContextNext (randomGeneratorContext *, byte *, size_t)
int randomGeneratorContextSeed (randomGeneratorContext *, const byte *, size_t)
int hashFunctionCount (void)
const hashFunctionhashFunctionGet (int)
const hashFunctionhashFunctionFind (const char *)
const hashFunctionhashFunctionDefault (void)
int hashFunctionContextInit (hashFunctionContext *, const hashFunction *)
int hashFunctionContextFree (hashFunctionContext *)
int hashFunctionContextReset (hashFunctionContext *)
int hashFunctionContextUpdate (hashFunctionContext *, const byte *, size_t)
int hashFunctionContextUpdateMC (hashFunctionContext *, const memchunk *)
int hashFunctionContextUpdateMP (hashFunctionContext *, const mpnumber *)
int hashFunctionContextDigest (hashFunctionContext *, byte *)
int hashFunctionContextDigestMP (hashFunctionContext *, mpnumber *)
int hashFunctionContextDigestMatch (hashFunctionContext *, const mpnumber *)
int keyedHashFunctionCount (void)
const keyedHashFunctionkeyedHashFunctionGet (int)
const keyedHashFunctionkeyedHashFunctionFind (const char *)
const keyedHashFunctionkeyedHashFunctionDefault (void)
int keyedHashFunctionContextInit (keyedHashFunctionContext *, const keyedHashFunction *)
int keyedHashFunctionContextFree (keyedHashFunctionContext *)
int keyedHashFunctionContextSetup (keyedHashFunctionContext *, const byte *, size_t)
int keyedHashFunctionContextReset (keyedHashFunctionContext *)
int keyedHashFunctionContextUpdate (keyedHashFunctionContext *, const byte *, size_t)
int keyedHashFunctionContextUpdateMC (keyedHashFunctionContext *, const memchunk *)
int keyedHashFunctionContextUpdateMP (keyedHashFunctionContext *, const mpnumber *)
int keyedHashFunctionContextDigest (keyedHashFunctionContext *, byte *)
int keyedHashFunctionContextDigestMP (keyedHashFunctionContext *, mpnumber *)
int keyedHashFunctionContextDigestMatch (keyedHashFunctionContext *, const mpnumber *)
int blockCipherCount (void)
 This function returns the number of blockciphers implemented by the library.
const blockCipherblockCipherGet (int)
 This function returns the n -th blockcipher implemented by the library.
const blockCipherblockCipherFind (const char *)
 This function returns the blockcipher specified by the given name.
const blockCipherblockCipherDefault (void)
 This functions returns the default blockcipher; the default value can be specified by setting environment variable BEECRYPT_CIPHER.
int blockCipherContextInit (blockCipherContext *, const blockCipher *)
int blockCipherContextSetup (blockCipherContext *, const byte *, size_t, cipherOperation)
int blockCipherContextSetIV (blockCipherContext *, const byte *)
int blockCipherContextSetCTR (blockCipherContext *, const byte *, size_t)
int blockCipherContextFree (blockCipherContext *)
int blockCipherContextECB (blockCipherContext *, uint32_t *, const uint32_t *, int)
int blockCipherContextCBC (blockCipherContext *, uint32_t *, const uint32_t *, int)
int blockCipherContextCTR (blockCipherContext *, uint32_t *, const uint32_t *, int)
int blockCipherContextValidKeylen (blockCipherContext *, size_t)

Detailed Description

BeeCrypt API, headers.

These API functions provide an abstract way for using most of the various algorithms implemented by the library.

Author
Bob Deblier bob.d.nosp@m.ebli.nosp@m.er@te.nosp@m.lene.nosp@m.t.be

Typedef Documentation

◆ blockCipherFeedback

typedef uint32_t *(* blockCipherFeedback) (blockCipherParam *)

◆ blockCipherModcrypt

typedef int(* blockCipherModcrypt) (blockCipherParam *, uint32_t *, const uint32_t *, unsigned int)

Prototype for a encryption or decryption function which operates on multiple blocks in a certain mode.

Parameters
bpThe blockcipher's parameters.
dstThe ciphertext address; must be aligned on 32-bit boundary.
srcThe cleartext address; must be aligned on 32-bit boundary.
nblocksThe number of blocks to process.
Return values
0on success.
-1on failure.

◆ blockCipherParam

typedef void blockCipherParam

Placeholder type definition for blockcipher parameters.

See also
aesParam, blowfishParam.

◆ blockCipherRawcrypt

typedef int(* blockCipherRawcrypt) (blockCipherParam *, uint32_t *, const uint32_t *)

Prototype for a raw encryption or decryption function.

Parameters
bpThe blockcipher's parameters.
dstThe ciphertext address; must be aligned on 32-bit boundary.
srcThe cleartext address; must be aligned on 32-bit boundary.
Return values
0on success.
-1on failure.

◆ blockCipherSetCTR

typedef int(* blockCipherSetCTR) (blockCipherParam *, const byte *, size_t)

Prototype definition for an initialization vector setup function.

Parameters
bpThe blockcipher's parameters.
nivzThe concatenation of the Nonce, IV and padding Zero bytes.
counterThe blockciphers' counter value.
Note
nivz length must be equal to the cipher's block size.
Return values
0on success.
-1on failure.

◆ blockCipherSetIV

typedef int(* blockCipherSetIV) (blockCipherParam *, const byte *)

Prototype definition for an initialization vector setup function.

Parameters
bpThe blockcipher's parameters.
ivThe blockciphers' IV value.
Note
iv length must be equal to the cipher's block size.
Return values
0on success.
-1on failure.

◆ blockCipherSetup

typedef int(* blockCipherSetup) (blockCipherParam *, const byte *, size_t, cipherOperation)

Prototype definition for a setup function.

◆ entropyNext

typedef int(* entropyNext) (byte *, size_t)

Prototype definition for an entropy-generating function.

◆ hashFunctionDigest

typedef int(* hashFunctionDigest) (hashFunctionParam *, byte *)

◆ hashFunctionParam

typedef void hashFunctionParam

typedef void hashFunctionParam

◆ hashFunctionReset

typedef int(* hashFunctionReset) (hashFunctionParam *)

◆ hashFunctionUpdate

typedef int(* hashFunctionUpdate) (hashFunctionParam *, const byte *, size_t)

◆ keyedHashFunctionDigest

typedef int(* keyedHashFunctionDigest) (keyedHashFunctionParam *, byte *)

◆ keyedHashFunctionParam

typedef void keyedHashFunctionParam

◆ keyedHashFunctionReset

typedef int(* keyedHashFunctionReset) (keyedHashFunctionParam *)

◆ keyedHashFunctionSetup

typedef int(* keyedHashFunctionSetup) (keyedHashFunctionParam *, const byte *, size_t)

◆ keyedHashFunctionUpdate

typedef int(* keyedHashFunctionUpdate) (keyedHashFunctionParam *, const byte *, size_t)

◆ randomGeneratorCleanup

typedef int(* randomGeneratorCleanup) (randomGeneratorParam *)

◆ randomGeneratorNext

typedef int(* randomGeneratorNext) (randomGeneratorParam *, byte *, size_t)

◆ randomGeneratorParam

typedef void randomGeneratorParam

◆ randomGeneratorSeed

typedef int(* randomGeneratorSeed) (randomGeneratorParam *, const byte *, size_t)

◆ randomGeneratorSetup

typedef int(* randomGeneratorSetup) (randomGeneratorParam *)

Enumeration Type Documentation

◆ cipherOperation

Specifies whether to perform encryption or decryption.

Enumerator
NOCRYPT 
ENCRYPT 
DECRYPT 

Function Documentation

◆ blockCipherContextCBC()

int blockCipherContextCBC ( blockCipherContext * ,
uint32_t * ,
const uint32_t * ,
int  )

References BEECRYPTAPI.

◆ blockCipherContextCTR()

int blockCipherContextCTR ( blockCipherContext * ,
uint32_t * ,
const uint32_t * ,
int  )

References BEECRYPTAPI.

◆ blockCipherContextECB()

int blockCipherContextECB ( blockCipherContext * ,
uint32_t * ,
const uint32_t * ,
int  )

References BEECRYPTAPI.

◆ blockCipherContextFree()

int blockCipherContextFree ( blockCipherContext * )

References BEECRYPTAPI.

◆ blockCipherContextInit()

int blockCipherContextInit ( blockCipherContext * ,
const blockCipher *  )

References BEECRYPTAPI.

◆ blockCipherContextSetCTR()

int blockCipherContextSetCTR ( blockCipherContext * ,
const byte * ,
size_t  )

References BEECRYPTAPI.

◆ blockCipherContextSetIV()

int blockCipherContextSetIV ( blockCipherContext * ,
const byte *  )

References BEECRYPTAPI.

◆ blockCipherContextSetup()

int blockCipherContextSetup ( blockCipherContext * ,
const byte * ,
size_t ,
cipherOperation  )

References BEECRYPTAPI.

◆ blockCipherContextValidKeylen()

int blockCipherContextValidKeylen ( blockCipherContext * ,
size_t  )

◆ blockCipherCount()

int blockCipherCount ( void )

This function returns the number of blockciphers implemented by the library.

Returns
The number of implemented blockciphers.

References BEECRYPTAPI.

◆ blockCipherDefault()

const blockCipher * blockCipherDefault ( void )

This functions returns the default blockcipher; the default value can be specified by setting environment variable BEECRYPT_CIPHER.

Returns
A pointer to a blockcipher or null, in case an error occured.

◆ blockCipherFind()

const blockCipher * blockCipherFind ( const char * name)

This function returns the blockcipher specified by the given name.

Parameters
nameName of the requested blockcipher.
Returns
A pointer to a blockcipher or null, if the name wasn't found.

References BEECRYPTAPI.

◆ blockCipherGet()

const blockCipher * blockCipherGet ( int n)

This function returns the n -th blockcipher implemented by the library.

Parameters
nIndex of the requested blockcipher; legal values are 0 through blockCipherCount() - 1.
Returns
A pointer to a blockcipher or null, if the index was out of range.

References BEECRYPTAPI.

◆ entropyGatherNext()

int entropyGatherNext ( byte * data,
size_t size )

This function gathers size bytes of entropy into data.

Unless environment variable BEECRYPT_ENTROPY is set, this function will try each successive entropy source to gather up the requested amount.

Parameters
dataPoints to where the entropy should be stored.
sizeIndicates how many bytes of entropy should be gathered.
Return values
0On success.
-1On failure.

◆ entropySourceCount()

int entropySourceCount ( void )

This function returns the number of entropy sources implemented by the library.

Returns
The number of implemented entropy sources.

References BEECRYPTAPI.

◆ entropySourceDefault()

const entropySource * entropySourceDefault ( void )

This functions returns the default entropy source; the default value can be specified by setting environment variable BEECRYPT_ENTROPY.

Returns
A pointer to an entropy source or null, in case an error occured.

References BEECRYPTAPI.

◆ entropySourceFind()

const entropySource * entropySourceFind ( const char * name)

This function returns the entropy source specified by the given name.

Parameters
nameName of the requested entropy source.
Returns
A pointer to an entropy source or null, if the name wasn't found.

References BEECRYPTAPI.

◆ entropySourceGet()

const entropySource * entropySourceGet ( int n)

This function returns the n -th entropy source implemented by the library.

Parameters
nIndex of the requested entropy source; legal values are 0 through entropySourceCount() - 1.
Returns
A pointer to an entropy source or null, if the index was out of range.

References BEECRYPTAPI.

◆ hashFunctionContextDigest()

int hashFunctionContextDigest ( hashFunctionContext * ,
byte *  )

References BEECRYPTAPI.

◆ hashFunctionContextDigestMatch()

int hashFunctionContextDigestMatch ( hashFunctionContext * ,
const mpnumber *  )

◆ hashFunctionContextDigestMP()

int hashFunctionContextDigestMP ( hashFunctionContext * ,
mpnumber *  )

References BEECRYPTAPI.

◆ hashFunctionContextFree()

int hashFunctionContextFree ( hashFunctionContext * )

References BEECRYPTAPI.

◆ hashFunctionContextInit()

int hashFunctionContextInit ( hashFunctionContext * ,
const hashFunction *  )

References BEECRYPTAPI.

◆ hashFunctionContextReset()

int hashFunctionContextReset ( hashFunctionContext * )

References BEECRYPTAPI.

◆ hashFunctionContextUpdate()

int hashFunctionContextUpdate ( hashFunctionContext * ,
const byte * ,
size_t  )

References BEECRYPTAPI.

◆ hashFunctionContextUpdateMC()

int hashFunctionContextUpdateMC ( hashFunctionContext * ,
const memchunk *  )

References BEECRYPTAPI.

◆ hashFunctionContextUpdateMP()

int hashFunctionContextUpdateMP ( hashFunctionContext * ,
const mpnumber *  )

References BEECRYPTAPI.

◆ hashFunctionCount()

int hashFunctionCount ( void )

References BEECRYPTAPI.

◆ hashFunctionDefault()

const hashFunction * hashFunctionDefault ( void )

◆ hashFunctionFind()

const hashFunction * hashFunctionFind ( const char * )

References BEECRYPTAPI.

◆ hashFunctionGet()

const hashFunction * hashFunctionGet ( int )

References BEECRYPTAPI.

◆ keyedHashFunctionContextDigest()

int keyedHashFunctionContextDigest ( keyedHashFunctionContext * ,
byte *  )

References BEECRYPTAPI.

◆ keyedHashFunctionContextDigestMatch()

int keyedHashFunctionContextDigestMatch ( keyedHashFunctionContext * ,
const mpnumber *  )

◆ keyedHashFunctionContextDigestMP()

int keyedHashFunctionContextDigestMP ( keyedHashFunctionContext * ,
mpnumber *  )

References BEECRYPTAPI.

◆ keyedHashFunctionContextFree()

int keyedHashFunctionContextFree ( keyedHashFunctionContext * )

References BEECRYPTAPI.

◆ keyedHashFunctionContextInit()

int keyedHashFunctionContextInit ( keyedHashFunctionContext * ,
const keyedHashFunction *  )

References BEECRYPTAPI.

◆ keyedHashFunctionContextReset()

int keyedHashFunctionContextReset ( keyedHashFunctionContext * )

References BEECRYPTAPI.

◆ keyedHashFunctionContextSetup()

int keyedHashFunctionContextSetup ( keyedHashFunctionContext * ,
const byte * ,
size_t  )

References BEECRYPTAPI.

◆ keyedHashFunctionContextUpdate()

int keyedHashFunctionContextUpdate ( keyedHashFunctionContext * ,
const byte * ,
size_t  )

References BEECRYPTAPI.

◆ keyedHashFunctionContextUpdateMC()

int keyedHashFunctionContextUpdateMC ( keyedHashFunctionContext * ,
const memchunk *  )

References BEECRYPTAPI.

◆ keyedHashFunctionContextUpdateMP()

int keyedHashFunctionContextUpdateMP ( keyedHashFunctionContext * ,
const mpnumber *  )

References BEECRYPTAPI.

◆ keyedHashFunctionCount()

int keyedHashFunctionCount ( void )

References BEECRYPTAPI.

◆ keyedHashFunctionDefault()

const keyedHashFunction * keyedHashFunctionDefault ( void )

◆ keyedHashFunctionFind()

const keyedHashFunction * keyedHashFunctionFind ( const char * )

References BEECRYPTAPI.

◆ keyedHashFunctionGet()

const keyedHashFunction * keyedHashFunctionGet ( int )

References BEECRYPTAPI.

◆ randomGeneratorContextFree()

int randomGeneratorContextFree ( randomGeneratorContext * )

References BEECRYPTAPI.

◆ randomGeneratorContextInit()

int randomGeneratorContextInit ( randomGeneratorContext * ,
const randomGenerator *  )

References BEECRYPTAPI.

◆ randomGeneratorContextNext()

int randomGeneratorContextNext ( randomGeneratorContext * ,
byte * ,
size_t  )

References BEECRYPTAPI.

◆ randomGeneratorContextSeed()

int randomGeneratorContextSeed ( randomGeneratorContext * ,
const byte * ,
size_t  )

◆ randomGeneratorCount()

int randomGeneratorCount ( void )

References BEECRYPTAPI.

◆ randomGeneratorDefault()

const randomGenerator * randomGeneratorDefault ( void )

◆ randomGeneratorFind()

const randomGenerator * randomGeneratorFind ( const char * )

References BEECRYPTAPI.

◆ randomGeneratorGet()

const randomGenerator * randomGeneratorGet ( int )

References BEECRYPTAPI.