BearSSL: br_block_ctr_class Struct Reference

BearSSL

Loading...
Searching...
No Matches
Data Fields
br_block_ctr_class Struct Reference

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

`#include <bearssl_block.h>`

## Data Fields
size_t | context_size
| Size (in bytes) of the context structure appropriate for containing subkeys.
unsigned | block_size
| Size of individual blocks (in bytes).
unsigned | log_block_size
| Base-2 logarithm of the size of individual blocks, expressed in bytes.
void(* | init )(const br_block_ctr_class **ctx, const void *key, size_t key_len)
| Initialisation function.
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.

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

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

  ctx | context structure (already initialised).
  iv | IV for CTR encryption/decryption.
  cc | initial value for the block counter.
  data | data to encrypt or decrypt.
  len | data length (in bytes).

Returns
  the new block counter value.

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

- bearssl_block.h