Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::Blinder Class Reference

`#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
Blinder & | operator= (const Blinder &)=delete
BigInt | unblind (const BigInt &x) const

## Detailed Description

Blinding Function Object.

Definition at line 22 of file blinding.h.

## Constructor & Destructor Documentation

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 13 of file blinding.cpp.

16 :
17 m_reducer(modulus),
18 m_rng(rng),
19 m_fwd_fn(fwd),
20 m_inv_fn(inv),
21 m_modulus_bits(modulus.bits()),
22 m_e{},
23 m_d{},
24 m_counter{}
25 {
26 const BigInt k = blinding_nonce();
27 m_e = m_fwd_fn(k);
28 m_d = m_inv_fn(k);
29 }

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

## Member Function Documentation

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 36 of file blinding.cpp.

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

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

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

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

Unblind a value.

Parameters

  x | value to unblind

Returns
  unblinded value

Definition at line 59 of file blinding.cpp.

References Botan::Modular_Reducer::initialized(), and Botan::Modular_Reducer::multiply().

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

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

- src/lib/pubkey/blinding.h
- src/lib/pubkey/blinding.cpp