Botan 3.6.1
Crypto and TLS for C&
Botan::detail::Bounded_XOF< XofT, bound > Class Template Referencefinal

#include <pqcrystals_helpers.h>

Public Member Functions

 Bounded_XOF ()
 
 Bounded_XOF (XofT xof)
 
template<size_t bytes, typename MapFnT = decltype(default_transformer<bytes>), typename PredicateFnT = decltype(default_predicate<bytes, MappedValueT<bytes, MapFnT>>)>
requires std::invocable<MapFnT, std::array<uint8_t, bytes>> && std::invocable<PredicateFnT, MappedValueT<bytes, MapFnT>>
constexpr auto next (MapFnT &&transformer=default_transformer< bytes >, PredicateFnT &&predicate=default_predicate< bytes, MappedValueT< bytes, MapFnT > >)
 
template<typename PredicateFnT = decltype(default_predicate<1, uint8_t>)>
requires std::invocable<PredicateFnT, uint8_t>
constexpr auto next_byte (PredicateFnT &&predicate=default_predicate< 1, uint8_t >)
 

Static Public Member Functions

template<size_t bytes, typename T >
static constexpr bool default_predicate (T)
 
template<size_t bytes>
static constexpr auto default_transformer (std::array< uint8_t, bytes > x)
 

Detailed Description

template<typename XofT, size_t bound>
requires requires(XofT xof) { { xof.template output<1>() } -> std::convertible_to<std::span<const uint8_t, 1>>; { xof.template output<42>() } -> std::convertible_to<std::span<const uint8_t, 42>>; }
class Botan::detail::Bounded_XOF< XofT, bound >

Wraps any XOF to limit the number of bytes that can be produced to bound. When the bound is reached, the XOF will throw an Internal_Error.

Definition at line 149 of file pqcrystals_helpers.h.

Constructor & Destructor Documentation

◆ Bounded_XOF() [1/2]

template<typename XofT , size_t bound>
Botan::detail::Bounded_XOF< XofT, bound >::Bounded_XOF ( )
inline

Definition at line 166 of file pqcrystals_helpers.h.

168 : m_bytes_consumed(0) {}

◆ Bounded_XOF() [2/2]

template<typename XofT , size_t bound>
Botan::detail::Bounded_XOF< XofT, bound >::Bounded_XOF ( XofT xof)
inlineexplicit

Definition at line 170 of file pqcrystals_helpers.h.

170: m_xof(xof), m_bytes_consumed(0) {}

Member Function Documentation

◆ default_predicate()

template<typename XofT , size_t bound>
template<size_t bytes, typename T >
static constexpr bool Botan::detail::Bounded_XOF< XofT, bound >::default_predicate ( T )
inlinestaticconstexpr

Definition at line 161 of file pqcrystals_helpers.h.

161 {
162 return true;
163 }

◆ default_transformer()

template<typename XofT , size_t bound>
template<size_t bytes>
static constexpr auto Botan::detail::Bounded_XOF< XofT, bound >::default_transformer ( std::array< uint8_t, bytes > x)
inlinestaticconstexpr

Definition at line 156 of file pqcrystals_helpers.h.

156 {
157 return x;
158 }

◆ next()

template<typename XofT , size_t bound>
template<size_t bytes, typename MapFnT = decltype(default_transformer<bytes>), typename PredicateFnT = decltype(default_predicate<bytes, MappedValueT<bytes, MapFnT>>)>
requires std::invocable<MapFnT, std::array<uint8_t, bytes>> && std::invocable<PredicateFnT, MappedValueT<bytes, MapFnT>>
auto Botan::detail::Bounded_XOF< XofT, bound >::next ( MapFnT && transformer = default_transformer<bytes>,
PredicateFnT && predicate = default_predicate<bytes, MappedValueT<bytes, MapFnT>> )
inlineconstexpr

Pulls the next bytes from the XOF and applies transformer to the output. The result is returned if predicate is fulfilled.

Returns
the transformed output of the XOF that fulfills predicate.

Definition at line 191 of file pqcrystals_helpers.h.

192 {
193 while(true) {
194 auto output = transformer(take<bytes>());
195 if(predicate(output)) {
196 return output;
197 }
198 }
199 }

Referenced by Botan::detail::Bounded_XOF< XofT, bound >::next_byte().

◆ next_byte()

template<typename XofT , size_t bound>
template<typename PredicateFnT = decltype(default_predicate<1, uint8_t>)>
requires std::invocable<PredicateFnT, uint8_t>
auto Botan::detail::Bounded_XOF< XofT, bound >::next_byte ( PredicateFnT && predicate = default_predicate<1, uint8_t>)
inlineconstexpr
Returns
the next byte from the XOF that fulfills predicate.

Definition at line 177 of file pqcrystals_helpers.h.

177 {
178 return next<1>([](const auto bytes) { return bytes[0]; }, std::forward<PredicateFnT>(predicate));
179 }
constexpr auto next(MapFnT &&transformer=default_transformer< bytes >, PredicateFnT &&predicate=default_predicate< bytes, MappedValueT< bytes, MapFnT > >)

References Botan::detail::Bounded_XOF< XofT, bound >::next().


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