summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2018-06-19 13:08:27 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-06-20 08:22:13 +0200
commit171227f3463a29ac4f037f821fbbeb8e097cac39 (patch)
tree56a970a9f6c877b2e3f2ef159093325ba83e4f3a
parent6a5cff38810ca9eb36ac586d2fe37e3140d0ce43 (diff)
downloadgnutls-171227f3463a29ac4f037f821fbbeb8e097cac39.tar.gz
tests: verify that resumed session ID matches original
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--tests/resume.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/resume.c b/tests/resume.c
index 482af8e271..891a209313 100644
--- a/tests/resume.c
+++ b/tests/resume.c
@@ -316,6 +316,8 @@ static void verify_group(gnutls_session_t session, gnutls_group_t *group, unsign
static void verify_server_params(gnutls_session_t session, unsigned counter, struct params_res *params)
{
+ static char id[GNUTLS_MAX_SESSION_ID];
+ static size_t id_size = 0;
#if defined(USE_PSK)
const char *username;
username = gnutls_psk_server_get_username(session);
@@ -342,6 +344,31 @@ static void verify_server_params(gnutls_session_t session, unsigned counter, str
}
#endif
+ /* verify whether the session ID remains the same between sessions */
+ if (counter == 0) {
+ id_size = sizeof(id);
+ assert(gnutls_session_get_id(session, id, &id_size) >= 0);
+ } else {
+ char id2[GNUTLS_MAX_SESSION_ID];
+ size_t id2_size = sizeof(id2);
+
+ if (params->enable_session_ticket_client && params->enable_session_ticket_server)
+ goto finish;
+
+ if (id_size == 0)
+ fail("no session ID was set\n");
+
+ assert(gnutls_session_get_id(session, id2, &id2_size) >= 0);
+
+ if (id_size != id2_size || memcmp(id, id2, id_size) != 0) {
+ hexprint(id, id_size);
+ printf("\n");
+ hexprint(id2, id2_size);
+ fail("resumed session ID does not match original\n");
+ }
+ }
+
+ finish:
return;
}