diff options
author | lloyd <[email protected]> | 2012-01-24 15:10:14 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-01-24 15:10:14 +0000 |
commit | 9e37cd76af978147cbb36faa09b9832b5f15f20a (patch) | |
tree | 5a198928294a9bde7b7cf5eb43aa5f89e885c25a /src/tls/tls_server.cpp | |
parent | 92f6a575bca25d8985aa87304e28cd63867310e2 (diff) |
Send the supported elliptic curves extension. Instead of hardcoding
the values let policy specify them. Also choose an ECC curve for
server kex from the client hello. Choice is via policy, default
implementation is to choose the first curve the client supports out of
the server's preference list.
Diffstat (limited to 'src/tls/tls_server.cpp')
-rw-r--r-- | src/tls/tls_server.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tls/tls_server.cpp b/src/tls/tls_server.cpp index 47c62a96a..207d40990 100644 --- a/src/tls/tls_server.cpp +++ b/src/tls/tls_server.cpp @@ -265,7 +265,18 @@ void Server::process_handshake_msg(Handshake_Type type, state->kex_priv = new DH_PrivateKey(rng, policy.dh_group()); else if(kex_algo == "ECDH") { - EC_Group ec_group("secp256r1"); // FIXME, use client known groups + const std::vector<std::string>& curves = + state->client_hello->supported_ecc_curves(); + + if(curves.empty()) + throw Internal_Error("Client sent no ECC extension but we negotiated ECDH"); + + const std::string curve_name = policy.choose_curve(curves); + + if(curve_name == "") // shouldn't happen + throw Internal_Error("Could not agree on an ECC curve with the client"); + + EC_Group ec_group(curve_name); state->kex_priv = new ECDH_PrivateKey(rng, ec_group); } else |