diff options
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)); |