aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/nr
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/nr
parent2fbfdd7e5afb5e888fd8c0b56c6df09e2bdeaca7 (diff)
Mass-prefix member vars with m_
Diffstat (limited to 'src/lib/pubkey/nr')
-rw-r--r--src/lib/pubkey/nr/nr.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/lib/pubkey/nr/nr.cpp b/src/lib/pubkey/nr/nr.cpp
index ed90c2345..64e08a111 100644
--- a/src/lib/pubkey/nr/nr.cpp
+++ b/src/lib/pubkey/nr/nr.cpp
@@ -24,8 +24,8 @@ NR_PublicKey::NR_PublicKey(const AlgorithmIdentifier& alg_id,
*/
NR_PublicKey::NR_PublicKey(const DL_Group& grp, const BigInt& y1)
{
- group = grp;
- y = y1;
+ m_group = grp;
+ m_y = y1;
}
/*
@@ -35,13 +35,13 @@ NR_PrivateKey::NR_PrivateKey(RandomNumberGenerator& rng,
const DL_Group& grp,
const BigInt& x_arg)
{
- group = grp;
- x = x_arg;
+ m_group = grp;
+ m_x = x_arg;
- if(x == 0)
- x = BigInt::random_integer(rng, 2, group_q() - 1);
+ if(m_x == 0)
+ m_x = BigInt::random_integer(rng, 2, group_q() - 1);
- y = power_mod(group_g(), x, group_p());
+ m_y = power_mod(group_g(), m_x, group_p());
if(x_arg == 0)
gen_check(rng);
@@ -54,7 +54,7 @@ NR_PrivateKey::NR_PrivateKey(const AlgorithmIdentifier& alg_id,
RandomNumberGenerator& rng) :
DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
{
- y = power_mod(group_g(), x, group_p());
+ m_y = power_mod(group_g(), m_x, group_p());
load_check(rng);
}
@@ -64,7 +64,7 @@ NR_PrivateKey::NR_PrivateKey(const AlgorithmIdentifier& alg_id,
*/
bool NR_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
{
- if(!DL_Scheme_PrivateKey::check_key(rng, strong) || x >= group_q())
+ if(!DL_Scheme_PrivateKey::check_key(rng, strong) || m_x >= group_q())
return false;
if(!strong)
@@ -84,24 +84,24 @@ class NR_Signature_Operation : public PK_Ops::Signature_with_EMSA
typedef NR_PrivateKey Key_Type;
NR_Signature_Operation(const NR_PrivateKey& nr, const std::string& emsa) :
PK_Ops::Signature_with_EMSA(emsa),
- q(nr.group_q()),
- x(nr.get_x()),
- powermod_g_p(nr.group_g(), nr.group_p()),
- mod_q(nr.group_q())
+ m_q(nr.group_q()),
+ m_x(nr.get_x()),
+ m_powermod_g_p(nr.group_g(), nr.group_p()),
+ m_mod_q(nr.group_q())
{
}
size_t message_parts() const override { return 2; }
- size_t message_part_size() const override { return q.bytes(); }
- size_t max_input_bits() const override { return (q.bits() - 1); }
+ size_t message_part_size() const override { return m_q.bytes(); }
+ size_t max_input_bits() const override { return (m_q.bits() - 1); }
secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
- const BigInt& q;
- const BigInt& x;
- Fixed_Base_Power_Mod powermod_g_p;
- Modular_Reducer mod_q;
+ const BigInt& m_q;
+ const BigInt& m_x;
+ Fixed_Base_Power_Mod m_powermod_g_p;
+ Modular_Reducer m_mod_q;
};
secure_vector<byte>
@@ -112,7 +112,7 @@ NR_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
BigInt f(msg, msg_len);
- if(f >= q)
+ if(f >= m_q)
throw Invalid_Argument("NR_Signature_Operation: Input is out of range");
BigInt c, d;
@@ -121,14 +121,14 @@ NR_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
{
BigInt k;
do
- k.randomize(rng, q.bits());
- while(k >= q);
+ k.randomize(rng, m_q.bits());
+ while(k >= m_q);
- c = mod_q.reduce(powermod_g_p(k) + f);
- d = mod_q.reduce(k - x * c);
+ c = m_mod_q.reduce(m_powermod_g_p(k) + f);
+ d = m_mod_q.reduce(k - m_x * c);
}
- secure_vector<byte> output(2*q.bytes());
+ secure_vector<byte> output(2*m_q.bytes());
c.binary_encode(&output[output.size() / 2 - c.bytes()]);
d.binary_encode(&output[output.size() - d.bytes()]);
return output;
@@ -144,33 +144,33 @@ class NR_Verification_Operation : public PK_Ops::Verification_with_EMSA
typedef NR_PublicKey Key_Type;
NR_Verification_Operation(const NR_PublicKey& nr, const std::string& emsa) :
PK_Ops::Verification_with_EMSA(emsa),
- q(nr.group_q()), y(nr.get_y())
+ m_q(nr.group_q()), m_y(nr.get_y())
{
- powermod_g_p = Fixed_Base_Power_Mod(nr.group_g(), nr.group_p());
- powermod_y_p = Fixed_Base_Power_Mod(y, nr.group_p());
- mod_p = Modular_Reducer(nr.group_p());
- mod_q = Modular_Reducer(nr.group_q());
+ m_powermod_g_p = Fixed_Base_Power_Mod(nr.group_g(), nr.group_p());
+ m_powermod_y_p = Fixed_Base_Power_Mod(m_y, nr.group_p());
+ m_mod_p = Modular_Reducer(nr.group_p());
+ m_mod_q = Modular_Reducer(nr.group_q());
}
size_t message_parts() const override { return 2; }
- size_t message_part_size() const override { return q.bytes(); }
- size_t max_input_bits() const override { return (q.bits() - 1); }
+ size_t message_part_size() const override { return m_q.bytes(); }
+ size_t max_input_bits() const override { return (m_q.bits() - 1); }
bool with_recovery() const override { return true; }
secure_vector<byte> verify_mr(const byte msg[], size_t msg_len) override;
private:
- const BigInt& q;
- const BigInt& y;
+ const BigInt& m_q;
+ const BigInt& m_y;
- Fixed_Base_Power_Mod powermod_g_p, powermod_y_p;
- Modular_Reducer mod_p, mod_q;
+ Fixed_Base_Power_Mod m_powermod_g_p, m_powermod_y_p;
+ Modular_Reducer m_mod_p, m_mod_q;
};
secure_vector<byte>
NR_Verification_Operation::verify_mr(const byte msg[], size_t msg_len)
{
- const BigInt& q = mod_q.get_modulus();
+ const BigInt& q = m_mod_q.get_modulus();
if(msg_len != 2*q.bytes())
throw Invalid_Argument("NR verification: Invalid signature");
@@ -181,11 +181,11 @@ NR_Verification_Operation::verify_mr(const byte msg[], size_t msg_len)
if(c.is_zero() || c >= q || d >= q)
throw Invalid_Argument("NR verification: Invalid signature");
- auto future_y_c = std::async(std::launch::async, powermod_y_p, c);
- BigInt g_d = powermod_g_p(d);
+ auto future_y_c = std::async(std::launch::async, m_powermod_y_p, c);
+ BigInt g_d = m_powermod_g_p(d);
- BigInt i = mod_p.multiply(g_d, future_y_c.get());
- return BigInt::encode_locked(mod_q.reduce(c - i));
+ BigInt i = m_mod_p.multiply(g_d, future_y_c.get());
+ return BigInt::encode_locked(m_mod_q.reduce(c - i));
}
}