aboutsummaryrefslogtreecommitdiffstats
path: root/src/dsa.cpp
diff options
context:
space:
mode:
authorlloyd <lloyd@randombit.net>2008-06-20 19:03:45 +0000
committerlloyd <lloyd@randombit.net>2008-06-20 19:03:45 +0000
commit7dde81851bfb6cef78c3480acc2f1c1dedb1f126 (patch)
tree06f35288c9c08b9f77468c664dbf8a65aaaf2647 /src/dsa.cpp
parent770a9850f1a7c6c65b0316503b99798a6ff910dd (diff)
Similiar combining transform for the ElGamal, DSA, and NR private key
constructors.
Diffstat (limited to 'src/dsa.cpp')
-rw-r--r--src/dsa.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/dsa.cpp b/src/dsa.cpp
index e53ba0766..8ca2f7db5 100644
--- a/src/dsa.cpp
+++ b/src/dsa.cpp
@@ -57,26 +57,20 @@ u32bit DSA_PublicKey::message_part_size() const
/*************************************************
* Create a DSA private key *
*************************************************/
-DSA_PrivateKey::DSA_PrivateKey(const DL_Group& grp,
- RandomNumberGenerator& rng)
+DSA_PrivateKey::DSA_PrivateKey(RandomNumberGenerator& rng,
+ const DL_Group& grp,
+ const BigInt& x_arg)
{
group = grp;
- x = random_integer(rng, 2, group_q() - 1);
+ x = x_arg;
- PKCS8_load_hook(rng, true);
- }
-
-/*************************************************
-* DSA_PrivateKey Constructor *
-*************************************************/
-DSA_PrivateKey::DSA_PrivateKey(const DL_Group& grp, const BigInt& x1,
- const BigInt& y1)
- {
- group = grp;
- y = y1;
- x = x1;
-
- PKCS8_load_hook(global_state().prng_reference());
+ if(x == 0)
+ {
+ x = random_integer(rng, 2, group_q() - 1);
+ PKCS8_load_hook(rng, true);
+ }
+ else
+ PKCS8_load_hook(rng, false);
}
/*************************************************
@@ -85,8 +79,7 @@ DSA_PrivateKey::DSA_PrivateKey(const DL_Group& grp, const BigInt& x1,
void DSA_PrivateKey::PKCS8_load_hook(RandomNumberGenerator& rng,
bool generated)
{
- if(y == 0)
- y = power_mod(group_g(), x, group_p());
+ y = power_mod(group_g(), x, group_p());
core = DSA_Core(group, y, x);
if(generated)