diff options
author | lloyd <[email protected]> | 2010-03-04 16:53:24 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-04 16:53:24 +0000 |
commit | e63bcc23c6121245c143b7b026127ebf0be55c22 (patch) | |
tree | f177b24a648fff3715cd332fba4b13f36912348e /src/pubkey | |
parent | 634e6a30f066f64caa28be36d29c556f9edae8e1 (diff) |
Remove DH_PrivateKey::PKCS8_load_hook
Diffstat (limited to 'src/pubkey')
-rw-r--r-- | src/pubkey/dh/dh.cpp | 25 | ||||
-rw-r--r-- | src/pubkey/dh/dh.h | 13 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/pubkey/dh/dh.cpp b/src/pubkey/dh/dh.cpp index baaa31126..31510bced 100644 --- a/src/pubkey/dh/dh.cpp +++ b/src/pubkey/dh/dh.cpp @@ -58,26 +58,33 @@ DH_PrivateKey::DH_PrivateKey(RandomNumberGenerator& rng, { const BigInt& p = group_p(); x.randomize(rng, 2 * dl_work_factor(p.bits())); - PKCS8_load_hook(rng, true); } + + if(y == 0) + y = power_mod(group_g(), x, group_p()); + + core = DH_Core(rng, group, x); + + if(x == 0) + gen_check(rng); else - PKCS8_load_hook(rng, false); + load_check(rng); } /* -* Algorithm Specific PKCS #8 Initialization Code +* Load a DH private key */ -void DH_PrivateKey::PKCS8_load_hook(RandomNumberGenerator& rng, - bool generated) +DH_PrivateKey::DH_PrivateKey(const AlgorithmIdentifier& alg_id, + const MemoryRegion<byte>& key_bits, + RandomNumberGenerator& rng) : + DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42) { if(y == 0) y = power_mod(group_g(), x, group_p()); + core = DH_Core(rng, group, x); - if(generated) - gen_check(rng); - else - load_check(rng); + load_check(rng); } /* diff --git a/src/pubkey/dh/dh.h b/src/pubkey/dh/dh.h index 638553db4..2a7f21fbb 100644 --- a/src/pubkey/dh/dh.h +++ b/src/pubkey/dh/dh.h @@ -57,13 +57,15 @@ class BOTAN_DLL DH_PrivateKey : public DH_PublicKey, MemoryVector<byte> public_value() const; + /** + * Load a DH private key + * @param alg_id the algorithm id + * @param key_bits the subject public key + * @rng a random number generator + */ DH_PrivateKey(const AlgorithmIdentifier& alg_id, const MemoryRegion<byte>& key_bits, - RandomNumberGenerator& rng) : - DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42) - { - PKCS8_load_hook(rng); - } + RandomNumberGenerator& rng); /** * Construct a private key with predetermined value. @@ -74,7 +76,6 @@ class BOTAN_DLL DH_PrivateKey : public DH_PublicKey, DH_PrivateKey(RandomNumberGenerator& rng, const DL_Group& grp, const BigInt& x = 0); private: - void PKCS8_load_hook(RandomNumberGenerator& rng, bool = false); DH_Core core; }; |