Botan 3.13.0
Crypto and TLS for C&
Botan::Roughtime::Nonce Class Referencefinal

#include <roughtime.h>

Public Member Functions

const std::array< uint8_t, 64 > & get_nonce () const
 Nonce ()=default
 Nonce (const std::array< uint8_t, 64 > &nonce)
 Nonce (const std::vector< uint8_t > &nonce)
 Nonce (RandomNumberGenerator &rng)
bool operator== (const Nonce &rhs) const

Detailed Description

A 64 byte Roughtime nonce

Definition at line 49 of file roughtime.h.

Constructor & Destructor Documentation

◆ Nonce() [1/4]

Botan::Roughtime::Nonce::Nonce ( )
default

Create an uninitialized nonce

References Nonce().

Referenced by Nonce(), and operator==().

◆ Nonce() [2/4]

Botan::Roughtime::Nonce::Nonce ( const std::vector< uint8_t > & nonce)
explicit

Create a nonce from a 64 byte vector

Parameters
noncethe nonce bytes

Definition at line 165 of file roughtime.cpp.

165 : m_nonce{} {
166 if(nonce.size() != 64) {
167 throw Invalid_Argument("Roughtime nonce must be 64 bytes long");
168 }
169 m_nonce = typecast_copy<std::array<uint8_t, 64>>(nonce.data());
170}
constexpr void typecast_copy(ToR &&out, const FromR &in)
Definition mem_ops.h:176

References Botan::typecast_copy().

◆ Nonce() [3/4]

Botan::Roughtime::Nonce::Nonce ( RandomNumberGenerator & rng)
explicit

Create a random nonce

Parameters
Random Number Generatorsa random number generator

Definition at line 172 of file roughtime.cpp.

172: m_nonce(rng.random_array<64>()) {}

◆ Nonce() [4/4]

Botan::Roughtime::Nonce::Nonce ( const std::array< uint8_t, 64 > & nonce)
inlineexplicit

Create a nonce from a 64 byte array

Parameters
noncethe nonce bytes

Definition at line 72 of file roughtime.h.

72: m_nonce(nonce) {}

Member Function Documentation

◆ get_nonce()

const std::array< uint8_t, 64 > & Botan::Roughtime::Nonce::get_nonce ( ) const
inline

Access the nonce bytes

Returns
the 64 nonce bytes

Definition at line 85 of file roughtime.h.

85{ return m_nonce; }

Referenced by Botan::Roughtime::encode_request(), Botan::Roughtime::Response::from_bits(), and Botan::Roughtime::nonce_from_blind().

◆ operator==()

bool Botan::Roughtime::Nonce::operator== ( const Nonce & rhs) const
inline

Compare two nonces

Parameters
rhsthe nonce to compare against
Returns
true if the nonces are equal

Definition at line 79 of file roughtime.h.

79{ return m_nonce == rhs.m_nonce; }

References Nonce().


The documentation for this class was generated from the following files: