Botan 3.7.1
Crypto and TLS for C&
Botan::Blinder Class Referencefinal

#include <blinding.h>

Public Member Functions

BigInt blind (const BigInt &x) const
 
 Blinder (const Blinder &)=delete
 
 Blinder (const Modular_Reducer &reducer, RandomNumberGenerator &rng, std::function< BigInt(const BigInt &)> fwd_func, std::function< BigInt(const BigInt &)> inv_func)
 
Blinderoperator= (const Blinder &)=delete
 
RandomNumberGeneratorrng () const
 
BigInt unblind (const BigInt &x) const
 

Detailed Description

Blinding Function Object.

Definition at line 22 of file blinding.h.

Constructor & Destructor Documentation

◆ Blinder() [1/2]

Botan::Blinder::Blinder ( const Modular_Reducer & reducer,
RandomNumberGenerator & rng,
std::function< BigInt(const BigInt &)> fwd_func,
std::function< BigInt(const BigInt &)> inv_func )
Parameters
reducerprecomputed Barrett reduction for the modulus
rngthe RNG to use for generating the nonce
fwd_funca function that calculates the modular exponentiation of the public exponent and the given value (the nonce)
inv_funca function that calculates the modular inverse of the given value (the nonce)
Note
Lifetime: The rng and reducer arguments are captured by reference and must live as long as the Blinder does

Definition at line 12 of file blinding.cpp.

15 :
16 m_reducer(reducer),
17 m_rng(rng),
18 m_fwd_fn(std::move(fwd)),
19 m_inv_fn(std::move(inv)),
20 m_modulus_bits(reducer.get_modulus().bits()),
21 m_e{},
22 m_d{},
23 m_counter{} {
24 const BigInt k = blinding_nonce();
25 m_e = m_fwd_fn(k);
26 m_d = m_inv_fn(k);
27}
RandomNumberGenerator & rng() const
Definition blinding.h:63

◆ Blinder() [2/2]

Botan::Blinder::Blinder ( const Blinder & )
delete

Member Function Documentation

◆ blind()

BigInt Botan::Blinder::blind ( const BigInt & x) const

Blind a value. The blinding nonce k is freshly generated after BOTAN_BLINDING_REINIT_INTERVAL calls to blind(). BOTAN_BLINDING_REINIT_INTERVAL = 0 means a fresh nonce is only generated once. On every other call, an updated nonce is used for blinding: k' = k*k mod n.

Parameters
xvalue to blind
Returns
blinded value

Definition at line 33 of file blinding.cpp.

33 {
34 ++m_counter;
35
37 const BigInt k = blinding_nonce();
38 m_e = m_fwd_fn(k);
39 m_d = m_inv_fn(k);
40 m_counter = 0;
41 } else {
42 m_e = m_reducer.square(m_e);
43 m_d = m_reducer.square(m_d);
44 }
45
46 return m_reducer.multiply(i, m_e);
47}
BigInt square(const BigInt &x) const
Definition reducer.cpp:61
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition reducer.h:32
#define BOTAN_BLINDING_REINIT_INTERVAL
Definition build.h:508

References BOTAN_BLINDING_REINIT_INTERVAL, Botan::Modular_Reducer::multiply(), and Botan::Modular_Reducer::square().

◆ operator=()

Blinder & Botan::Blinder::operator= ( const Blinder & )
delete

◆ rng()

RandomNumberGenerator & Botan::Blinder::rng ( ) const
inline

Definition at line 63 of file blinding.h.

63{ return m_rng; }

◆ unblind()

BigInt Botan::Blinder::unblind ( const BigInt & x) const

Unblind a value.

Parameters
xvalue to unblind
Returns
unblinded value

Definition at line 49 of file blinding.cpp.

49 {
50 return m_reducer.multiply(i, m_d);
51}

References Botan::Modular_Reducer::multiply().


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