aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/if_algo/if_algo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/if_algo/if_algo.cpp')
-rw-r--r--src/lib/pubkey/if_algo/if_algo.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/lib/pubkey/if_algo/if_algo.cpp b/src/lib/pubkey/if_algo/if_algo.cpp
index 9c49b8dd4..a79cad116 100644
--- a/src/lib/pubkey/if_algo/if_algo.cpp
+++ b/src/lib/pubkey/if_algo/if_algo.cpp
@@ -15,7 +15,7 @@ namespace Botan {
size_t IF_Scheme_PublicKey::estimated_strength() const
{
- return if_work_factor(n.bits());
+ return if_work_factor(m_n.bits());
}
AlgorithmIdentifier IF_Scheme_PublicKey::algorithm_identifier() const
@@ -28,8 +28,8 @@ std::vector<byte> IF_Scheme_PublicKey::x509_subject_public_key() const
{
return DER_Encoder()
.start_cons(SEQUENCE)
- .encode(n)
- .encode(e)
+ .encode(m_n)
+ .encode(m_e)
.end_cons()
.get_contents_unlocked();
}
@@ -39,8 +39,8 @@ IF_Scheme_PublicKey::IF_Scheme_PublicKey(const AlgorithmIdentifier&,
{
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
- .decode(n)
- .decode(e)
+ .decode(m_n)
+ .decode(m_e)
.verify_end()
.end_cons();
}
@@ -50,7 +50,7 @@ IF_Scheme_PublicKey::IF_Scheme_PublicKey(const AlgorithmIdentifier&,
*/
bool IF_Scheme_PublicKey::check_key(RandomNumberGenerator&, bool) const
{
- if(n < 35 || n.is_even() || e < 2)
+ if(m_n < 35 || m_n.is_even() || m_e < 2)
return false;
return true;
}
@@ -60,14 +60,14 @@ secure_vector<byte> IF_Scheme_PrivateKey::pkcs8_private_key() const
return DER_Encoder()
.start_cons(SEQUENCE)
.encode(static_cast<size_t>(0))
- .encode(n)
- .encode(e)
- .encode(d)
- .encode(p)
- .encode(q)
- .encode(d1)
- .encode(d2)
- .encode(c)
+ .encode(m_n)
+ .encode(m_e)
+ .encode(m_d)
+ .encode(m_p)
+ .encode(m_q)
+ .encode(m_d1)
+ .encode(m_d2)
+ .encode(m_c)
.end_cons()
.get_contents();
}
@@ -79,14 +79,14 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
BER_Decoder(key_bits)
.start_cons(SEQUENCE)
.decode_and_check<size_t>(0, "Unknown PKCS #1 key format version")
- .decode(n)
- .decode(e)
- .decode(d)
- .decode(p)
- .decode(q)
- .decode(d1)
- .decode(d2)
- .decode(c)
+ .decode(m_n)
+ .decode(m_e)
+ .decode(m_d)
+ .decode(m_p)
+ .decode(m_q)
+ .decode(m_d1)
+ .decode(m_d2)
+ .decode(m_c)
.end_cons();
load_check(rng);
@@ -99,24 +99,24 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
const BigInt& d_exp,
const BigInt& mod)
{
- p = prime1;
- q = prime2;
- e = exp;
- d = d_exp;
- n = mod.is_nonzero() ? mod : p * q;
+ m_p = prime1;
+ m_q = prime2;
+ m_e = exp;
+ m_d = d_exp;
+ m_n = mod.is_nonzero() ? mod : m_p * m_q;
- if(d == 0)
+ if(m_d == 0)
{
- BigInt inv_for_d = lcm(p - 1, q - 1);
- if(e.is_even())
+ BigInt inv_for_d = lcm(m_p - 1, m_q - 1);
+ if(m_e.is_even())
inv_for_d >>= 1;
- d = inverse_mod(e, inv_for_d);
+ m_d = inverse_mod(m_e, inv_for_d);
}
- d1 = d % (p - 1);
- d2 = d % (q - 1);
- c = inverse_mod(q, p);
+ m_d1 = m_d % (m_p - 1);
+ m_d2 = m_d % (m_q - 1);
+ m_c = inverse_mod(m_q, m_p);
load_check(rng);
}
@@ -127,15 +127,15 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
bool IF_Scheme_PrivateKey::check_key(RandomNumberGenerator& rng,
bool strong) const
{
- if(n < 35 || n.is_even() || e < 2 || d < 2 || p < 3 || q < 3 || p*q != n)
+ if(m_n < 35 || m_n.is_even() || m_e < 2 || m_d < 2 || m_p < 3 || m_q < 3 || m_p*m_q != m_n)
return false;
- if(d1 != d % (p - 1) || d2 != d % (q - 1) || c != inverse_mod(q, p))
+ if(m_d1 != m_d % (m_p - 1) || m_d2 != m_d % (m_q - 1) || m_c != inverse_mod(m_q, m_p))
return false;
const size_t prob = (strong) ? 56 : 12;
- if(!is_prime(p, rng, prob) || !is_prime(q, rng, prob))
+ if(!is_prime(m_p, rng, prob) || !is_prime(m_q, rng, prob))
return false;
return true;
}