diff options
author | Jack Lloyd <[email protected]> | 2016-10-24 12:38:42 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-10-24 12:38:42 -0400 |
commit | 055a0bb4344f48397225acf903e8c21df2ffd724 (patch) | |
tree | 6778f0b5b19bc5bbf3ef7b58ce5214f49a3bc6c6 /src/lib/pubkey | |
parent | bd663dbc98f35d45558db53f34b104f28ade0ddf (diff) | |
parent | f44bd90a3ff9c2928eef825a0ff5394160b1a01c (diff) |
Merge GH #673 X25519 TLS key exchange
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.cpp | 7 | ||||
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.h | 15 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/pubkey/curve25519/curve25519.cpp b/src/lib/pubkey/curve25519/curve25519.cpp index 02ee516de..4a072e648 100644 --- a/src/lib/pubkey/curve25519/curve25519.cpp +++ b/src/lib/pubkey/curve25519/curve25519.cpp @@ -29,10 +29,13 @@ secure_vector<byte> curve25519(const secure_vector<byte>& secret, return out; } -secure_vector<byte> curve25519_basepoint(const secure_vector<byte>& secret) +std::vector<byte> curve25519_basepoint(const secure_vector<byte>& secret) { const byte basepoint[32] = { 9 }; - return curve25519(secret, basepoint); + std::vector<byte> out(32); + const int rc = curve25519_donna(out.data(), secret.data(), basepoint); + BOTAN_ASSERT_EQUAL(rc, 0, "Return value of curve25519_donna is ok"); + return out; } } diff --git a/src/lib/pubkey/curve25519/curve25519.h b/src/lib/pubkey/curve25519/curve25519.h index 476db80d1..03d274e0b 100644 --- a/src/lib/pubkey/curve25519/curve25519.h +++ b/src/lib/pubkey/curve25519/curve25519.h @@ -27,7 +27,7 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key std::vector<byte> x509_subject_public_key() const override; - std::vector<byte> public_value() const { return unlock(m_public); } + std::vector<byte> public_value() const { return m_public; } /** * Create a Curve25519 Public Key. @@ -39,13 +39,20 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key /** * Create a Curve25519 Public Key. - * @param pub DER encoded public key bits + * @param pub 32-byte raw public key */ - explicit Curve25519_PublicKey(const secure_vector<byte>& pub) : m_public(pub) {} + explicit Curve25519_PublicKey(const std::vector<byte>& pub) : m_public(pub) {} + + /** + * Create a Curve25519 Public Key. + * @param pub 32-byte raw public key + */ + explicit Curve25519_PublicKey(const secure_vector<byte>& pub) : + m_public(pub.begin(), pub.end()) {} protected: Curve25519_PublicKey() {} - secure_vector<byte> m_public; + std::vector<byte> m_public; }; class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey, |