aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-19 21:38:12 +0000
committerlloyd <[email protected]>2012-07-19 21:38:12 +0000
commitf5775ee4aa20abd43b025869c733ed1b473f4034 (patch)
treef28a83ff1895504493a3010a57fefa2172abf957 /src
parent360e97936a3cd410a13aaddbf810fa4647588163 (diff)
Fix divisibility check in DL_Group::make_dsa_generator
Diffstat (limited to 'src')
-rw-r--r--src/pubkey/dl_group/dl_group.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp
index a6bea3bbc..837d4ea82 100644
--- a/src/pubkey/dl_group/dl_group.cpp
+++ b/src/pubkey/dl_group/dl_group.cpp
@@ -320,13 +320,14 @@ void DL_Group::PEM_decode(const std::string& pem)
*/
BigInt DL_Group::make_dsa_generator(const BigInt& p, const BigInt& q)
{
- BigInt g, e = (p - 1) / q;
+ const BigInt e = (p - 1) / q;
- BOTAN_ASSERT(e > 0, "q divides p-1");
+ if(e == 0 || (p - 1) % q > 0)
+ throw std::invalid_argument("make_dsa_generator q does not divide p-1");
for(size_t i = 0; i != PRIME_TABLE_SIZE; ++i)
{
- g = power_mod(PRIMES[i], e, p);
+ BigInt g = power_mod(PRIMES[i], e, p);
if(g > 1)
return g;
}