Botan
1.10.17
src
pubkey
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::BigInt
Definition
bigint.h:23
Botan::Blinder::blind
BigInt blind(const BigInt &x) const
Definition
blinding.cpp:29
Botan::Blinder::unblind
BigInt unblind(const BigInt &x) const
Definition
blinding.cpp:42
Botan::Blinder::Blinder
Blinder()
Definition
blinding.h:27
Botan::Modular_Reducer::Modular_Reducer
Modular_Reducer()
Definition
reducer.h:52
Botan
Definition
algo_base.h:14
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition
exceptn.h:20
Generated by
1.18.0