BearSSL: br_prng_class Struct Reference

BearSSL

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

Class type for PRNG implementations. More...

`#include <bearssl_rand.h>`

## Data Fields
size_t | context_size
| Size (in bytes) of the context structure appropriate for running this PRNG.
void(* | init )(const br_prng_class **ctx, const void *params, const void *seed, size_t seed_len)
| Initialisation method.
void(* | generate )(const br_prng_class **ctx, void *out, size_t len)
| Random bytes generation.
void(* | update )(const br_prng_class **ctx, const void *seed, size_t seed_len)
| Inject additional seed bytes.

## Detailed Description

Class type for PRNG implementations.

A br_prng_class instance references the methods implementing a PRNG. Constant instances of this structure are defined for each implemented PRNG. Such instances are also called "vtables".

## Field Documentation

## ◆ context_size

size_t br_prng_class::context_size

Size (in bytes) of the context structure appropriate for running this PRNG.

## ◆ generate

void(* br_prng_class::generate) (const br_prng_class **ctx, void *out, size_t len)

Random bytes generation.

This method produces len pseudorandom bytes, in the out buffer. The context is updated accordingly.

Parameters

  ctx | PRNG context.
  out | output buffer.
  len | number of pseudorandom bytes to produce.

## ◆ init

void(* br_prng_class::init) (const br_prng_class **ctx, const void *params, const void *seed, size_t seed_len)

Initialisation method.

The context to initialise is provided as a pointer to its first field (the vtable pointer); this function sets that first field to a pointer to the vtable.

The extra parameters depend on the implementation; each implementation defines what kind of extra parameters it expects (if any).

Requirements on the initial seed depend on the implemented PRNG.

Parameters

  ctx | PRNG context to initialise.
  params | extra parameters for the PRNG.
  seed | initial seed.
  seed_len | initial seed length (in bytes).

## ◆ update

void(* br_prng_class::update) (const br_prng_class **ctx, const void *seed, size_t seed_len)

Inject additional seed bytes.

The provided seed bytes are added into the PRNG internal entropy pool.

Parameters

  ctx | PRNG context.
  seed | additional seed.
  seed_len | additional seed length (in bytes).

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

- bearssl_rand.h