Skip to content

Commit 528b221

Browse files
revert PR 9909
1 parent b02ddde commit 528b221

5 files changed

Lines changed: 12 additions & 84 deletions

File tree

src/tls.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7384,7 +7384,7 @@ int TLSX_Cookie_Use(const WOLFSSL* ssl, const byte* data, word16 len, byte* mac,
73847384

73857385
#else
73867386

7387-
#define CKE_FREE_ALL(a, b) WC_DO_NOTHING
7387+
#define CKE_FREE_ALL(a, b) 0
73887388
#define CKE_GET_SIZE(a, b, c) 0
73897389
#define CKE_WRITE(a, b, c, d) 0
73907390
#define CKE_PARSE(a, b, c, d) 0
@@ -13892,10 +13892,12 @@ void TLSX_FreeAll(TLSX* list, void* heap)
1389213892
WOLFSSL_MSG("Supported Versions extension free");
1389313893
break;
1389413894

13895+
#ifdef WOLFSSL_SEND_HRR_COOKIE
1389513896
case TLSX_COOKIE:
1389613897
WOLFSSL_MSG("Cookie extension free");
1389713898
CKE_FREE_ALL((Cookie*)extension->data, heap);
1389813899
break;
13900+
#endif
1389913901

1390013902
#ifdef WOLFSSL_EARLY_DATA
1390113903
case TLSX_EARLY_DATA:
@@ -14087,9 +14089,11 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType,
1408714089
ret = SV_GET_SIZE(extension->data, msgType, &length);
1408814090
break;
1408914091

14092+
#ifdef WOLFSSL_SEND_HRR_COOKIE
1409014093
case TLSX_COOKIE:
1409114094
ret = CKE_GET_SIZE((Cookie*)extension->data, msgType, &length);
1409214095
break;
14096+
#endif
1409314097

1409414098
#ifdef WOLFSSL_EARLY_DATA
1409514099
case TLSX_EARLY_DATA:
@@ -14320,11 +14324,13 @@ static int TLSX_Write(TLSX* list, byte* output, byte* semaphore,
1432014324
&offset);
1432114325
break;
1432214326

14327+
#ifdef WOLFSSL_SEND_HRR_COOKIE
1432314328
case TLSX_COOKIE:
1432414329
WOLFSSL_MSG("Cookie extension to write");
1432514330
ret = CKE_WRITE((Cookie*)extension->data, output + offset,
1432614331
msgType, &offset);
1432714332
break;
14333+
#endif
1432814334

1432914335
#ifdef WOLFSSL_EARLY_DATA
1433014336
case TLSX_EARLY_DATA:
@@ -16626,6 +16632,7 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
1662616632
break;
1662716633

1662816634

16635+
#ifdef WOLFSSL_SEND_HRR_COOKIE
1662916636
case TLSX_COOKIE:
1663016637
WOLFSSL_MSG("Cookie extension received");
1663116638
#ifdef WOLFSSL_DEBUG_TLS
@@ -16641,6 +16648,7 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
1664116648

1664216649
ret = CKE_PARSE(ssl, input + offset, size, msgType);
1664316650
break;
16651+
#endif
1664416652

1664516653
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
1664616654
case TLSX_PRE_SHARED_KEY:
@@ -16880,16 +16888,6 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
1688016888
#endif
1688116889
default:
1688216890
WOLFSSL_MSG("Unknown TLS extension type");
16883-
#if defined(WOLFSSL_TLS13)
16884-
/* RFC 8446 4.2: for TLS 1.3 server-to-client messages, the
16885-
* client MUST abort with unsupported_extension upon receiving
16886-
* an extension that was not advertised in the ClientHello. */
16887-
if (IsAtLeastTLSv1_3(ssl->version) && !isRequest) {
16888-
SendAlert((WOLFSSL*)ssl, alert_fatal, unsupported_extension);
16889-
WOLFSSL_ERROR_VERBOSE(UNSUPPORTED_EXTENSION);
16890-
return UNSUPPORTED_EXTENSION;
16891-
}
16892-
#endif
1689316891
}
1689416892

1689516893
/* offset should be updated here! */

tests/api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30340,8 +30340,7 @@ static int test_TLSX_CA_NAMES_bad_extension(void)
3034030340

3034130341
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
3034230342
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
30343-
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1),
30344-
WC_NO_ERR_TRACE(UNSUPPORTED_EXTENSION));
30343+
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WC_NO_ERR_TRACE(EXT_MISSING));
3034530344
#else
3034630345
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WC_NO_ERR_TRACE(BUFFER_ERROR));
3034730346
#endif

tests/api/test_tls13.c

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,75 +3162,6 @@ int test_tls13_warning_alert_is_fatal(void)
31623162
return EXPECT_RESULT();
31633163
}
31643164

