]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Set a default supported curve
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 2 Aug 2017 15:25:17 +0000 (17:25 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 2 Aug 2017 15:25:17 +0000 (17:25 +0200)
RFC4492 and draft-ietf-tls-rfc4492bis-17 mention:
"A client that proposes ECC cipher suites may choose not to include these
extensions.  In this case, the server is free to choose any one of
the elliptic curves or point formats listed in Section 5."

As such, we set a default curve to be used in the case the
server encounters a handshake with no supported groups/curves
extension.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
lib/algorithms/ciphersuites.c
lib/gnutls_int.h

index 141597d92a1932040b250cc36a3bd9c389b2d9b4..ae5dba1c09b8f314fda5f5ac85d1120eba32afc6 100644 (file)
@@ -1411,6 +1411,15 @@ _gnutls_figure_common_ciphersuite(gnutls_session_t session,
                return gnutls_assert_val(GNUTLS_E_NO_CIPHER_SUITES);
        }
 
+       /* If we didn't receive the supported_groups extension, then
+        * we should assume that SECP256R1 is supported; that is required
+        * by RFC4492, probably to allow SSLv2 hellos negotiate elliptic curve
+        * ciphersuites */
+       if (session->internals.cand_ec_group == NULL &&
+           _gnutls_extension_list_check(session, GNUTLS_EXTENSION_SUPPORTED_ECC) < 0) {
+               session->internals.cand_ec_group = _gnutls_id_to_group(DEFAULT_EC_GROUP);
+       }
+
        if (session->internals.priorities->server_precedence == 0) {
                for (i = 0; i < peer_clist->size; i++) {
                        _gnutls_debug_log("checking %.2x.%.2x (%s) for compatibility\n",
index 86745a9c286feb653deb83f35657a60b76f7b0e5..fa00ad234d48cedd630c506040c0cf8670a4a95b 100644 (file)
@@ -148,6 +148,10 @@ typedef struct {
 #define DEFAULT_EXPIRE_TIME 3600
 #define DEFAULT_HANDSHAKE_TIMEOUT_MS 40*1000
 
+/* The EC group to be used when the extension
+ * supported groups/curves is not present */
+#define DEFAULT_EC_GROUP GNUTLS_GROUP_SECP256R1
+
 typedef enum transport_t {
        GNUTLS_STREAM,
        GNUTLS_DGRAM
@@ -1098,10 +1102,6 @@ typedef struct {
        struct extension_entry_st *rexts;
        unsigned rexts_size;
 
-       /* In case of a client holds the extensions we sent to the peer;
-        * otherwise the extensions we received from the client.
-        */
-
        struct {
                uint16_t type;
                gnutls_ext_priv_data_t priv;
@@ -1110,6 +1110,9 @@ typedef struct {
                bool resumed_set;
        } ext_data[MAX_EXT_TYPES];
 
+       /* In case of a client holds the extensions we sent to the peer;
+        * otherwise the extensions we received from the client.
+        */
        const struct extension_entry_st *used_exts[MAX_EXT_TYPES];
        unsigned used_exts_size;