|
|
f4c0b8 |
diff --color -ruNp a/lib/ext/session_ticket.c b/lib/ext/session_ticket.c
|
|
|
f4c0b8 |
--- a/lib/ext/session_ticket.c 2022-05-10 13:55:00.000000000 +0200
|
|
|
f4c0b8 |
+++ b/lib/ext/session_ticket.c 2022-11-15 13:30:20.491830382 +0100
|
|
|
f4c0b8 |
@@ -624,6 +624,12 @@ gnutls_session_ticket_enable_server(gnut
|
|
|
f4c0b8 |
return 0;
|
|
|
f4c0b8 |
}
|
|
|
f4c0b8 |
|
|
|
f4c0b8 |
+void
|
|
|
f4c0b8 |
+_gnutls_session_ticket_disable_server(gnutls_session_t session)
|
|
|
f4c0b8 |
+{
|
|
|
f4c0b8 |
+ session->internals.flags |= GNUTLS_NO_TICKETS;
|
|
|
f4c0b8 |
+}
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
/*
|
|
|
f4c0b8 |
* Return zero if session tickets haven't been enabled.
|
|
|
f4c0b8 |
*/
|
|
|
f4c0b8 |
diff --color -ruNp a/lib/ext/session_ticket.h b/lib/ext/session_ticket.h
|
|
|
f4c0b8 |
--- a/lib/ext/session_ticket.h 2022-02-22 15:34:48.000000000 +0100
|
|
|
f4c0b8 |
+++ b/lib/ext/session_ticket.h 2022-11-15 13:30:20.491830382 +0100
|
|
|
f4c0b8 |
@@ -36,5 +36,6 @@ int _gnutls_encrypt_session_ticket(gnutl
|
|
|
f4c0b8 |
int _gnutls_decrypt_session_ticket(gnutls_session_t session,
|
|
|
f4c0b8 |
const gnutls_datum_t *ticket_data,
|
|
|
f4c0b8 |
gnutls_datum_t *state);
|
|
|
f4c0b8 |
+void _gnutls_session_ticket_disable_server(gnutls_session_t session);
|
|
|
f4c0b8 |
|
|
|
f4c0b8 |
#endif /* GNUTLS_LIB_EXT_SESSION_TICKET_H */
|
|
|
f4c0b8 |
diff --color -ruNp a/lib/libgnutls.map b/lib/libgnutls.map
|
|
|
f4c0b8 |
--- a/lib/libgnutls.map 2022-11-15 13:12:57.781688194 +0100
|
|
|
f4c0b8 |
+++ b/lib/libgnutls.map 2022-11-15 13:30:20.492830401 +0100
|
|
|
f4c0b8 |
@@ -1510,4 +1510,6 @@ GNUTLS_PRIVATE_3_4 {
|
|
|
f4c0b8 |
_gnutls_buffer_clear;
|
|
|
f4c0b8 |
# needed by tests/cipher-alignment
|
|
|
f4c0b8 |
_gnutls_crypto_register_cipher;
|
|
|
f4c0b8 |
+ # needed by tests/tls12-rehandshake-cert-ticket
|
|
|
f4c0b8 |
+ _gnutls_session_ticket_disable_server;
|
|
|
f4c0b8 |
} GNUTLS_3_4;
|
|
|
f4c0b8 |
diff --color -ruNp a/lib/state.c b/lib/state.c
|
|
|
f4c0b8 |
--- a/lib/state.c 2022-05-16 17:10:08.000000000 +0200
|
|
|
f4c0b8 |
+++ b/lib/state.c 2022-11-15 13:30:20.493830420 +0100
|
|
|
f4c0b8 |
@@ -545,6 +545,7 @@ void _gnutls_handshake_internal_state_cl
|
|
|
f4c0b8 |
session->internals.tfo.connect_addrlen = 0;
|
|
|
f4c0b8 |
session->internals.tfo.connect_only = 0;
|
|
|
f4c0b8 |
session->internals.early_data_received = 0;
|
|
|
f4c0b8 |
+ session->internals.session_ticket_renew = 0;
|
|
|
f4c0b8 |
}
|
|
|
f4c0b8 |
|
|
|
f4c0b8 |
/**
|
|
|
f4c0b8 |
diff --color -ruNp a/tests/Makefile.am b/tests/Makefile.am
|
|
|
f4c0b8 |
--- a/tests/Makefile.am 2022-11-15 13:12:58.209696462 +0100
|
|
|
f4c0b8 |
+++ b/tests/Makefile.am 2022-11-15 13:30:20.494830440 +0100
|
|
|
f4c0b8 |
@@ -234,7 +234,7 @@ ctests += mini-record-2 simple gnutls_hm
|
|
|
f4c0b8 |
set_x509_ocsp_multi_cli kdf-api keylog-func handshake-write \
|
|
|
f4c0b8 |
x509cert-dntypes id-on-xmppAddr tls13-compat-mode ciphersuite-name \
|
|
|
f4c0b8 |
x509-upnconstraint xts-key-check pkcs7-verify-double-free \
|
|
|
f4c0b8 |
- fips-rsa-sizes
|
|
|
f4c0b8 |
+ fips-rsa-sizes tls12-rehandshake-ticket
|
|
|
f4c0b8 |
|
|
|
f4c0b8 |
ctests += tls-channel-binding
|
|
|
f4c0b8 |
|
|
|
f4c0b8 |
diff --color -ruNp a/tests/tls12-rehandshake-ticket.c b/tests/tls12-rehandshake-ticket.c
|
|
|
f4c0b8 |
--- a/tests/tls12-rehandshake-ticket.c 1970-01-01 01:00:00.000000000 +0100
|
|
|
f4c0b8 |
+++ b/tests/tls12-rehandshake-ticket.c 2022-11-15 13:30:20.495830459 +0100
|
|
|
f4c0b8 |
@@ -0,0 +1,152 @@
|
|
|
f4c0b8 |
+/*
|
|
|
f4c0b8 |
+ * Copyright (C) 2022 Red Hat, Inc.
|
|
|
f4c0b8 |
+ *
|
|
|
f4c0b8 |
+ * Author: Daiki Ueno
|
|
|
f4c0b8 |
+ *
|
|
|
f4c0b8 |
+ * This file is part of GnuTLS.
|
|
|
f4c0b8 |
+ *
|
|
|
f4c0b8 |
+ * GnuTLS is free software; you can redistribute it and/or modify it
|
|
|
f4c0b8 |
+ * under the terms of the GNU General Public License as published by
|
|
|
f4c0b8 |
+ * the Free Software Foundation; either version 3 of the License, or
|
|
|
f4c0b8 |
+ * (at your option) any later version.
|
|
|
f4c0b8 |
+ *
|
|
|
f4c0b8 |
+ * GnuTLS is distributed in the hope that it will be useful, but
|
|
|
f4c0b8 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f4c0b8 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f4c0b8 |
+ * General Public License for more details.
|
|
|
f4c0b8 |
+ *
|
|
|
f4c0b8 |
+ * You should have received a copy of the GNU Lesser General Public License
|
|
|
f4c0b8 |
+ * along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
|
f4c0b8 |
+ */
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+#ifdef HAVE_CONFIG_H
|
|
|
f4c0b8 |
+#include <config.h>
|
|
|
f4c0b8 |
+#endif
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+#include <gnutls/gnutls.h>
|
|
|
f4c0b8 |
+#include <assert.h>
|
|
|
f4c0b8 |
+#include "cert-common.h"
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+#include "utils.h"
|
|
|
f4c0b8 |
+#include "eagain-common.h"
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+const char *side = "";
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+static void tls_log_func(int level, const char *str)
|
|
|
f4c0b8 |
+{
|
|
|
f4c0b8 |
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
|
|
|
f4c0b8 |
+}
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+#define MAX_BUF 1024
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+void _gnutls_session_ticket_disable_server(gnutls_session_t session);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+static void run(void)
|
|
|
f4c0b8 |
+{
|
|
|
f4c0b8 |
+ char buffer[MAX_BUF + 1];
|
|
|
f4c0b8 |
+ /* Server stuff. */
|
|
|
f4c0b8 |
+ gnutls_certificate_credentials_t scred;
|
|
|
f4c0b8 |
+ gnutls_session_t server;
|
|
|
f4c0b8 |
+ gnutls_datum_t session_ticket_key = { NULL, 0 };
|
|
|
f4c0b8 |
+ int sret;
|
|
|
f4c0b8 |
+ /* Client stuff. */
|
|
|
f4c0b8 |
+ gnutls_certificate_credentials_t ccred;
|
|
|
f4c0b8 |
+ gnutls_session_t client;
|
|
|
f4c0b8 |
+ int cret;
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ /* General init. */
|
|
|
f4c0b8 |
+ global_init();
|
|
|
f4c0b8 |
+ gnutls_global_set_log_function(tls_log_func);
|
|
|
f4c0b8 |
+ if (debug)
|
|
|
f4c0b8 |
+ gnutls_global_set_log_level(9);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ /* Init server */
|
|
|
f4c0b8 |
+ assert(gnutls_certificate_allocate_credentials(&scred) >= 0);
|
|
|
f4c0b8 |
+ assert(gnutls_certificate_set_x509_key_mem(scred,
|
|
|
f4c0b8 |
+ &server_ca3_localhost_cert,
|
|
|
f4c0b8 |
+ &server_ca3_key,
|
|
|
f4c0b8 |
+ GNUTLS_X509_FMT_PEM) >= 0);
|
|
|
f4c0b8 |
+ assert(gnutls_certificate_set_x509_trust_mem(scred,
|
|
|
f4c0b8 |
+ &ca3_cert,
|
|
|
f4c0b8 |
+ GNUTLS_X509_FMT_PEM) >= 0);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ assert(gnutls_init(&server, GNUTLS_SERVER) >= 0);
|
|
|
f4c0b8 |
+ gnutls_certificate_server_set_request(server, GNUTLS_CERT_REQUEST);
|
|
|
f4c0b8 |
+ assert(gnutls_priority_set_direct(server,
|
|
|
f4c0b8 |
+ "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.1:+VERS-TLS1.2",
|
|
|
f4c0b8 |
+ NULL) >= 0);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE, scred);
|
|
|
f4c0b8 |
+ gnutls_transport_set_push_function(server, server_push);
|
|
|
f4c0b8 |
+ gnutls_transport_set_pull_function(server, server_pull);
|
|
|
f4c0b8 |
+ gnutls_transport_set_ptr(server, server);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_session_ticket_key_generate(&session_ticket_key);
|
|
|
f4c0b8 |
+ gnutls_session_ticket_enable_server(server, &session_ticket_key);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ /* Init client */
|
|
|
f4c0b8 |
+ assert(gnutls_certificate_allocate_credentials(&ccred) >= 0);
|
|
|
f4c0b8 |
+ assert(gnutls_certificate_set_x509_key_mem
|
|
|
f4c0b8 |
+ (ccred, &cli_ca3_cert_chain, &cli_ca3_key, GNUTLS_X509_FMT_PEM) >= 0);
|
|
|
f4c0b8 |
+ assert(gnutls_certificate_set_x509_trust_mem
|
|
|
f4c0b8 |
+ (ccred, &ca3_cert, GNUTLS_X509_FMT_PEM) >= 0);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_init(&client, GNUTLS_CLIENT);
|
|
|
f4c0b8 |
+ assert(gnutls_priority_set_direct(client,
|
|
|
f4c0b8 |
+ "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.1:+VERS-TLS1.2",
|
|
|
f4c0b8 |
+ NULL) >= 0);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ assert(gnutls_credentials_set(client, GNUTLS_CRD_CERTIFICATE, ccred) >= 0);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_transport_set_push_function(client, client_push);
|
|
|
f4c0b8 |
+ gnutls_transport_set_pull_function(client, client_pull);
|
|
|
f4c0b8 |
+ gnutls_transport_set_ptr(client, client);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ HANDSHAKE(client, server);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ /* Server initiates rehandshake */
|
|
|
f4c0b8 |
+ switch_side("server");
|
|
|
f4c0b8 |
+ sret = gnutls_rehandshake(server);
|
|
|
f4c0b8 |
+ if (sret < 0) {
|
|
|
f4c0b8 |
+ fail("Error sending %d byte packet: %s\n",
|
|
|
f4c0b8 |
+ (int)sizeof(buffer), gnutls_strerror(sret));
|
|
|
f4c0b8 |
+ } else if (debug)
|
|
|
f4c0b8 |
+ success("server: starting rehandshake\n");
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ /* Stop sending session ticket */
|
|
|
f4c0b8 |
+ _gnutls_session_ticket_disable_server(server);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ /* Client gets notified with rehandshake */
|
|
|
f4c0b8 |
+ switch_side("client");
|
|
|
f4c0b8 |
+ do {
|
|
|
f4c0b8 |
+ do {
|
|
|
f4c0b8 |
+ cret = gnutls_record_recv(client, buffer, MAX_BUF);
|
|
|
f4c0b8 |
+ } while (cret == GNUTLS_E_AGAIN || cret == GNUTLS_E_INTERRUPTED);
|
|
|
f4c0b8 |
+ } while (cret > 0);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ if (cret != GNUTLS_E_REHANDSHAKE) {
|
|
|
f4c0b8 |
+ fail("client: Error receiving rehandshake: %s\n",
|
|
|
f4c0b8 |
+ gnutls_strerror(cret));
|
|
|
f4c0b8 |
+ }
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ HANDSHAKE(client, server);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_bye(client, GNUTLS_SHUT_WR);
|
|
|
f4c0b8 |
+ gnutls_bye(server, GNUTLS_SHUT_WR);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_deinit(client);
|
|
|
f4c0b8 |
+ gnutls_deinit(server);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_certificate_free_credentials(scred);
|
|
|
f4c0b8 |
+ gnutls_certificate_free_credentials(ccred);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_free(session_ticket_key.data);
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+ gnutls_global_deinit();
|
|
|
f4c0b8 |
+ reset_buffers();
|
|
|
f4c0b8 |
+}
|
|
|
f4c0b8 |
+
|
|
|
f4c0b8 |
+void doit(void)
|
|
|
f4c0b8 |
+{
|
|
|
f4c0b8 |
+ run();
|
|
|
f4c0b8 |
+}
|