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

Abstraction Layer. More...

#include "ordo/primitives/block_modes/mode_params.h"
#include "ordo/primitives/block_ciphers.h"
Include dependency graph for block_modes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ORDO_PUBLIC int block_mode_init (struct BLOCK_MODE_STATE *state, struct BLOCK_STATE *cipher_state, const void *iv, size_t iv_len, int direction, prim_t primitive, const void *params)
 
ORDO_PUBLIC void block_mode_update (struct BLOCK_MODE_STATE *state, struct BLOCK_STATE *cipher_state, const void *in, size_t in_len, void *out, size_t *out_len)
 
ORDO_PUBLIC int block_mode_final (struct BLOCK_MODE_STATE *state, struct BLOCK_STATE *cipher_state, void *out, size_t *out_len)
 
ORDO_PUBLIC size_t block_mode_query (prim_t mode, prim_t cipher, int query, size_t value)
 
ORDO_PUBLIC size_t block_mode_bsize (void)
 

Detailed Description

Abstraction Layer.

This abstraction layer declares all the block modes of operation in the library, making them available to higher level modules.

Note "block cipher mode of operation" is shortened to "block mode" in code and documentation to minimize noise and redundancy.

Function Documentation

ORDO_PUBLIC int block_mode_init ( struct BLOCK_MODE_STATE *  state,
struct BLOCK_STATE *  cipher_state,
const void *  iv,
size_t  iv_len,
int  direction,
prim_t  primitive,
const void *  params 
)

Initializes a block mode state.

Parameters
[in,out]stateA block mode state.
[in]cipher_stateA block cipher state.
[in]ivThe initialization vector to use.
[in]iv_lenThe length, in bytes, of the IV.
[in]direction1 for encryption, 0 for decryption.
[in]primitiveA block mode primitive.
[in]paramsBlock mode specific parameters.
Returns
ORDO_SUCCESS on success, else an error code.
ORDO_PUBLIC void block_mode_update ( struct BLOCK_MODE_STATE *  state,
struct BLOCK_STATE *  cipher_state,
const void *  in,
size_t  in_len,
void *  out,
size_t *  out_len 
)

Encrypts or decrypts a buffer.

Parameters
[in,out]stateA block mode state.
[in]cipher_stateA block cipher state.
[in]inThe input buffer.
[in]in_lenThe length, in bytes, of the input.
[out]outThe output buffer.
[out]out_lenA pointer to an integer to which to write the number of output bytes that can be returned to the user. Remaining input data has not been ignored and should not be passed again.
Warning
In-place encryption (by letting in be the same buffer as out) is always supported, however the buffers may not overlap.
ORDO_PUBLIC int block_mode_final ( struct BLOCK_MODE_STATE *  state,
struct BLOCK_STATE *  cipher_state,
void *  out,
size_t *  out_len 
)

Finalizes a block mode state.

Parameters
[in,out]stateA block mode state.
[in]cipher_stateA block cipher state.
[out]outThe output buffer.
[out]out_lenA pointer to an integer to which to store the number of bytes written to out.
Returns
ORDO_SUCCESS on success, else an error code.
Remarks
This function will return any input bytes which were not returned by calls to block_mode_update() (in the correct order).
ORDO_PUBLIC size_t block_mode_query ( prim_t  mode,
prim_t  cipher,
int  query,
size_t  value 
)

Queries a block mode for suitable parameters.

Parameters
[in]modeA block mode primitive.
[in]cipherA block cipher primitive.
[in]queryA query code.
[in]valueA suggested value.
Returns
A suitable parameter of type query based on value.
See Also
query.h
ORDO_PUBLIC size_t block_mode_bsize ( void  )

Gets the size in bytes of a BLOCK_MODE_STATE.

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