aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ed25519/ed25519_key.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/ed25519/ed25519_key.cpp')
-rw-r--r--src/lib/pubkey/ed25519/ed25519_key.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lib/pubkey/ed25519/ed25519_key.cpp b/src/lib/pubkey/ed25519/ed25519_key.cpp
index c16b44b6f..18bfb51d7 100644
--- a/src/lib/pubkey/ed25519/ed25519_key.cpp
+++ b/src/lib/pubkey/ed25519/ed25519_key.cpp
@@ -69,23 +69,20 @@ Ed25519_PrivateKey::Ed25519_PrivateKey(RandomNumberGenerator& rng)
Ed25519_PrivateKey::Ed25519_PrivateKey(const AlgorithmIdentifier&,
const secure_vector<uint8_t>& key_bits)
{
- BER_Decoder(key_bits)
- .start_cons(SEQUENCE)
- .decode(m_private, OCTET_STRING)
- .end_cons();
+ secure_vector<uint8_t> bits;
+ BER_Decoder(key_bits).decode(bits, OCTET_STRING).discard_remaining();
- if(m_private.size() != 64)
+ if(bits.size() != 32)
throw Decoding_Error("Invalid size for Ed25519 private key");
- m_public.assign(&m_private[32], &m_private[64]);
+ m_public.resize(32);
+ m_private.resize(64);
+ ed25519_gen_keypair(m_public.data(), m_private.data(), bits.data());
}
secure_vector<uint8_t> Ed25519_PrivateKey::private_key_bits() const
{
- return DER_Encoder()
- .start_cons(SEQUENCE)
- .encode(m_private, OCTET_STRING)
- .end_cons()
- .get_contents();
+ secure_vector<uint8_t> bits(&m_private[0], &m_private[32]);
+ return DER_Encoder().encode(bits, OCTET_STRING).get_contents();
}
bool Ed25519_PrivateKey::check_key(RandomNumberGenerator&, bool) const