3165-
/* Test that an unknown extension in a TLS 1.3 server-to-client message is
3166-
* rejected with unsupported_extension (RFC 8446 4.2). The client MUST abort
3167-
* the handshake when it receives an extension it did not advertise.
3168-
*/
3169-
int test_tls13_unknown_ext_rejected(void)
3170-
{
3171-
EXPECT_DECLS;
3172-
#if defined(WOLFSSL_TLS13) && defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
3173-
!defined(NO_WOLFSSL_CLIENT) && defined(WOLFSSL_AES_128) && \
3174-
defined(HAVE_AESGCM) && !defined(NO_SHA256) && \
3175-
!defined(WOLFSSL_TLS13_MIDDLEBOX_COMPAT)
3176-
WOLFSSL_CTX *ctx_c = NULL;
3177-
WOLFSSL *ssl_c = NULL;
3178-
struct test_memio_ctx test_ctx;
3179-
/* HelloRetryRequest carrying TLS_AES_128_GCM_SHA256, supported_versions
3180-
* (TLS 1.3), and an extra unknown extension type 0xFABC.
3181-
*
3182-
* The base HRR (from test_tls13_same_ch) extended with 4 bytes:
3183-
* extensions length: 6 -> 10 (0x00,0x0a)
3184-
* handshake body length: 46 -> 50 (0x00,0x00,0x32)
3185-
* record body length: 50 -> 54 (0x00,0x36)
3186-
* appended: 0xfa,0xbc,0x00,0x00 (unknown type, zero-length value)
3187-
*/
3188-
static const unsigned char hrr_unknown_ext[] = {
3189-
/* TLS record header: handshake, TLS 1.2 compat, len=54 */
3190-
0x16, 0x03, 0x03, 0x00, 0x36,
3191-
/* Handshake header: ServerHello, len=50 */
3192-
0x02, 0x00, 0x00, 0x32,
3193-
/* legacy_version: TLS 1.2 */
3194-
0x03, 0x03,
3195-
/* HelloRetryRequest magic random */
3196-
0xcf, 0x21, 0xad, 0x74, 0xe5, 0x9a, 0x61, 0x11,
3197-
0xbe, 0x1d, 0x8c, 0x02, 0x1e, 0x65, 0xb8, 0x91,
3198-
0xc2, 0xa2, 0x11, 0x16, 0x7a, 0xbb, 0x8c, 0x5e,
3199-
0x07, 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c,
3200-
/* session ID length: 0 */
3201-
0x00,
3202-
/* cipher suite: TLS_AES_128_GCM_SHA256 */
3203-
0x13, 0x01,
3204-
/* compression: null */
3205-
0x00,
3206-
/* extensions length: 10 */
3207-
0x00, 0x0a,
3208-
/* supported_versions: TLS 1.3 (0x0304) */
3209-
0x00, 0x2b, 0x00, 0x02, 0x03, 0x04,
3210-
/* unknown extension type 0xFABC, zero-length value */
3211-
0xfa, 0xbc, 0x00, 0x00
3212-
};
3213-
3214-
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
3215-
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, NULL, &ssl_c, NULL,
3216-
wolfTLSv1_3_client_method, NULL), 0);
3217-
3218-
/* Inject the crafted HRR before the client starts the handshake.
3219-
* wolfSSL_connect will send the ClientHello and then read this message. */
3220-
ExpectIntEQ(test_memio_inject_message(&test_ctx, 1,
3221-
(const char *)hrr_unknown_ext, sizeof(hrr_unknown_ext)), 0);
3222-
3223-
/* RFC 8446 4.2: the client MUST abort with unsupported_extension. */
3224-
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
3225-
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1),
3226-
WC_NO_ERR_TRACE(UNSUPPORTED_EXTENSION));
3227-
3228-
wolfSSL_free(ssl_c);
3229-
wolfSSL_CTX_free(ctx_c);
3230-
#endif
3231-
return EXPECT_RESULT();
3232-
}
3233-
32343165
/* Test that wolfSSL_set1_sigalgs_list() is honored in TLS 1.3
32353166
*/
32363167
int test_tls13_cert_req_sigalgs(void)

tests/api/test_tls13.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ int test_key_share_mismatch(void);
3939
int test_tls13_middlebox_compat_empty_session_id(void);
4040
int test_tls13_plaintext_alert(void);
4141
int test_tls13_warning_alert_is_fatal(void);
42-
int test_tls13_unknown_ext_rejected(void);
4342
int test_tls13_cert_req_sigalgs(void);
4443
int test_tls13_derive_keys_no_key(void);
4544

@@ -59,7 +58,6 @@ int test_tls13_derive_keys_no_key(void);
5958
TEST_DECL_GROUP("tls13", test_tls13_middlebox_compat_empty_session_id), \
6059
TEST_DECL_GROUP("tls13", test_tls13_plaintext_alert), \
6160
TEST_DECL_GROUP("tls13", test_tls13_warning_alert_is_fatal), \
62-
TEST_DECL_GROUP("tls13", test_tls13_unknown_ext_rejected), \
6361
TEST_DECL_GROUP("tls13", test_tls13_cert_req_sigalgs), \
6462
TEST_DECL_GROUP("tls13", test_tls13_derive_keys_no_key)
6563

wolfssl/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,7 +3012,9 @@ typedef enum {
30123012
TLSX_EARLY_DATA = TLSXT_EARLY_DATA,
30133013
#endif
30143014
TLSX_SUPPORTED_VERSIONS = TLSXT_SUPPORTED_VERSIONS,
3015+
#ifdef WOLFSSL_SEND_HRR_COOKIE
30153016
TLSX_COOKIE = TLSXT_COOKIE,
3017+
#endif
30163018
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
30173019
TLSX_PSK_KEY_EXCHANGE_MODES = TLSXT_PSK_KEY_EXCHANGE_MODES,
30183020
#endif

0 commit comments

Comments
 (0)