summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-18 11:31:52 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-18 11:56:30 +0200
commit6f62adb1ce12262111a9fdcb2a75040d5c23c3cb (patch)
treec6e119ba2ffc9cdbcb4c52ad88d2befe0726cec6 /lib
parentaa86ea26580aafacfe2a338078587a47d15d01ad (diff)
downloadgnutls-6f62adb1ce12262111a9fdcb2a75040d5c23c3cb.tar.gz
gnutls_session_get_flags: introduced GNUTLS_SFLAGS_RFC7919
This allows checking whether the DHE parameters used were negotiated using RFC7919. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/auth/dh_common.c11
-rw-r--r--lib/dh.c2
-rw-r--r--lib/gnutls_int.h1
-rw-r--r--lib/includes/gnutls/gnutls.h.in4
-rw-r--r--lib/state.c2
5 files changed, 14 insertions, 6 deletions
diff --git a/lib/auth/dh_common.c b/lib/auth/dh_common.c
index df57747183..6d6a7e5648 100644
--- a/lib/auth/dh_common.c
+++ b/lib/auth/dh_common.c
@@ -188,8 +188,9 @@ _gnutls_proc_dh_common_server_kx(gnutls_session_t session,
int i, bits, ret, p_bits;
unsigned j;
ssize_t data_size = _data_size;
- unsigned used_ffdhe = 0;
-
+
+ session->internals.used_ffdhe = 0;
+
/* just in case we are resuming a session */
gnutls_pk_params_release(&session->key.dh_params);
@@ -242,14 +243,14 @@ _gnutls_proc_dh_common_server_kx(gnutls_session_t session,
memcmp(session->internals.priorities->groups.entry[j]->prime->data,
data_p, n_p) == 0) {
- used_ffdhe = 1;
+ session->internals.used_ffdhe = 1;
_gnutls_session_group_set(session, session->internals.priorities->groups.entry[j]);
session->key.dh_params.qbits = *session->internals.priorities->groups.entry[j]->q_bits;
break;
}
}
- if (!used_ffdhe) {
+ if (!session->internals.used_ffdhe) {
_gnutls_audit_log(session, "FFDHE groups advertised, but server didn't support it; falling back to server's choice\n");
}
}
@@ -269,7 +270,7 @@ _gnutls_proc_dh_common_server_kx(gnutls_session_t session,
session->key.dh_params.params_nr = 3; /* include empty q */
session->key.dh_params.algo = GNUTLS_PK_DH;
- if (used_ffdhe == 0) {
+ if (session->internals.used_ffdhe == 0) {
bits = _gnutls_dh_get_min_prime_bits(session);
if (bits < 0) {
gnutls_assert();
diff --git a/lib/dh.c b/lib/dh.c
index 4686736946..c8e84680f9 100644
--- a/lib/dh.c
+++ b/lib/dh.c
@@ -79,6 +79,7 @@ _gnutls_figure_dh_params(gnutls_session_t session, gnutls_dh_params_t dh_params,
group = get_group(session);
params.deinit = 0;
+ session->internals.used_ffdhe = 0;
/* if we negotiated RFC7919 FFDHE */
if (group && group->pk == GNUTLS_PK_DH) {
@@ -100,6 +101,7 @@ _gnutls_figure_dh_params(gnutls_session_t session, gnutls_dh_params_t dh_params,
goto cleanup;
}
+ session->internals.used_ffdhe = 1;
q_bits = *session->internals.priorities->groups.entry[i]->q_bits;
goto finished;
}
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index c0e0d7eed7..76e64083b2 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -1115,6 +1115,7 @@ typedef struct {
/* whether the peer has advertized at least an FFDHE group */
bool have_ffdhe;
+ bool used_ffdhe; /* whether ffdhe was actually negotiated and used */
/* candidate groups to be selected for security params groups */
const gnutls_group_entry_st *cand_ec_group;
diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in
index fd6f063cc4..6c92600de6 100644
--- a/lib/includes/gnutls/gnutls.h.in
+++ b/lib/includes/gnutls/gnutls.h.in
@@ -1294,6 +1294,7 @@ unsigned gnutls_session_etm_status(gnutls_session_t session);
* @GNUTLS_SFLAGS_SAFE_RENEGOTIATION: Safe renegotiation (RFC5746) was used
* @GNUTLS_SFLAGS_EXT_MASTER_SECRET: The extended master secret (RFC7627) extension was used
* @GNUTLS_SFLAGS_ETM: The encrypt then MAC (RFC7366) extension was used
+ * @GNUTLS_SFLAGS_RFC7919: The RFC7919 Diffie-Hellman parameters were negotiated
* @GNUTLS_SFLAGS_HB_LOCAL_SEND: The heartbeat negotiation allows the local side to send heartbeat messages
* @GNUTLS_SFLAGS_HB_PEER_SEND: The heartbeat negotiation allows the peer to send heartbeat messages
* @GNUTLS_SFLAGS_FALSE_START: The appdata set with gnutls_handshake_set_appdata() were sent during handshake (false start)
@@ -1306,7 +1307,8 @@ typedef enum {
GNUTLS_SFLAGS_ETM = 1<<2,
GNUTLS_SFLAGS_HB_LOCAL_SEND = 1<<3,
GNUTLS_SFLAGS_HB_PEER_SEND = 1<<4,
- GNUTLS_SFLAGS_FALSE_START = 1<<5
+ GNUTLS_SFLAGS_FALSE_START = 1<<5,
+ GNUTLS_SFLAGS_RFC7919 = 1<<6
} gnutls_session_flags_t;
unsigned gnutls_session_get_flags(gnutls_session_t session);
diff --git a/lib/state.c b/lib/state.c
index edcabeba96..1551fa9794 100644
--- a/lib/state.c
+++ b/lib/state.c
@@ -1266,6 +1266,8 @@ unsigned gnutls_session_get_flags(gnutls_session_t session)
flags |= GNUTLS_SFLAGS_HB_PEER_SEND;
if (session->internals.false_start_used)
flags |= GNUTLS_SFLAGS_FALSE_START;
+ if (session->internals.used_ffdhe)
+ flags |= GNUTLS_SFLAGS_RFC7919;
return flags;
}