diff options
author | lloyd <[email protected]> | 2007-03-03 23:42:58 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2007-03-03 23:42:58 +0000 |
commit | 9c99db0f0f8e61bb43bf51282aaf71e01cc05aa2 (patch) | |
tree | 4536c68bca96b5d87acb1089dc68635f37178edd /src/dl_group.cpp | |
parent | 2e08f75d02c3b08e6d8c983bae963f5709aa8311 (diff) |
Alter one of the constructors of DL_Group to take a parameter specifying
how big q should be.
Add FIPS 186-3 DSA parameter generation, this allows for generating larger
(2048 and 3072 bit) DSA keys. At this time there do not seem to be official
test vectors for 186-3, and I have not checked against other implementations.
Tests will be constructed using the latest OpenSSL snapshot.
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"); |