Software APIs
Functions
drbg.h File Reference

(9b0647a)

DRBG for the OpenTitan cryptography library. More...

#include "datatypes.h"

Go to the source code of this file.

Functions

otcrypto_status_t otcrypto_drbg_instantiate (otcrypto_const_byte_buf_t perso_string)
 Instantiates the DRBG system. More...
 
otcrypto_status_t otcrypto_drbg_reseed (otcrypto_const_byte_buf_t additional_input)
 Reseeds the DRBG with fresh entropy. More...
 
otcrypto_status_t otcrypto_drbg_manual_instantiate (otcrypto_const_byte_buf_t entropy, otcrypto_const_byte_buf_t perso_string)
 Instantiates the DRBG system. More...
 
otcrypto_status_t otcrypto_drbg_manual_reseed (otcrypto_const_byte_buf_t entropy, otcrypto_const_byte_buf_t additional_input)
 Reseeds the DRBG with fresh entropy. More...
 
otcrypto_status_t otcrypto_drbg_generate (otcrypto_const_byte_buf_t additional_input, otcrypto_word32_buf_t drbg_output)
 DRBG function for generating random bits. More...
 
otcrypto_status_t otcrypto_drbg_manual_generate (otcrypto_const_byte_buf_t additional_input, otcrypto_word32_buf_t drbg_output)
 DRBG function for generating random bits. More...
 
otcrypto_status_t otcrypto_drbg_uninstantiate (void)
 Uninstantiates DRBG and clears the context. More...
 

Detailed Description

DRBG for the OpenTitan cryptography library.

Definition in file drbg.h.

Function Documentation

◆ otcrypto_drbg_generate()

otcrypto_status_t otcrypto_drbg_generate ( otcrypto_const_byte_buf_t  additional_input,
otcrypto_word32_buf_t  drbg_output 
)

DRBG function for generating random bits.

This function checks the hardware flags for FIPS compatibility of the generated bits, so it will fail after otcrypto_drbg_manual_instantiate or otcrypto_drbg_manual_reseed.

The caller should allocate space for the drbg_output buffer and set the length of expected output in the len field.

The output is generated in 16-byte blocks; if drbg_output->len is not a multiple of 4, some output from the hardware will be discarded. This detail may be important for known-answer tests.

Parameters
additional_inputPointer to the additional data.
[out]drbg_outputPointer to the generated pseudo random bits.
Returns
Result of the DRBG generate operation.

Definition at line 189 of file drbg.c.

◆ otcrypto_drbg_instantiate()

otcrypto_status_t otcrypto_drbg_instantiate ( otcrypto_const_byte_buf_t  perso_string)

Instantiates the DRBG system.

Initializes the DRBG and the context for DRBG. Gets the required entropy input automatically from the entropy source.

The personalization string may empty, and may be up to 48 bytes long; any longer will result in an error.

Parameters
perso_stringPointer to personalization bitstring.
Returns
Result of the DRBG instantiate operation.

Definition at line 87 of file drbg.c.

◆ otcrypto_drbg_manual_generate()

otcrypto_status_t otcrypto_drbg_manual_generate ( otcrypto_const_byte_buf_t  additional_input,
otcrypto_word32_buf_t  drbg_output 
)

DRBG function for generating random bits.

This function does NOT check the hardware flags for FIPS compatibility of the generated bits, so it may be called after otcrypto_drbg_manual_instantiate or otcrypto_drbg_manual_reseed.

The caller should allocate space for the drbg_output buffer and set the length of expected output in the len field.

The output is generated in 16-byte blocks; if drbg_output->len is not a multiple of 4, some output from the hardware will be discarded. This detail may be important for known-answer tests.

Parameters
additional_inputPointer to the additional data.
[out]drbg_outputPointer to the generated pseudo random bits.
Returns
Result of the DRBG generate operation.

Definition at line 196 of file drbg.c.

◆ otcrypto_drbg_manual_instantiate()

otcrypto_status_t otcrypto_drbg_manual_instantiate ( otcrypto_const_byte_buf_t  entropy,
otcrypto_const_byte_buf_t  perso_string 
)

Instantiates the DRBG system.

Initializes DRBG and the DRBG context. Gets the required entropy input from the user through the entropy parameter. Calling this function breaks FIPS compliance until the DRBG is uninstantiated.

The entropy input must be exactly 384 bits long (48 bytes). The personalization string must not be longer than the entropy input, and may be empty.

Parameters
entropyPointer to the user defined entropy value.
personalization_stringPointer to personalization bitstring.
Returns
Result of the DRBG manual instantiation.

Definition at line 116 of file drbg.c.

◆ otcrypto_drbg_manual_reseed()

otcrypto_status_t otcrypto_drbg_manual_reseed ( otcrypto_const_byte_buf_t  entropy,
otcrypto_const_byte_buf_t  additional_input 
)

Reseeds the DRBG with fresh entropy.

Reseeds the DRBG with entropy input from the user through the entropy parameter and updates the working state parameters. Calling this function breaks FIPS compliance until the DRBG is uninstantiated.

Parameters
entropyPointer to the user defined entropy value.
additional_inputPointer to the additional input for DRBG.
Returns
Result of the manual DRBG reseed operation.

Definition at line 136 of file drbg.c.

◆ otcrypto_drbg_reseed()

otcrypto_status_t otcrypto_drbg_reseed ( otcrypto_const_byte_buf_t  additional_input)

Reseeds the DRBG with fresh entropy.

Reseeds the DRBG with fresh entropy that is automatically fetched from the entropy source and updates the working state parameters.

Parameters
additional_inputPointer to the additional input for DRBG.
Returns
Result of the DRBG reseed operation.

Definition at line 102 of file drbg.c.

◆ otcrypto_drbg_uninstantiate()

otcrypto_status_t otcrypto_drbg_uninstantiate ( void  )

Uninstantiates DRBG and clears the context.

Returns
Result of the DRBG uninstantiate operation.

Definition at line 203 of file drbg.c.