diff options
Diffstat (limited to 'src/lib/pubkey/dl_group')
-rw-r--r-- | src/lib/pubkey/dl_group/dl_group.cpp | 72 | ||||
-rw-r--r-- | src/lib/pubkey/dl_group/dl_group.h | 4 |
2 files changed, 38 insertions, 38 deletions
diff --git a/src/lib/pubkey/dl_group/dl_group.cpp b/src/lib/pubkey/dl_group/dl_group.cpp index ed9b60c7c..40660e62a 100644 --- a/src/lib/pubkey/dl_group/dl_group.cpp +++ b/src/lib/pubkey/dl_group/dl_group.cpp @@ -20,7 +20,7 @@ namespace Botan { */ DL_Group::DL_Group() { - initialized = false; + m_initialized = false; } /* @@ -48,35 +48,35 @@ DL_Group::DL_Group(RandomNumberGenerator& rng, if(type == Strong) { - p = random_safe_prime(rng, pbits); - q = (p - 1) / 2; - g = 2; + m_p = random_safe_prime(rng, pbits); + m_q = (m_p - 1) / 2; + m_g = 2; } else if(type == Prime_Subgroup) { if(!qbits) qbits = dl_exponent_size(pbits); - q = random_prime(rng, qbits); + m_q = random_prime(rng, qbits); BigInt X; - while(p.bits() != pbits || !is_prime(p, rng)) + while(m_p.bits() != pbits || !is_prime(m_p, rng)) { X.randomize(rng, pbits); - p = X - (X % (2*q) - 1); + m_p = X - (X % (2*m_q) - 1); } - g = make_dsa_generator(p, q); + m_g = make_dsa_generator(m_p, m_q); } else if(type == DSA_Kosherizer) { qbits = qbits ? qbits : ((pbits <= 1024) ? 160 : 256); - generate_dsa_primes(rng, p, q, pbits, qbits); + generate_dsa_primes(rng, m_p, m_q, pbits, qbits); - g = make_dsa_generator(p, q); + m_g = make_dsa_generator(m_p, m_q); } - initialized = true; + m_initialized = true; } /* @@ -86,13 +86,13 @@ DL_Group::DL_Group(RandomNumberGenerator& rng, const std::vector<byte>& seed, size_t pbits, size_t qbits) { - if(!generate_dsa_primes(rng, p, q, pbits, qbits, seed)) + if(!generate_dsa_primes(rng, m_p, m_q, pbits, qbits, seed)) throw Invalid_Argument("DL_Group: The seed given does not " "generate a DSA group"); - g = make_dsa_generator(p, q); + m_g = make_dsa_generator(m_p, m_q); - initialized = true; + m_initialized = true; } /* @@ -123,11 +123,11 @@ void DL_Group::initialize(const BigInt& p1, const BigInt& q1, const BigInt& g1) if(q1 < 0 || q1 >= p1) throw Invalid_Argument("DL_Group: Subgroup invalid"); - p = p1; - g = g1; - q = q1; + m_p = p1; + m_g = g1; + m_q = q1; - initialized = true; + m_initialized = true; } /* @@ -135,7 +135,7 @@ void DL_Group::initialize(const BigInt& p1, const BigInt& q1, const BigInt& g1) */ void DL_Group::init_check() const { - if(!initialized) + if(!m_initialized) throw Invalid_State("DLP group cannot be used uninitialized"); } @@ -147,16 +147,16 @@ bool DL_Group::verify_group(RandomNumberGenerator& rng, { init_check(); - if(g < 2 || p < 3 || q < 0) + if(m_g < 2 || m_p < 3 || m_q < 0) return false; - if((q != 0) && ((p - 1) % q != 0)) + if((m_q != 0) && ((m_p - 1) % m_q != 0)) return false; const size_t prob = (strong) ? 56 : 10; - if(!is_prime(p, rng, prob)) + if(!is_prime(m_p, rng, prob)) return false; - if((q > 0) && !is_prime(q, rng, prob)) + if((m_q > 0) && !is_prime(m_q, rng, prob)) return false; return true; } @@ -167,7 +167,7 @@ bool DL_Group::verify_group(RandomNumberGenerator& rng, const BigInt& DL_Group::get_p() const { init_check(); - return p; + return m_p; } /* @@ -176,7 +176,7 @@ const BigInt& DL_Group::get_p() const const BigInt& DL_Group::get_g() const { init_check(); - return g; + return m_g; } /* @@ -185,9 +185,9 @@ const BigInt& DL_Group::get_g() const const BigInt& DL_Group::get_q() const { init_check(); - if(q == 0) + if(m_q == 0) throw Invalid_State("DLP group has no q prime specified"); - return q; + return m_q; } /* @@ -197,16 +197,16 @@ std::vector<byte> DL_Group::DER_encode(Format format) const { init_check(); - if((q == 0) && (format != PKCS_3)) + if((m_q == 0) && (format != PKCS_3)) throw Encoding_Error("The ANSI DL parameter formats require a subgroup"); if(format == ANSI_X9_57) { return DER_Encoder() .start_cons(SEQUENCE) - .encode(p) - .encode(q) - .encode(g) + .encode(m_p) + .encode(m_q) + .encode(m_g) .end_cons() .get_contents_unlocked(); } @@ -214,9 +214,9 @@ std::vector<byte> DL_Group::DER_encode(Format format) const { return DER_Encoder() .start_cons(SEQUENCE) - .encode(p) - .encode(g) - .encode(q) + .encode(m_p) + .encode(m_g) + .encode(m_q) .end_cons() .get_contents_unlocked(); } @@ -224,8 +224,8 @@ std::vector<byte> DL_Group::DER_encode(Format format) const { return DER_Encoder() .start_cons(SEQUENCE) - .encode(p) - .encode(g) + .encode(m_p) + .encode(m_g) .end_cons() .get_contents_unlocked(); } diff --git a/src/lib/pubkey/dl_group/dl_group.h b/src/lib/pubkey/dl_group/dl_group.h index 7201054f2..8bdd205da 100644 --- a/src/lib/pubkey/dl_group/dl_group.h +++ b/src/lib/pubkey/dl_group/dl_group.h @@ -161,8 +161,8 @@ class BOTAN_DLL DL_Group void init_check() const; void initialize(const BigInt&, const BigInt&, const BigInt&); - bool initialized; - BigInt p, q, g; + bool m_initialized; + BigInt m_p, m_q, m_g; }; } |