diff options
author | lloyd <[email protected]> | 2010-06-14 23:58:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-06-14 23:58:40 +0000 |
commit | 0d26fdf3e03c7a34c33307352bcc27e79d493eb3 (patch) | |
tree | 27f94d81a8d8bc69d5f50b8cd110f643c79ccdc5 /src/pubkey/pk_keys.cpp | |
parent | 2c17c50fbf663ddc4bcef3c12540c3983b25925f (diff) |
Some PKCS #8 simplifications
Diffstat (limited to 'src/pubkey/pk_keys.cpp')
-rw-r--r-- | src/pubkey/pk_keys.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pubkey/pk_keys.cpp b/src/pubkey/pk_keys.cpp index b93158558..c7ca9673e 100644 --- a/src/pubkey/pk_keys.cpp +++ b/src/pubkey/pk_keys.cpp @@ -6,6 +6,7 @@ */ #include <botan/pk_keys.h> +#include <botan/der_enc.h> #include <botan/oids.h> namespace Botan { @@ -24,6 +25,19 @@ OID Public_Key::get_oid() const } } +SecureVector<byte> Private_Key::PKCS8_BER_encode() const + { + const u32bit PKCS8_VERSION = 0; + + return DER_Encoder() + .start_cons(SEQUENCE) + .encode(PKCS8_VERSION) + .encode(this->pkcs8_algorithm_identifier()) + .encode(this->pkcs8_private_key(), OCTET_STRING) + .end_cons() + .get_contents(); + } + /* * Run checks on a loaded public key */ |