aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/mce
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-22 11:04:15 -0400
committerJack Lloyd <[email protected]>2018-05-22 11:04:15 -0400
commit3789138906cecbcc5e33bb0d5784e6b576171080 (patch)
tree147c442020bec8ad6effe62727fdb6b300d0f7f7 /src/lib/pubkey/mce
parentcd0bcd90817ece3e4fcba32e06a372580bbe3008 (diff)
DER improvements
Let DER_Encoder write to a user specified vector instead of only to an internal vector. This allows encoding to a std::vector without having to first write to a locked vector and then copying out the result. Add ASN1_Object::BER_encode convenience method. Replaces X509_Object::BER_encode which had the same logic but was restricted to a subtype. This replaces many cases where DER_Encoder was just used to encode a single object (X509_DN, AlgorithmIdentifier, etc).
Diffstat (limited to 'src/lib/pubkey/mce')
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index 67ff8f635..4fe78d2a1 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -72,15 +72,16 @@ AlgorithmIdentifier McEliece_PublicKey::algorithm_identifier() const
std::vector<uint8_t> McEliece_PublicKey::public_key_bits() const
{
- return DER_Encoder()
+ std::vector<uint8_t> output;
+ DER_Encoder(output)
.start_cons(SEQUENCE)
.start_cons(SEQUENCE)
.encode(static_cast<size_t>(get_code_length()))
.encode(static_cast<size_t>(get_t()))
.end_cons()
.encode(m_public_matrix, OCTET_STRING)
- .end_cons()
- .get_contents_unlocked();
+ .end_cons();
+ return output;
}
size_t McEliece_PublicKey::key_length() const