aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/dl_algo
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-04 03:49:35 +0000
committerlloyd <[email protected]>2010-03-04 03:49:35 +0000
commitfe9aa5acece6c004f2c1c1aa4b23d7c44207672f (patch)
tree56bf2fc8378d965138e29074c23f645ed5d1a947 /src/pubkey/dl_algo
parentde89566f633d5ed807ca57a59cc1071f79fdded3 (diff)
Add similar decoding constructors to the private keys
Diffstat (limited to 'src/pubkey/dl_algo')
-rw-r--r--src/pubkey/dl_algo/dl_algo.cpp10
-rw-r--r--src/pubkey/dl_algo/dl_algo.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/src/pubkey/dl_algo/dl_algo.cpp b/src/pubkey/dl_algo/dl_algo.cpp
index 7ec6877e1..185e62cef 100644
--- a/src/pubkey/dl_algo/dl_algo.cpp
+++ b/src/pubkey/dl_algo/dl_algo.cpp
@@ -38,6 +38,16 @@ MemoryVector<byte> DL_Scheme_PrivateKey::pkcs8_private_key() const
return DER_Encoder().encode(x).get_contents();
}
+DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
+ const MemoryRegion<byte>& key_bits,
+ DL_Group::Format format)
+ {
+ DataSource_Memory source(alg_id.parameters);
+ group.BER_decode(source, format);
+
+ BER_Decoder(key_bits).decode(x);
+ }
+
/*
* Return the PKCS #8 private key decoder
*/
diff --git a/src/pubkey/dl_algo/dl_algo.h b/src/pubkey/dl_algo/dl_algo.h
index 66e6eafd0..59690a33a 100644
--- a/src/pubkey/dl_algo/dl_algo.h
+++ b/src/pubkey/dl_algo/dl_algo.h
@@ -91,6 +91,10 @@ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
MemoryVector<byte> pkcs8_private_key() const;
+ DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
+ const MemoryRegion<byte>& key_bits,
+ DL_Group::Format group_format);
+
/**
* Get an PKCS#8 decoder for this key.
* @param rng the rng to use
@@ -99,6 +103,7 @@ class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
*/
PKCS8_Decoder* pkcs8_decoder(RandomNumberGenerator& rng);
protected:
+ DL_Scheme_PrivateKey() {}
BigInt x;
private:
virtual void PKCS8_load_hook(RandomNumberGenerator&, bool = false) {}