Main Page Modules Data Structures File List Data Fields Globals Related Pages

# Block ciphers

## Files

file | aes.c
| AES cipher, code.

file | aes.h
| AES block cipher, header.

file | blockmode.c
| Block cipher operation modes, code.

file | blockmode.h
| Blockcipher operation modes, header.

file | blockpad.c
| Blockcipher padding, code.

file | blockpad.h
| Blockcipher padding, header.

file | blowfish.c
| Blowfish block cipher, code.

file | blowfish.h
| Blowfish block cipher, header.

file | blowfishopt.h
| Blowfish block cipher assembler-optimized routines, header.

## Data Structures

struct | blockCipher
struct | blockCipherContext
struct | blockMode

## Block ciphers

typedef void | blockCipherParam
typedef int(* | blockModeEncrypt )(blockCipherParam *param, int count, uint32 *dst, const uint32 *src)
typedef int(* | blockModeDecrypt )(blockCipherParam *param, int count, uint32 *dst, const uint32 *src)
typedef int(* | blockCipherSetup )(blockCipherParam *param, const uint32 *key, int keybits, cipherOperation cipherOperation)
typedef int(* | blockCipherSetIV )(blockCipherParam *param, const uint32 *data)
typedef int(* | blockCipherEncrypt )(blockCipherParam *param, uint32 *dst, const uint32 *src)
typedef int(* | blockCipherDecrypt )(blockCipherParam *param, uint32 *dst, const uint32 *src)
enum | cipherOperation { ENCRYPT, DECRYPT }
enum | cipherMode { ECB, CBC }
int | blockCipherCount (void)
const blockCipher * | blockCipherGet (int index)
const blockCipher * | blockCipherFind (const char *name)
const blockCipher * | blockCipherDefault (void)
int | blockCipherContextInit (blockCipherContext *ctxt, const blockCipher *ciph)
int | blockCipherContextSetup (blockCipherContext *ctxt, const uint32 *key, int keybits, cipherOperation op)
int | blockCipherContextSetIV (blockCipherContext *ctxt, const uint32 *iv)
int | blockCipherContextFree (blockCipherContext *ctxt)

## Typedef Documentation

typedef int(* blockCipherDecrypt)(blockCipherParam* param, uint32* dst, const uint32* src)

Decrypt one block of data (with bit size chosen by the blockcipher).

Note:
  This is raw decryption, without padding, etc.

Parameters:

  param | blockcipher parameters

Return values:

  dst | plaintext block

Parameters:

  src | ciphertext block

Returns:
  0 on success, -1 on failure

Definition at line 760 of file beecrypt.h.

typedef int(* blockCipherEncrypt)(blockCipherParam* param, uint32* dst, const uint32* src)

Encrypt one block of data (with bit size chosen by the blockcipher).

Note:
  This is raw encryption, without padding, etc.

Parameters:

  param | blockcipher parameters

Return values:

  dst | ciphertext block

Parameters:

  src | plaintext block

Returns:
  0 on success, -1 on failure

Definition at line 748 of file beecrypt.h.

typedef void blockCipherParam

| Definition at line 664 of file beecrypt.h. Referenced by blockCipherContextFree, blockCipherContextInit, blockCipherContextSetIV, blockCipherContextSetup, blockDecrypt, and blockEncrypt.

typedef int(* blockCipherSetIV)(blockCipherParam* param, const uint32* data)

Initialize IV for blockcipher.

Parameters:

  param | blockcipher parameters
  data | iv data

Returns:
  0 on success, -1 on failure

Definition at line 736 of file beecrypt.h.

typedef int(* blockCipherSetup)(blockCipherParam* param, const uint32* key, int keybits, cipherOperation cipherOperation)

Setup the blockcipher parameters with the given secret key for either encryption or decryption.

Note:
  After use, it is recommended to wipe the parameters by calling setup again with another (dummy) key.

Parameters:

  param | blockcipher parameters
  key | secret key
  keybits | no. bits in secret key
  cipherOperation |

Returns:
  0 on success, -1 on failure

Definition at line 727 of file beecrypt.h.

typedef int(* blockModeDecrypt)(blockCipherParam* param, int count, uint32* dst, const uint32* src)

Parameters:

  param | blockcipher parameters
  size | no. of ints

Return values:

  dst | plainttext block

Parameters:

  src | ciphertext block

Returns:
  0 on success, -1 on failure

Definition at line 703 of file beecrypt.h.

typedef int(* blockModeEncrypt)(blockCipherParam* param, int count, uint32* dst, const uint32* src)

Parameters:

  param | blockcipher parameters
  size | no. of ints

Return values:

  dst | ciphertext block

Parameters:

  src | plaintext block

Returns:
  0 on success, -1 on failure

Definition at line 693 of file beecrypt.h.

Referenced by blockDecrypt, and blockEncrypt.

## Enumeration Type Documentation

enum cipherMode

Block cipher modes.

Enumeration values:

  ECB |
  CBC |

Definition at line 679 of file beecrypt.h.

Referenced by blockDecrypt, and blockEncrypt.

enum cipherOperation

Block cipher operations.

Enumeration values:

  ENCRYPT |
  DECRYPT |

Definition at line 669 of file beecrypt.h.

Referenced by aesSetup, blockCipherContextSetup, blowfishSetup, and dhaes_pContextSetup.

## Function Documentation

int blockCipherContextFree | ( | blockCipherContext * | ctxt | ) |

| Destroy a blockCipher instance. Definition at line 839 of file beecrypt.c. Referenced by dhaes_pContextFree.

int blockCipherContextInit | ( | blockCipherContext * | ctxt,
|  | const blockCipher * | ciph
| ) |

| Initialize a blockCipher instance. Definition at line 785 of file beecrypt.c. References BEECRYPTAPI, blockCipherCount, blockCipherFind, and blockCipherGet. Referenced by dhaes_pContextInit.

int blockCipherContextSetIV | ( | blockCipherContext * | ctxt,
|  | const uint32 * | iv
| ) |

| Definition at line 823 of file beecrypt.c.

int blockCipherContextSetup | ( | blockCipherContext * | ctxt,
|  | const uint32 * | key,
|  | int | keybits,
|  | cipherOperation | op
| ) |

| Definition at line 806 of file beecrypt.c. Referenced by dhaes_pContextSetup.

int blockCipherCount | ( | void |  | ) |

Return the number of blockciphers available.

Returns:
  number of blockciphers available

Definition at line 739 of file beecrypt.c.

const blockCipher* blockCipherDefault | ( | void |  | ) |

Retrieve the default blockcipher. If the BEECRYPT_CIPHER environment variable is set, use that blockcipher. Otherwise, use "blowfish".

Returns:
  blockcipher pointer

Definition at line 744 of file beecrypt.c.

const blockCipher* blockCipherFind | ( | const char * | name | ) |

Retrieve a blockcipher by name.

Parameters:

  name | blockcipher name

Returns:
  blockcipher pointer (or NULL)

Definition at line 769 of file beecrypt.c.

Referenced by blockCipherContextInit, and blockCipherDefault.

const blockCipher* blockCipherGet | ( | int | index | ) |

Retrieve a blockcipher by index.

Parameters:

  index | blockcipher index

Returns:
  blockcipher pointer (or NULL)

Definition at line 756 of file beecrypt.c.

Referenced by blockCipherContextInit.