diff options
Diffstat (limited to 'src/dl_group.cpp')
-rw-r--r-- | src/dl_group.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/dl_group.cpp b/src/dl_group.cpp index 78a2952be..9d50458dd 100644 --- a/src/dl_group.cpp +++ b/src/dl_group.cpp @@ -35,7 +35,7 @@ DL_Group::DL_Group(const std::string& type) /************************************************* * DL_Group Constructor * *************************************************/ -DL_Group::DL_Group(u32bit pbits, PrimeType type) +DL_Group::DL_Group(PrimeType type, u32bit pbits, u32bit qbits) { if(pbits < 512) throw Invalid_Argument("DL_Group: prime size " + to_string(pbits) + @@ -51,7 +51,9 @@ DL_Group::DL_Group(u32bit pbits, PrimeType type) { if(type == Prime_Subgroup) { - const u32bit qbits = 2 * dl_work_factor(pbits); + if(!qbits) + qbits = 2 * dl_work_factor(pbits); + q = random_prime(qbits); BigInt X; while(p.bits() != pbits || !is_prime(p)) @@ -61,7 +63,10 @@ DL_Group::DL_Group(u32bit pbits, PrimeType type) } } else - generate_dsa_primes(p, q, pbits); + { + qbits = qbits ? qbits : ((pbits == 1024) ? 160 : 256); + generate_dsa_primes(p, q, pbits, qbits); + } g = make_dsa_generator(p, q); } @@ -72,9 +77,9 @@ DL_Group::DL_Group(u32bit pbits, PrimeType type) /************************************************* * DL_Group Constructor * *************************************************/ -DL_Group::DL_Group(const MemoryRegion<byte>& seed, u32bit pbits, u32bit start) +DL_Group::DL_Group(const MemoryRegion<byte>& seed, u32bit pbits, u32bit qbits) { - if(!generate_dsa_primes(p, q, seed.begin(), seed.size(), pbits, start)) + if(!generate_dsa_primes(p, q, pbits, qbits, seed)) throw Invalid_Argument("DL_Group: The seed/counter given does not " "generate a DSA group"); |