diff options
author | Jack Lloyd <[email protected]> | 2016-10-21 11:25:53 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-10-21 16:54:43 -0400 |
commit | f44bd90a3ff9c2928eef825a0ff5394160b1a01c (patch) | |
tree | d5bec5ca3c501122c747fd492c8a16270135b935 /src/lib/tls/tls_extensions.cpp | |
parent | 6aa855bba613c7b6fedfbe71d15930964acb1633 (diff) |
X25519 key exchange for TLS
Client interops with google.com, server not tested against an
independent client yet.
Diffstat (limited to 'src/lib/tls/tls_extensions.cpp')
-rw-r--r-- | src/lib/tls/tls_extensions.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/lib/tls/tls_extensions.cpp b/src/lib/tls/tls_extensions.cpp index df265d915..a2db1faaf 100644 --- a/src/lib/tls/tls_extensions.cpp +++ b/src/lib/tls/tls_extensions.cpp @@ -293,6 +293,12 @@ std::string Supported_Elliptic_Curves::curve_id_to_name(u16bit id) return "brainpool384r1"; case 28: return "brainpool512r1"; + +#if defined(BOTAN_HAS_CURVE_25519) + case 29: + return "x25519"; +#endif + default: return ""; // something we don't know or support } @@ -313,7 +319,13 @@ u16bit Supported_Elliptic_Curves::name_to_curve_id(const std::string& name) if(name == "brainpool512r1") return 28; - throw Invalid_Argument("name_to_curve_id unknown name " + name); +#if defined(BOTAN_HAS_CURVE_25519) + if(name == "x25519") + return 29; +#endif + + // Unknown/unavailable EC curves are ignored + return 0; } std::vector<byte> Supported_Elliptic_Curves::serialize() const @@ -323,8 +335,12 @@ std::vector<byte> Supported_Elliptic_Curves::serialize() const for(size_t i = 0; i != m_curves.size(); ++i) { const u16bit id = name_to_curve_id(m_curves[i]); - buf.push_back(get_byte(0, id)); - buf.push_back(get_byte(1, id)); + + if(id > 0) + { + buf.push_back(get_byte(0, id)); + buf.push_back(get_byte(1, id)); + } } buf[0] = get_byte(0, static_cast<u16bit>(buf.size()-2)); |