aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/rsa
diff options
context:
space:
mode:
authorRenĂ© Korthaus <[email protected]>2015-12-23 11:52:19 +0100
committerJack Lloyd <[email protected]>2016-01-08 19:09:51 -0500
commitd22bc10cd4f67924acd82bcd46a31e3de3b20ce3 (patch)
tree58459585e6675cd799b6ef5900be026825cd6f9d /src/lib/pubkey/rsa
parent2fbfdd7e5afb5e888fd8c0b56c6df09e2bdeaca7 (diff)
Mass-prefix member vars with m_
Diffstat (limited to 'src/lib/pubkey/rsa')
-rw-r--r--src/lib/pubkey/rsa/rsa.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp
index 57fab94c5..8d75d4a29 100644
--- a/src/lib/pubkey/rsa/rsa.cpp
+++ b/src/lib/pubkey/rsa/rsa.cpp
@@ -27,19 +27,19 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng,
if(exp < 3 || exp % 2 == 0)
throw Invalid_Argument(algo_name() + ": Invalid encryption exponent");
- e = exp;
+ m_e = exp;
do
{
- p = random_prime(rng, (bits + 1) / 2, e);
- q = random_prime(rng, bits - p.bits(), e);
- n = p * q;
- } while(n.bits() != bits);
+ m_p = random_prime(rng, (bits + 1) / 2, m_e);
+ m_q = random_prime(rng, bits - m_p.bits(), m_e);
+ m_n = m_p * m_q;
+ } while(m_n.bits() != bits);
- d = inverse_mod(e, lcm(p - 1, q - 1));
- d1 = d % (p - 1);
- d2 = d % (q - 1);
- c = inverse_mod(q, p);
+ m_d = inverse_mod(m_e, lcm(m_p - 1, m_q - 1));
+ m_d1 = m_d % (m_p - 1);
+ m_d2 = m_d % (m_q - 1);
+ m_c = inverse_mod(m_q, m_p);
gen_check(rng);
}
@@ -55,7 +55,7 @@ bool RSA_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
if(!strong)
return true;
- if((e * d) % lcm(p - 1, q - 1) != 1)
+ if((m_e * m_d) % lcm(m_p - 1, m_q - 1) != 1)
return false;
return KeyPair::signature_consistency_check(rng, *this, "EMSA4(SHA-1)");
@@ -69,25 +69,25 @@ namespace {
class RSA_Private_Operation
{
protected:
- size_t get_max_input_bits() const { return (n.bits() - 1); }
+ size_t get_max_input_bits() const { return (m_n.bits() - 1); }
RSA_Private_Operation(const RSA_PrivateKey& rsa) :
- n(rsa.get_n()),
- q(rsa.get_q()),
- c(rsa.get_c()),
+ m_n(rsa.get_n()),
+ m_q(rsa.get_q()),
+ m_c(rsa.get_c()),
m_powermod_e_n(rsa.get_e(), rsa.get_n()),
m_powermod_d1_p(rsa.get_d1(), rsa.get_p()),
m_powermod_d2_q(rsa.get_d2(), rsa.get_q()),
m_mod_p(rsa.get_p()),
- m_blinder(n,
+ m_blinder(m_n,
[this](const BigInt& k) { return m_powermod_e_n(k); },
- [this](const BigInt& k) { return inverse_mod(k, n); })
+ [this](const BigInt& k) { return inverse_mod(k, m_n); })
{
}
BigInt blinded_private_op(const BigInt& m) const
{
- if(m >= n)
+ if(m >= m_n)
throw Invalid_Argument("RSA private op - input is too large");
return m_blinder.unblind(private_op(m_blinder.blind(m)));
@@ -99,14 +99,14 @@ class RSA_Private_Operation
BigInt j2 = m_powermod_d2_q(m);
BigInt j1 = future_j1.get();
- j1 = m_mod_p.reduce(sub_mul(j1, j2, c));
+ j1 = m_mod_p.reduce(sub_mul(j1, j2, m_c));
- return mul_add(j1, q, j2);
+ return mul_add(j1, m_q, j2);
}
- const BigInt& n;
- const BigInt& q;
- const BigInt& c;
+ const BigInt& m_n;
+ const BigInt& m_q;
+ const BigInt& m_c;
Fixed_Exponent_Power_Mod m_powermod_e_n, m_powermod_d1_p, m_powermod_d2_q;
Modular_Reducer m_mod_p;
Blinder m_blinder;
@@ -133,7 +133,7 @@ class RSA_Signature_Operation : public PK_Ops::Signature_with_EMSA,
const BigInt x = blinded_private_op(m);
const BigInt c = m_powermod_e_n(x);
BOTAN_ASSERT(m == c, "RSA sign consistency check");
- return BigInt::encode_1363(x, n.bytes());
+ return BigInt::encode_1363(x, m_n.bytes());
}
};
@@ -180,7 +180,7 @@ class RSA_KEM_Decryption_Operation : public PK_Ops::KEM_Decryption_with_KDF,
const BigInt x = blinded_private_op(m);
const BigInt c = m_powermod_e_n(x);
BOTAN_ASSERT(m == c, "RSA KEM consistency check");
- return BigInt::encode_1363(x, n.bytes());
+ return BigInt::encode_1363(x, m_n.bytes());
}
};