Skip to content

Commit e17ac41

Browse files
TLS ECH fixes [SNI, api.c, server.c, comments]
1 parent 58625d1 commit e17ac41

5 files changed

Lines changed: 14 additions & 13 deletions

File tree

examples/server/server.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3105,6 +3105,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
31053105
byte echConfig[512];
31063106
word32 echConfigLen = sizeof(echConfig);
31073107
char echConfigBase64[512];
3108+
char* echConfigBase64Ptr;
31083109
word32 echConfigBase64Len = sizeof(echConfigBase64);
31093110

31103111
if (wolfSSL_CTX_GenerateEchConfig(ctx, echPublicName, 0, 0, 0)
@@ -3116,12 +3117,16 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
31163117
err_sys_ex(runWithErrors, "GetEchConfigs failed");
31173118
}
31183119
if (Base64_Encode_NoNl(echConfig, echConfigLen, (byte*)echConfigBase64,
3119-
&echConfigBase64Len) != 0) {
3120+
&echConfigBase64Len) != 0) {
31203121
err_sys_ex(runWithErrors, "Base64_Encode_NoNl failed");
31213122
}
31223123
else {
3123-
echConfigBase64[echConfigBase64Len] = '\0';
3124-
printf("ECH config (base64): %s\n", echConfigBase64);
3124+
echConfigBase64Ptr = echConfigBase64;
3125+
printf("ECH config (base64): ");
3126+
while (echConfigBase64Len-- > 0) {
3127+
printf("%c", *echConfigBase64Ptr++);
3128+
}
3129+
printf("\n");
31253130
}
31263131
}
31273132
#endif

src/ssl_ech.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ int wolfSSL_CTX_GenerateEchConfig(WOLFSSL_CTX* ctx, const char* publicName,
6767
XMEMSET(newConfig, 0, sizeof(WOLFSSL_EchConfig));
6868

6969
/* set random configId */
70-
/* TODO: if an equal configId is found should the old config be removed from
71-
* the LL? Prevents growth beyond 255+ items */
7270
if (ret == 0)
7371
ret = wc_RNG_GenerateByte(rng, &newConfig->configId);
7472

src/tls.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,12 +2381,13 @@ static int TLSX_SNI_Parse(WOLFSSL* ssl, const byte* input, word16 length,
23812381
/* Don't process the second ClientHello SNI extension if there
23822382
* was problems with the first.
23832383
*/
2384-
if (!cacheOnly && sni->status != WOLFSSL_SNI_NO_MATCH)
2384+
if (!cacheOnly && sni != NULL && sni->status != WOLFSSL_SNI_NO_MATCH)
23852385
return 0;
23862386
#endif
23872387

23882388
#if defined(HAVE_ECH)
2389-
if (ech != NULL && ech->sniState == ECH_INNER_SNI_ATTEMPT) {
2389+
if (ech != NULL && ech->sniState == ECH_INNER_SNI_ATTEMPT &&
2390+
ech->privateName != NULL) {
23902391
matched = cacheOnly || (XSTRLEN(ech->privateName) == size &&
23912392
XSTRNCMP(ech->privateName, (const char*)input + offset, size) == 0);
23922393
}

tests/api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13790,7 +13790,6 @@ static int test_wolfSSL_CTX_add_client_CA(void)
1379013790
defined(HAVE_IO_TESTS_DEPENDENCIES)
1379113791
static THREAD_RETURN WOLFSSL_THREAD server_task_ech(void* args)
1379213792
{
13793-
EXPECT_DECLS;
1379413793
callback_functions* callbacks = ((func_args*)args)->callbacks;
1379513794
WOLFSSL_CTX* ctx = callbacks->ctx;
1379613795
WOLFSSL* ssl = NULL;
@@ -13820,7 +13819,7 @@ static THREAD_RETURN WOLFSSL_THREAD server_task_ech(void* args)
1382013819
if (callbacks->ctx_ready)
1382113820
callbacks->ctx_ready(ctx);
1382213821

13823-
ExpectNotNull(ssl = wolfSSL_new(ctx));
13822+
AssertNotNull(ssl = wolfSSL_new(ctx));
1382413823

1382513824
/* set the sni for the server */
1382613825
AssertIntEQ(WOLFSSL_SUCCESS,

wolfssl/internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,10 +2972,8 @@ typedef struct Options Options;
29722972
#define TLSXT_KEY_SHARE 0x0033
29732973
#define TLSXT_CONNECTION_ID 0x0036
29742974
#define TLSXT_KEY_QUIC_TP_PARAMS 0x0039 /* RFC 9001, ch. 8.2 */
2975-
#define TLSXT_ECH 0xfe0d /* from */
2976-
/* draft-ietf-tls-esni-13 */
2977-
#define TLSXT_ECH_OUTER_EXTENSIONS 0xfd00 /* from
2978-
draft-ietf-tls-esni-13 */
2975+
#define TLSXT_ECH 0xfe0d /* RFC 9849 */
2976+
#define TLSXT_ECH_OUTER_EXTENSIONS 0xfd00 /* RFC 9849 */
29792977
/* The 0xFF section is experimental/custom/personal use */
29802978
#define TLSXT_CKS 0xff92 /* X9.146 */
29812979
#define TLSXT_RENEGOTIATION_INFO 0xff01

0 commit comments

Comments
 (0)