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
11namespace Botan {
12
13/*
14* Blinder Constructor
15*/
16Blinder::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*/
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*/
43 {
44 if(!reducer.initialized())
45 return i;
46 return reducer.multiply(i, d);
47 }
48
49}
BigInt blind(const BigInt &x) const
Definition blinding.cpp:29
BigInt unblind(const BigInt &x) const
Definition blinding.cpp:42
std::invalid_argument Invalid_Argument
Definition exceptn.h:20