BearSSL
Data Fields
br_block_ctr_class Struct Reference

Class type for CTR encryption/decryption implementations. More...

Data Fields

size_t context_size
 Size (in bytes) of the context structure appropriate for containing subkeys. More...
 
unsigned block_size
 Size of individual blocks (in bytes). More...
 
unsigned log_block_size
 Base-2 logarithm of the size of individual blocks, expressed in bytes. More...
 
void(* init )(const br_block_ctr_class **ctx, const void *key, size_t key_len)
 Initialisation function. More...
 
uint32_t(* run )(const br_block_ctr_class *const *ctx, const void *iv, uint32_t cc, void *data, size_t len)
 Run the CTR encryption or decryption. More...
 

Detailed Description

Class type for CTR encryption/decryption implementations.

A br_block_ctr_class instance points to the functions implementing a specific block cipher, when used in CTR mode for encrypting or decrypting data.

Field Documentation

◆ block_size

unsigned br_block_ctr_class::block_size

Size of individual blocks (in bytes).

◆ context_size

size_t br_block_ctr_class::context_size

Size (in bytes) of the context structure appropriate for containing subkeys.

◆ init

void(* br_block_ctr_class::init) (const br_block_ctr_class **ctx, const void *key, size_t key_len)

Initialisation function.

This function sets the vtable field in the context structure. The key length MUST be one of the key lengths supported by the implementation.

Parameters
ctxcontext structure to initialise.
keysecret key.
key_lenkey length (in bytes).

◆ log_block_size

unsigned br_block_ctr_class::log_block_size

Base-2 logarithm of the size of individual blocks, expressed in bytes.

◆ run

uint32_t(* br_block_ctr_class::run) (const br_block_ctr_class *const *ctx, const void *iv, uint32_t cc, void *data, size_t len)

Run the CTR encryption or decryption.

The iv parameter points to the IV for this run; its length is exactly 4 bytes less than the block size (e.g. 12 bytes for AES/CTR). The IV is combined with a 32-bit block counter to produce the block value which is processed with the block cipher.

The data to encrypt or decrypt is updated "in place". Its length (len bytes) is not required to be a multiple of the block size; if the final block is partial, then the corresponding key stream bits are dropped.

The resulting counter value is returned.

Parameters
ctxcontext structure (already initialised).
ivIV for CTR encryption/decryption.
ccinitial value for the block counter.
datadata to encrypt or decrypt.
lendata length (in bytes).
Returns
the new block counter value.

The documentation for this struct was generated from the following file: