]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Fix non-empty session id (TLS13_APPENDIX_D4)
authorNorbert Pocs <npocs@redhat.com>
Fri, 30 Oct 2020 16:18:30 +0000 (17:18 +0100)
committerNorbert Pocs <npocs@redhat.com>
Tue, 8 Dec 2020 14:24:54 +0000 (15:24 +0100)
When TLS1.3 is used with middlebox compatible mode, the session id should be filled with random session id,
but remained empty.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Closes #1074

lib/handshake.c
tests/tls13/prf-early.c
tests/tls13/prf.c
tests/tlsext-decoding.c

index ce2d160e2077c6d971de58e63ec86b9b035af853..52bb20bfe220e87df3e4c5a8ec0aeb5b642e0364 100644 (file)
@@ -2211,6 +2211,7 @@ static int send_client_hello(gnutls_session_t session, int again)
                        goto cleanup;
                }
 
+               uint8_t *resumed_session_id = session->internals.resumed_security_parameters.session_id;
 #ifdef TLS13_APPENDIX_D4
                if (max_ver->tls13_sem &&
                    session->security_parameters.session_id_size == 0) {
@@ -2225,13 +2226,15 @@ static int send_client_hello(gnutls_session_t session, int again)
                                gnutls_assert();
                                goto cleanup;
                        }
+                       resumed_session_id = session->security_parameters.session_id;
+                       session_id_len = session->security_parameters.session_id_size;
                }
 #endif
 
                /* Copy the Session ID - if any
                 */
                ret = _gnutls_buffer_append_data_prefix(&extdata, 8,
-                                                       session->internals.resumed_security_parameters.session_id,
+                                                       resumed_session_id,
                                                        session_id_len);
                if (ret < 0) {
                        gnutls_assert();
index bc3196248fc24d0d00bafcab08f055c439e8e5ec..51dd7a3f76cba92adee8209bd5d8b9b4382ccda0 100644 (file)
@@ -123,10 +123,10 @@ static void dump(const char *name, const uint8_t *data, unsigned data_size)
        } \
        }
 
-#define KEY_EXP_VALUE "\xc1\x6b\x6c\xb9\x88\x33\xd5\x28\x80\xec\x27\x87\xa2\x6f\x4b\xd0\x01\x5e\x7f\xca\xd7\xd4\x8a\x3f\xe2\x48\x92\xef\x02\x14\xfb\x81\x90\x04"
-#define HELLO_VALUE "\x2a\x73\xd9\x74\x04\x4e\x0a\x5f\x41\x8a\x09\xcb\x45\x33\x1a\xec\xd3\xfc\xdc\x1b\x2c\x67\x26\xe4\x9c\xfe\x1f\xa5\x74\xf1\x4f"
-#define CONTEXT_VALUE "\x87\xf6\x88\xe3\xd7\xf2\x05\xbc\xa4\x10\xa3\x48\x9f\xf5\xcf\x97\x06\x22\x4e\xfd\x18\x32\x52\x1d\xbd\x26\xf5\x5b\x21\x20\xec"
-#define NULL_CONTEXT_VALUE "\xf9\xca\xfe\x45\x44\x96\xdb\xc5\x41\x8f\x7e\x8e\xd7\xb0\x7d\x19\x45\xaf\x09\xbc\x1e\x82\x94\xac\x55\xe5\xb9\xb4\x3b\xe8\xc0"
+#define KEY_EXP_VALUE "\x7f\x9a\x62\x64\x5e\x90\xa4\x19\x6f\xbf\x7b\x4e\x98\x63\x29\xb0\x46\xa2\x2a\x47\x94\x6a\x78\xdc\x6e\xea\x90\x13\x9d\xd4\xd1\x20\x02\x04"
+#define HELLO_VALUE "\x38\x40\x8c\x0d\x53\xe5\xd2\xe8\x66\xb4\x46\xce\x32\x85\xd5\x02\x3a\x4f\x81\x3c\x9e\x1b\x4a\x53\x73\x22\xad\xf2\x11\xc6\x45"
+#define CONTEXT_VALUE "\xf6\x95\x60\x0d\x51\x9e\x1a\x40\xb2\x9e\xb0\x48\x55\xfe\x64\xf8\xa0\x26\x31\xd8\xb1\x66\xf3\x10\x62\x32\x26\x52\x9e\x63\x49"
+#define NULL_CONTEXT_VALUE "\xb1\x80\x8c\xb3\xc2\xa9\x06\x88\xb7\xc2\xed\xd4\x5f\x1c\xad\x0b\xb2\x1f\xa9\xe2\xc6\x37\xd3\x52\x73\x1b\xf5\x3b\x92\x61\x08"
 
 static int handshake_callback_called;
 
