aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/pk_keys.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pubkey/pk_keys.cpp')
-rw-r--r--src/pubkey/pk_keys.cpp14
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
*/