Botan 3.14.1
Crypto and TLS for C&
Botan::BlindingRandomness< BlindedScalar, Scalars > Class Template Referencefinal

#include <pcurves_impl.h>

Public Member Functions

 BlindingRandomness (RandomNumberGenerator &rng)
const FieldElement & isomorphism () const
std::span< const uint8_t, MaskBytes > mask (size_t idx) const
void randomize_rep (typename C::ProjectivePoint &pt, size_t idx) const
bool seeded () const

Static Public Attributes

static constexpr size_t Rerandomizations = 4
 Each multiplication re-randomizes the accumulator this many times.

Detailed Description

template<typename BlindedScalar, size_t Scalars = 1>
class Botan::BlindingRandomness< BlindedScalar, Scalars >

The randomness consumed by one blinded scalar multiplication

The scalar masks, the projective re-randomizations, and the random curve isomorphism of the point table are drawn from the RNG with a single request, since each request has a fixed cost that dominates for small outputs.

If the provided RNG is not seeded, no randomness is drawn and blinding is skipped; the isomorphism parameter is then one.

Definition at line 1435 of file pcurves_impl.h.

Constructor & Destructor Documentation

◆ BlindingRandomness()

template<typename BlindedScalar, size_t Scalars = 1>
Botan::BlindingRandomness< BlindedScalar, Scalars >::BlindingRandomness ( RandomNumberGenerator & rng)
inlineexplicit

Definition at line 1450 of file pcurves_impl.h.

1450 : m_seeded(rng.is_seeded()) {
1451 // Conditional ok: caller's RNG state (seeded vs not) is presumed public
1452 if(m_seeded) {
1453 std::array<uint8_t, Scalars * MaskBytes + (Rerandomizations + 1) * WideBytes> buf{};
1454 rng.randomize(buf);
1455
1457
1458 copy_mem(m_masks, bytes.first<Scalars * MaskBytes>());
1459
1460 for(size_t i = 0; i != Rerandomizations; ++i) {
1461 const auto wide = bytes.subspan(Scalars * MaskBytes + i * WideBytes).first<WideBytes>();
1462 m_rerandomizers[i] = FieldElement::from_wide_bytes(wide);
1463 }
1464
1465 const auto iso = bytes.subspan(Scalars * MaskBytes + Rerandomizations * WideBytes).first<WideBytes>();
1466 m_isomorphism = FieldElement::from_wide_bytes(iso);
1467 m_isomorphism.conditional_assign(m_isomorphism.is_zero(), FieldElement::one());
1468 }
1469 }
static constexpr size_t Rerandomizations
Each multiplication re-randomizes the accumulator this many times.
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:144

References Botan::copy_mem(), Botan::RandomNumberGenerator::randomize(), and Rerandomizations.

Member Function Documentation

◆ isomorphism()

template<typename BlindedScalar, size_t Scalars = 1>
const FieldElement & Botan::BlindingRandomness< BlindedScalar, Scalars >::isomorphism ( ) const
inline

Return the random curve isomorphism parameter for the point table

Definition at line 1492 of file pcurves_impl.h.

1492{ return m_isomorphism; }

Referenced by Botan::varpoint_mul2().

◆ mask()

template<typename BlindedScalar, size_t Scalars = 1>
std::span< const uint8_t, MaskBytes > Botan::BlindingRandomness< BlindedScalar, Scalars >::mask ( size_t idx) const
inline

Definition at line 1473 of file pcurves_impl.h.

1473 {
1475 return std::span{m_masks}.subspan(idx * MaskBytes).template first<MaskBytes>();
1476 }
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82

References BOTAN_ASSERT_NOMSG.

◆ randomize_rep()

template<typename BlindedScalar, size_t Scalars = 1>
void Botan::BlindingRandomness< BlindedScalar, Scalars >::randomize_rep ( typename C::ProjectivePoint & pt,
size_t idx ) const
inline

Randomize the projective representation of pt using the idx'th element

Definition at line 1481 of file pcurves_impl.h.

1481 {
1483 // Conditional ok: caller's RNG state (seeded vs not) is presumed public
1484 if(m_seeded) {
1485 pt.randomize_rep(m_rerandomizers[idx]);
1486 }
1487 }
void randomize_rep(typename C::ProjectivePoint &pt, size_t idx) const

References BOTAN_ASSERT_NOMSG, and Rerandomizations.

◆ seeded()

template<typename BlindedScalar, size_t Scalars = 1>
bool Botan::BlindingRandomness< BlindedScalar, Scalars >::seeded ( ) const
inline

Definition at line 1471 of file pcurves_impl.h.

1471{ return m_seeded; }

Member Data Documentation

◆ Rerandomizations

template<typename BlindedScalar, size_t Scalars = 1>
size_t Botan::BlindingRandomness< BlindedScalar, Scalars >::Rerandomizations = 4
staticconstexpr

Each multiplication re-randomizes the accumulator this many times.

Definition at line 1438 of file pcurves_impl.h.

Referenced by BlindingRandomness(), and randomize_rep().


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