BearSSL
Data Fields
br_block_ctrcbc_class Struct Reference

Class type for combined CTR and CBC-MAC 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_ctrcbc_class **ctx, const void *key, size_t key_len)
 Initialisation function. More...
 
void(* encrypt )(const br_block_ctrcbc_class *const *ctx, void *ctr, void *cbcmac, void *data, size_t len)
 Run the CTR encryption + CBC-MAC. More...
 
void(* decrypt )(const br_block_ctrcbc_class *const *ctx, void *ctr, void *cbcmac, void *data, size_t len)
 Run the CTR decryption + CBC-MAC. More...
 
void(* ctr )(const br_block_ctrcbc_class *const *ctx, void *ctr, void *data, size_t len)
 Run the CTR encryption/decryption only. More...
 
void(* mac )(const br_block_ctrcbc_class *const *ctx, void *cbcmac, const void *data, size_t len)
 Run the CBC-MAC only. More...
 

Detailed Description

Class type for combined CTR and CBC-MAC implementations.

A br_block_ctrcbc_class instance points to the functions implementing a specific block cipher, when used in CTR mode for encrypting or decrypting data, along with CBC-MAC.

Field Documentation

◆ block_size

unsigned br_block_ctrcbc_class::block_size

Size of individual blocks (in bytes).

◆ context_size

size_t br_block_ctrcbc_class::context_size

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

◆ ctr

void(* br_block_ctrcbc_class::ctr) (const br_block_ctrcbc_class *const *ctx, void *ctr, void *data, size_t len)

Run the CTR encryption/decryption only.

The ctr parameter points to the counter; its length shall be equal to the block size. It is updated by this function as decryption proceeds.

The data to decrypt is updated "in place". Its length (len bytes) MUST be a multiple of the block size.

Parameters
ctxcontext structure (already initialised).
ctrcounter for CTR encryption (initial and final).
datadata to decrypt.
lendata length (in bytes).

◆ decrypt

void(* br_block_ctrcbc_class::decrypt) (const br_block_ctrcbc_class *const *ctx, void *ctr, void *cbcmac, void *data, size_t len)

Run the CTR decryption + CBC-MAC.

The ctr parameter points to the counter; its length shall be equal to the block size. It is updated by this function as decryption proceeds.

The cbcmac parameter points to the IV for CBC-MAC. The MAC is computed over the encrypted data (i.e. before CTR decryption). Its length shall be equal to the block size. The computed CBC-MAC value is written over the cbcmac array.

The data to decrypt is updated "in place". Its length (len bytes) MUST be a multiple of the block size.

Parameters
ctxcontext structure (already initialised).
ctrcounter for CTR encryption (initial and final).
cbcmacIV and output buffer for CBC-MAC.
datadata to decrypt.
lendata length (in bytes).

◆ encrypt

void(* br_block_ctrcbc_class::encrypt) (const br_block_ctrcbc_class *const *ctx, void *ctr, void *cbcmac, void *data, size_t len)

Run the CTR encryption + CBC-MAC.

The ctr parameter points to the counter; its length shall be equal to the block size. It is updated by this function as encryption proceeds.

The cbcmac parameter points to the IV for CBC-MAC. The MAC is computed over the encrypted data (output of CTR encryption). Its length shall be equal to the block size. The computed CBC-MAC value is written over the cbcmac array.

The data to encrypt is updated "in place". Its length (len bytes) MUST be a multiple of the block size.

Parameters
ctxcontext structure (already initialised).
ctrcounter for CTR encryption (initial and final).
cbcmacIV and output buffer for CBC-MAC.
datadata to encrypt.
lendata length (in bytes).

◆ init

void(* br_block_ctrcbc_class::init) (const br_block_ctrcbc_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_ctrcbc_class::log_block_size

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

◆ mac

void(* br_block_ctrcbc_class::mac) (const br_block_ctrcbc_class *const *ctx, void *cbcmac, const void *data, size_t len)

Run the CBC-MAC only.

The cbcmac parameter points to the IV for CBC-MAC. The MAC is computed over the encrypted data (i.e. before CTR decryption). Its length shall be equal to the block size. The computed CBC-MAC value is written over the cbcmac array.

The data is unmodified. Its length (len bytes) MUST be a multiple of the block size.

Parameters
ctxcontext structure (already initialised).
cbcmacIV and output buffer for CBC-MAC.
datadata to decrypt.
lendata length (in bytes).

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