Struct desfire::random_oracle

Struct Documentation

struct random_oracle

Super light wrapper around a function pointer that fills a buffer of random bytes. This is a wrapper and not directly a function pointer to that the construction of e.g. key can be done without risk that {} will pass a nullptr to a random oracle, but it will instead select the default constructor of key_storage.

Public Types

using fn_t = void (*)(void*, std::size_t)

Function pointer which takes a void pointer and a size.

Public Functions

inline explicit random_oracle(fn_t fn_)

Explicitly wraps around a function pointer.

Parameters:

fn_ – Buffer-filling function matching the void (void *, std::size_t) signature.

inline void operator()(void *ptr, std::size_t len) const

Fills a preallocated buffer ptr of length len with random bytes. This is done by forwarding the arguments as-is to fn.

Parameters:
  • ptr – Preallocated buffer pointer

  • len – Number of bytes to fill at ptr.

Public Members

fn_t fn = nullptr

Pointer to the buffer-filling function.