aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/dl_group/dl_group.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-26 17:10:02 +0000
committerlloyd <[email protected]>2010-09-26 17:10:02 +0000
commit3181cda998fc96868efc17b9630fdd5dceff9404 (patch)
tree556cb4ef134b1ed34c26ea1a08ebb1aba605b988 /src/pubkey/dl_group/dl_group.cpp
parentc820501357ac3acc81ddb8fad9fd9fd5fee9b32f (diff)
Use BOTAN_ASSERT in various places
Diffstat (limited to 'src/pubkey/dl_group/dl_group.cpp')
-rw-r--r--src/pubkey/dl_group/dl_group.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp
index d4e306ac3..d714bc154 100644
--- a/src/pubkey/dl_group/dl_group.cpp
+++ b/src/pubkey/dl_group/dl_group.cpp
@@ -14,6 +14,7 @@
#include <botan/pipe.h>
#include <botan/pem.h>
#include <botan/internal/workfactor.h>
+#include <botan/internal/assert.h>
namespace Botan {
@@ -312,23 +313,22 @@ void DL_Group::PEM_decode(DataSource& source)
}
/*
-* Create a random DSA-style generator
+* Create generator of the q-sized subgroup (DSA style generator)
*/
BigInt DL_Group::make_dsa_generator(const BigInt& p, const BigInt& q)
{
BigInt g, e = (p - 1) / q;
- for(u32bit j = 0; j != PRIME_TABLE_SIZE; ++j)
+ BOTAN_ASSERT(e > 0, "q does not divide p, invalid group");
+
+ for(u32bit i = 0; i != PRIME_TABLE_SIZE; ++i)
{
- g = power_mod(PRIMES[j], e, p);
- if(g != 1)
- break;
+ g = power_mod(PRIMES[i], e, p);
+ if(g > 1)
+ return g;
}
- if(g == 1)
- throw Internal_Error("DL_Group: Couldn't create a suitable generator");
-
- return g;
+ throw Internal_Error("DL_Group: Couldn't create a suitable generator");
}
}