Ordo
0.3.4
Symmetric Cryptography Library
|
Primitive. More...
#include "ordo/primitives/block_modes.h"
Go to the source code of this file.
Functions | |
ORDO_PUBLIC int | ctr_init (struct CTR_STATE *state, struct BLOCK_STATE *cipher_state, const void *iv, size_t iv_len, int dir, const void *params) |
ORDO_PUBLIC void | ctr_update (struct CTR_STATE *state, struct BLOCK_STATE *cipher_state, const void *in, size_t in_len, void *out, size_t *out_len) |
ORDO_PUBLIC int | ctr_final (struct CTR_STATE *state, struct BLOCK_STATE *cipher_state, void *out, size_t *out_len) |
ORDO_PUBLIC size_t | ctr_query (prim_t cipher, int query, size_t value) |
ORDO_PUBLIC size_t | ctr_bsize (void) |
Primitive.
The CTR mode generates a keystream by repeatedly encrypting a counter starting from some initialization vector, effectively turning a block cipher into a stream cipher. As such, CTR mode requires no padding, and outlen will always be equal to inlen.
Note that the CTR keystream is independent of the plaintext, and is also spatially coherent (using a given initialization vector on a len-byte message will "use up" len bytes of the keystream) so care must be taken to avoid reusing the initialization vector in an insecure way. This also means the block cipher's inverse permutation is never used.
ctr_final()
accepts 0 as an argument for out_len
since by design the CTR mode of operation does not produce any final data. However, if a valid pointer is passed, its value will be set to zero as expected.
ORDO_PUBLIC int ctr_init | ( | struct CTR_STATE * | state, |
struct BLOCK_STATE * | cipher_state, | ||
const void * | iv, | ||
size_t | iv_len, | ||
int | dir, | ||
const void * | params | ||
) |
block_mode_init()
ORDO_PUBLIC void ctr_update | ( | struct CTR_STATE * | state, |
struct BLOCK_STATE * | cipher_state, | ||
const void * | in, | ||
size_t | in_len, | ||
void * | out, | ||
size_t * | out_len | ||
) |
block_mode_update()
ORDO_PUBLIC int ctr_final | ( | struct CTR_STATE * | state, |
struct BLOCK_STATE * | cipher_state, | ||
void * | out, | ||
size_t * | out_len | ||
) |
block_mode_final()
ORDO_PUBLIC size_t ctr_query | ( | prim_t | cipher, |
int | query, | ||
size_t | value | ||
) |
block_mode_query()
ORDO_PUBLIC size_t ctr_bsize | ( | void | ) |
Gets the size in bytes of a CTR_STATE
.