index c9c9f80b7bce261e3bde4abde58f821dc21cc241..e03544a0426f0b0918aaa2322f824fc9f0c07341 100644 (file)
@@ -130,10 +130,10 @@ static void dump(const char *name, const uint8_t *data, unsigned data_size)
        } \
        }
 
-#define KEY_EXP_VALUE "\xec\x26\x9e\x8c\x5f\xff\x5c\xb2\x60\x4f\x82\xe7\x6b\xb9\x70\x40\xb9\x2d\x2f\xe7\x41\xa8\xe7\xfa\x03\x7c\xe8\x6d\xfa\xda\xc2\xa9\x3f\x58"
-#define HELLO_VALUE "\xd4\x74\x4a\x09\x28\x0a\x99\xb9\xa4\x5b\x51\x5b\x80\xe7\x50\x1c\x16\xca\x57\x78\xf0\xe5\xa1\x94\x6b\x20\x2b\x14\xff\x2b\x53"
-#define CONTEXT_VALUE "\x8d\xde\xea\x58\xab\x90\xaf\x6c\x5c\x7a\x69\xbf\x8a\xd2\x16\xb4\x0f\x75\xb8\x63\xdb\x86\xe7\x66\x04\x59\xac\x57\xe0\x03\x37"
-#define NULL_CONTEXT_VALUE "\x6c\x1a\x10\x1f\xa9\x5a\xfd\xcd\xf4\xcf\x27\x09\x00\xa8\xca\x8e\x8a\x56\xfb\x80\xf0\x0d\xb3\xa6\xe9\x4a\x5f\xe0\x0c\x31\xd9"
+#define KEY_EXP_VALUE "\x28\x70\xa8\x34\xd4\x43\x85\xfd\x55\xe0\x13\x78\x75\xa3\x25\xa7\xfd\x0b\x6b\x68\x5d\x62\x72\x02\xdf\x3d\x79\xca\x55\xab\xea\x24\xf3\x4d"
+#define HELLO_VALUE "\xd8\xcb\x72\x1e\x24\x2d\x79\x11\x41\x38\x05\x2b\x1b\x5d\x60\x12\x30\x0a\xf7\x1e\x23\x90\x4d\x64\xf8\xf5\x23\xea\xbf\xa3\x24"
+#define CONTEXT_VALUE "\xe6\xc0\x57\xbe\xda\x28\x9c\xc7\xf6\x4f\xb6\x18\x92\xce\x10\xf6\xe1\x5e\xab\x10\xc8\xd1\x94\xf8\xac\xc7\x3e\x93\xde\x57\x12"
+#define NULL_CONTEXT_VALUE "\xaf\xea\xd2\x64\xc9\x42\xbd\xe7\xdb\xf0\xd3\x16\x84\x39\xf3\xdb\x5d\x4f\x0e\x5e\x71\x1e\xc0\xd7\x23\xde\x8b\x1e\x80\xa1\xca"
 static void check_prfs(gnutls_session_t session)
 {
        unsigned char key_material[512];
index 1a36c669f0a09189ac6d780e93a97a94006801da..a397ee55fba3fac23260a6660f750a92ee45d6d8 100644 (file)
@@ -70,7 +70,7 @@ static void client_log_func(int level, const char *str)
 }
 
 #define RECORD_PAYLOAD_POS 5
-#define HANDSHAKE_CS_POS (39)
+#define HANDSHAKE_ID_POS (38)
 static ssize_t odd_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
 {
        uint8_t *d = (void*)data;
@@ -79,15 +79,21 @@ static ssize_t odd_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
        int pos;
 
        if (d[0] == 22 && d[5] == GNUTLS_HANDSHAKE_CLIENT_HELLO) {
+               uint8_t isize;
+
+               /* skip session ID (this can be non-empty in TLS 1.3) */
+               isize = d[RECORD_PAYLOAD_POS+HANDSHAKE_ID_POS];
+               isize += 1;
+
                /* skip ciphersuites */
-               csize = d[RECORD_PAYLOAD_POS+HANDSHAKE_CS_POS+1] + (d[RECORD_PAYLOAD_POS+HANDSHAKE_CS_POS] << 8);
+               csize = d[RECORD_PAYLOAD_POS+HANDSHAKE_ID_POS+isize+1] + (d[RECORD_PAYLOAD_POS+HANDSHAKE_ID_POS+isize] << 8);
                csize += 2;
 
                /* skip compression methods */
-               osize = d[RECORD_PAYLOAD_POS+HANDSHAKE_CS_POS+csize];
+               osize = d[RECORD_PAYLOAD_POS+HANDSHAKE_ID_POS+isize+csize];
                osize += 1;
 
-               pos = RECORD_PAYLOAD_POS+HANDSHAKE_CS_POS+csize+osize;
+               pos = RECORD_PAYLOAD_POS+HANDSHAKE_ID_POS+isize+csize+osize;
 
                if (reduce) {
                        if (d[pos+1] != 0x00) {