BearSSL

Data Fields
br_block_ctrcbc_class Struct Reference

Class type for combined CTR and CBC-MAC implementations. More...

`#include <bearssl_block.h>`

## 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

  ctx | context structure (already initialised).
  ctr | counter for CTR encryption (initial and final).
  data | data to decrypt.
  len | data 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

  ctx | context structure (already initialised).
  ctr | counter for CTR encryption (initial and final).
  cbcmac | IV and output buffer for CBC-MAC.
  data | data to decrypt.
  len | data 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

  ctx | context structure (already initialised).
  ctr | counter for CTR encryption (initial and final).
  cbcmac | IV and output buffer for CBC-MAC.
  data | data to encrypt.
  len | data 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

  ctx | context structure to initialise.
  key | secret key.
  key_len | key 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

  ctx | context structure (already initialised).
  cbcmac | IV and output buffer for CBC-MAC.
  data | data to decrypt.
  len | data length (in bytes).

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

- bearssl_block.h