diff options
author | lloyd <[email protected]> | 2008-06-20 11:39:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-06-20 11:39:33 +0000 |
commit | 770a9850f1a7c6c65b0316503b99798a6ff910dd (patch) | |
tree | 8e10281d15a1095b2151a1d1482898d75251589f /src | |
parent | 8f32a90b0aa6ab873c1d5337947e3642c640e3a4 (diff) |
Consolidate the two DH_PrivateKey constructors into a single one taking
a RNG reference, a group, and an (optional) private key. The public key
is now always rederived from the private.
Diffstat (limited to 'src')
-rw-r--r-- | src/dh.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/dh.cpp b/src/dh.cpp index 8367a3bce..159eb0629 100644 --- a/src/dh.cpp +++ b/src/dh.cpp @@ -47,28 +47,21 @@ MemoryVector<byte> DH_PublicKey::public_value() const /************************************************* * Create a DH private key * *************************************************/ -DH_PrivateKey::DH_PrivateKey(const DL_Group& grp, - RandomNumberGenerator& rng) +DH_PrivateKey::DH_PrivateKey(RandomNumberGenerator& rng, + const DL_Group& grp, + const BigInt& x_arg) { group = grp; - - const BigInt& p = group_p(); - x.randomize(rng, 2 * dl_work_factor(p.bits())); - - PKCS8_load_hook(rng, true); - } - -/************************************************* -* DH_PrivateKey Constructor * -*************************************************/ -DH_PrivateKey::DH_PrivateKey(const DL_Group& grp, const BigInt& x1, - const BigInt& y1) - { - group = grp; - y = y1; - x = x1; - - PKCS8_load_hook(global_state().prng_reference()); + x = x_arg; + + if(x == 0) + { + const BigInt& p = group_p(); + x.randomize(rng, 2 * dl_work_factor(p.bits())); + PKCS8_load_hook(rng, true); + } + else + PKCS8_load_hook(rng, false); } /************************************************* |