Botan  2.16.0 Crypto and TLS for C++11
Botan::Blinder Class Referencefinal

`#include <blinding.h>`

## Public Member Functions

BigInt blind (const BigInt &x) const

Blinder (const BigInt &modulus, RandomNumberGenerator &rng, std::function< BigInt(const BigInt &)> fwd_func, std::function< BigInt(const BigInt &)> inv_func)

Blinder (const Blinder &)=delete

Blinderoperator= (const Blinder &)=delete

RandomNumberGeneratorrng () const

BigInt unblind (const BigInt &x) const

## Detailed Description

Blinding Function Object.

Definition at line 24 of file blinding.h.

## ◆ Blinder() [1/2]

 Botan::Blinder::Blinder ( const BigInt & modulus, RandomNumberGenerator & rng, std::function< BigInt(const BigInt &)> fwd_func, std::function< BigInt(const BigInt &)> inv_func )
Parameters
 modulus the modulus rng the RNG to use for generating the nonce fwd_func a function that calculates the modular exponentiation of the public exponent and the given value (the nonce) inv_func a function that calculates the modular inverse of the given value (the nonce)

Definition at line 12 of file blinding.cpp.

15  :
16  m_reducer(modulus),
17  m_rng(rng),
18  m_fwd_fn(fwd),
19  m_inv_fn(inv),
20  m_modulus_bits(modulus.bits()),
21  m_e{},
22  m_d{},
23  m_counter{}
24  {
25  const BigInt k = blinding_nonce();
26  m_e = m_fwd_fn(k);
27  m_d = m_inv_fn(k);
28  }
size_t bits() const
Definition: bigint.cpp:297
RandomNumberGenerator & rng() const
Definition: blinding.h:63
BigInt const BigInt & modulus
Definition: numthry.h:100

## ◆ Blinder() [2/2]

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

## ◆ 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
 x value to blind
Returns
blinded value

Definition at line 35 of file blinding.cpp.

36  {
37  if(!m_reducer.initialized())
38  throw Invalid_State("Blinder not initialized, cannot blind");
39
40  ++m_counter;
41
42  if((BOTAN_BLINDING_REINIT_INTERVAL > 0) && (m_counter > BOTAN_BLINDING_REINIT_INTERVAL))
43  {
44  const BigInt k = blinding_nonce();
45  m_e = m_fwd_fn(k);
46  m_d = m_inv_fn(k);
47  m_counter = 0;
48  }
49  else
50  {
51  m_e = m_reducer.square(m_e);
52  m_d = m_reducer.square(m_d);
53  }
54
55  return m_reducer.multiply(i, m_e);
56  }
bool initialized() const
Definition: reducer.h:58
BigInt square(const BigInt &x) const
Definition: reducer.h:39
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31

## ◆ 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
 x value to unblind
Returns
unblinded value

Definition at line 58 of file blinding.cpp.

59  {
60  if(!m_reducer.initialized())
61  throw Invalid_State("Blinder not initialized, cannot unblind");
62
63  return m_reducer.multiply(i, m_d);
64  }
bool initialized() const
Definition: reducer.h:58
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31

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