Botan: src/pubkey/blinding.cpp Source File

Botan 1.10.17

blinding.cpp
Go to the documentation of this file.
1 /*
2 * Blinding for public key operations
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #include <botan/blinding.h>
9 #include <botan/numthry.h>
10
11 namespace Botan {
12
13 /*
14 * Blinder Constructor
15 */
16 Blinder::Blinder(const BigInt& e, const BigInt& d, const BigInt& n)
17 {
18 if(e < 1 || d < 1 || n < 1)
19 throw Invalid_Argument("Blinder: Arguments too small");
20
21 reducer = Modular_Reducer(n);
22 this->e = e;
23 this->d = d;
24 }
25
26 /*
27 * Blind a number
28 */
29 BigInt Blinder::blind(const BigInt& i) const
30 {
31 if(!reducer.initialized())
32 return i;
33
34 e = reducer.square(e);
35 d = reducer.square(d);
36 return reducer.multiply(i, e);
37 }
38
39 /*
40 * Unblind a number
41 */
42 BigInt Blinder::unblind(const BigInt& i) const
43 {
44 if(!reducer.initialized())
45 return i;
46 return reducer.multiply(i, d);
47 }
48
49 }
Botan::Modular_Reducer::initialized
bool initialized() const
Definition: reducer.h:50
Botan::BigInt
Definition: bigint.h:22
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::Blinder::unblind
BigInt unblind(const BigInt &x) const
Definition: blinding.cpp:42
Botan
Definition: algo_base.h:14
Botan::Blinder::blind
BigInt blind(const BigInt &x) const
Definition: blinding.cpp:29
Botan::Blinder::Blinder
Blinder()
Definition: blinding.h:27
Botan::Modular_Reducer::square
BigInt square(const BigInt &x) const
Definition: reducer.h:39
Botan::Modular_Reducer
Definition: reducer.h:18
Botan::Modular_Reducer::multiply
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31