Ordo  0.3.4
Symmetric Cryptography Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
cbc.h File Reference

Primitive. More...

#include "ordo/primitives/block_modes.h"
Include dependency graph for cbc.h:

Go to the source code of this file.

Functions

ORDO_PUBLIC int cbc_init (struct CBC_STATE *state, struct BLOCK_STATE *cipher_state, const void *iv, size_t iv_len, int dir, const struct CBC_PARAMS *params)
 
ORDO_PUBLIC void cbc_update (struct CBC_STATE *state, struct BLOCK_STATE *cipher_state, const void *in, size_t in_len, void *out, size_t *out_len)
 
ORDO_PUBLIC int cbc_final (struct CBC_STATE *state, struct BLOCK_STATE *cipher_state, void *out, size_t *out_len)
 
ORDO_PUBLIC size_t cbc_query (prim_t cipher, int query, size_t value)
 
ORDO_PUBLIC size_t cbc_bsize (void)
 

Detailed Description

Primitive.

The CBC mode divides the input message into blocks of the cipher's block size, and encrypts them in a sequential fashion, where each block depends on the previous one (and the first block depends on the initialization vector). If the input message's length is not a multiple of the cipher's block size, a padding mechanism is enabled by default which will pad the message to the correct length (and remove the extra data upon decryption). If padding is explicitly disabled through the mode of operation's parameters, the input's length must be a multiple of the cipher's block size.

If padding is enabled, cbc_final() requires a valid pointer to be passed in the out_len parameter and will always return a full blocksize of data, containing the last few ciphertext bytes containing the padding information.

If padding is disabled, out_len is also required, and will return the number of unprocessed plaintext bytes in the context. If this is any value other than zero, the function will also fail with ORDO_LEFTOVER.

Function Documentation

ORDO_PUBLIC int cbc_init ( struct CBC_STATE *  state,
struct BLOCK_STATE *  cipher_state,
const void *  iv,
size_t  iv_len,
int  dir,
const struct CBC_PARAMS params 
)
ORDO_PUBLIC void cbc_update ( struct CBC_STATE *  state,
struct BLOCK_STATE *  cipher_state,
const void *  in,
size_t  in_len,
void *  out,
size_t *  out_len 
)
ORDO_PUBLIC int cbc_final ( struct CBC_STATE *  state,
struct BLOCK_STATE *  cipher_state,
void *  out,
size_t *  out_len 
)
ORDO_PUBLIC size_t cbc_query ( prim_t  cipher,
int  query,
size_t  value 
)
ORDO_PUBLIC size_t cbc_bsize ( void  )

Gets the size in bytes of a CBC_STATE.

Returns
The size in bytes of the structure.
Remarks
Binary compatibility layer.