aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pubkey/curve25519/curve25519.cpp16
-rw-r--r--src/lib/pubkey/curve25519/curve25519.h2
-rw-r--r--src/lib/pubkey/ed25519/ed25519.h2
-rw-r--r--src/lib/pubkey/ed25519/ed25519_key.cpp19
4 files changed, 14 insertions, 25 deletions
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp
index 8c8274efc..94970ef3f 100644
--- a/src/lib/pubkey/curve25519/curve25519.cpp
+++ b/src/lib/pubkey/curve25519/curve25519.cpp
@@ -81,24 +81,16 @@ Curve25519_PrivateKey::Curve25519_PrivateKey(RandomNumberGenerator& rng)
Curve25519_PrivateKey::Curve25519_PrivateKey(const AlgorithmIdentifier&,
const secure_vector<uint8_t>& key_bits)
{
- BER_Decoder(key_bits)
- .start_cons(SEQUENCE)
- .decode(m_public, OCTET_STRING)
- .decode(m_private, OCTET_STRING)
- .end_cons();
+ BER_Decoder(key_bits).decode(m_private, OCTET_STRING).discard_remaining();
- size_check(m_public.size(), "public key");
size_check(m_private.size(), "private key");
+ m_public.resize(32);
+ curve25519_basepoint(m_public.data(), m_private.data());
}
secure_vector<uint8_t> Curve25519_PrivateKey::private_key_bits() const
{
- return DER_Encoder()
- .start_cons(SEQUENCE)
- .encode(m_public, OCTET_STRING)
- .encode(m_private, OCTET_STRING)
- .end_cons()
- .get_contents();
+ return DER_Encoder().encode(m_private, OCTET_STRING).get_contents();
}
bool Curve25519_PrivateKey::check_key(RandomNumberGenerator&, bool) const
diff --git a/src/lib/pubkey/curve25519/curve25519.h b/src/lib/pubkey/curve25519/curve25519.h
index 567bb7008..da64113d5 100644
--- a/src/lib/pubkey/curve25519/curve25519.h
+++ b/src/lib/pubkey/curve25519/curve25519.h
@@ -76,7 +76,7 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey,
/**
* Construct a private key from the specified parameters.
- * @param secret_key DER encoded private key bits
+ * @param secret_key the private key
*/
explicit Curve25519_PrivateKey(const secure_vector<uint8_t>& secret_key);
diff --git a/src/lib/pubkey/ed25519/ed25519.h b/src/lib/pubkey/ed25519/ed25519.h
index f098517a0..360d92c16 100644
--- a/src/lib/pubkey/ed25519/ed25519.h
+++ b/src/lib/pubkey/ed25519/ed25519.h
@@ -82,7 +82,7 @@ class BOTAN_DLL Ed25519_PrivateKey : public Ed25519_PublicKey,
/**
* Construct a private key from the specified parameters.
- * @param secret_key DER encoded private key bits
+ * @param secret_key the private key
*/
explicit Ed25519_PrivateKey(const secure_vector<uint8_t>& secret_key);
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