diff options
author | lloyd <[email protected]> | 2010-03-04 02:15:10 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-04 02:15:10 +0000 |
commit | bc66f1dc8ace6b81c486392422d3302afd674f37 (patch) | |
tree | ed273b76330fc371a17eb142196efb0c0222d547 /src/pubkey/ecc_key/ecc_key.cpp | |
parent | c58d02b152b11bae78985aa441560f49ef6b5d09 (diff) |
Add a pkcs8_private_key similiar to x509_subject_public_key
Diffstat (limited to 'src/pubkey/ecc_key/ecc_key.cpp')
-rw-r--r-- | src/pubkey/ecc_key/ecc_key.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp index f91f394dc..b09ddfdb7 100644 --- a/src/pubkey/ecc_key/ecc_key.cpp +++ b/src/pubkey/ecc_key/ecc_key.cpp @@ -137,6 +137,17 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng, } } +MemoryVector<byte> EC_PrivateKey::pkcs8_private_key() const + { + return DER_Encoder() + .start_cons(SEQUENCE) + .encode(BigInt(1)) + .encode(BigInt::encode_1363(private_key, private_key.bytes()), + OCTET_STRING) + .end_cons() + .get_contents(); + } + /** * Return the PKCS #8 public key encoder **/ @@ -152,13 +163,7 @@ PKCS8_Encoder* EC_PrivateKey::pkcs8_encoder() const MemoryVector<byte> key_bits() const { - return DER_Encoder() - .start_cons(SEQUENCE) - .encode(BigInt(1)) - .encode(BigInt::encode_1363(key->private_key, key->private_key.bytes()), - OCTET_STRING) - .end_cons() - .get_contents(); + return key->pkcs8_private_key(); } EC_Key_Encoder(const EC_PrivateKey* k): key(k) {} |