CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
randombytes.h File Reference

API for accessing a shared entropy source in the randombytes compartment. More...

#include <cdefs.h>
#include <stddef.h>
#include <stdint.h>
#include <concepts>

Go to the source code of this file.

Functions

 __cheriot_compartment ("randombytes") int randombytes(uint8_t *output
 Populate output with n bytes of entropy from the system's entropy source.
template<typename T>
requires requires(T &v) { requires std::is_pointer_v<decltype(v.data())>; requires std::is_convertible_v<decltype(v.size()),
size_t>; }
int randombytes (T &output)
 Populate a container-like output with entropy using its .size() and .data() APIs.
template<typename T, size_t N>
requires std::is_arithmetic_v<T>
int randombytes (T(&output)[N])
 Populate an output array of length N with N * sizeof(output[0]) bytes of entropy from the system's entropy source.
template<typename T>
requires std::is_arithmetic_v<T>
int randombytes (T &output)
 Populate output with sizeof(output) bytes of entropy from the system's entropy source.

Variables

size_t n

Detailed Description

API for accessing a shared entropy source in the randombytes compartment.

Definition in file randombytes.h.

Function Documentation

◆ __cheriot_compartment()

__cheriot_compartment ( "randombytes" )

Populate output with n bytes of entropy from the system's entropy source.

This will be cryptographically secure entropy if and only if the system entropy source is cryptographically secure.

Returns 0 on success.

References randombytes().

◆ randombytes() [1/3]

template<typename T>
requires std::is_arithmetic_v<T>
int randombytes ( T & output)

Populate output with sizeof(output) bytes of entropy from the system's entropy source.

This will be cryptographically secure entropy if and only if the system entropy source is cryptographically secure.

Returns 0 on success.

Definition at line 80 of file randombytes.h.

References randombytes().

◆ randombytes() [2/3]

template<typename T>
requires requires(T &v) { requires std::is_pointer_v<decltype(v.data())>; requires std::is_convertible_v<decltype(v.size()),
size_t>; }
int randombytes ( T & output)

Populate a container-like output with entropy using its .size() and .data() APIs.

This will be cryptographically secure entropy if and only if the system entropy source is cryptographically secure.

Returns 0 on success.

Definition at line 47 of file randombytes.h.

References randombytes().

Referenced by __cheriot_compartment(), randombytes(), and randombytes().

◆ randombytes() [3/3]

template<typename T, size_t N>
requires std::is_arithmetic_v<T>
int randombytes ( T(&) output[N])

Populate an output array of length N with N * sizeof(output[0]) bytes of entropy from the system's entropy source.

This will be cryptographically secure entropy if and only if the system entropy source is cryptographically secure.

Returns 0 on success.

Definition at line 64 of file randombytes.h.

References randombytes().

Variable Documentation

◆ n

size_t n

Definition at line 27 of file randombytes.h.