Skip to content

Commit 3e57580

Browse files
TLS ECH fixes [SNI, api.c, server.c, comments]
1 parent fad33e9 commit 3e57580

4 files changed

Lines changed: 13 additions & 8 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/tls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,8 @@ static int TLSX_SNI_Parse(WOLFSSL* ssl, const byte* input, word16 length,
23622362
#endif
23632363

23642364
#if defined(HAVE_ECH)
2365-
if (ech != NULL && ech->sniState == ECH_INNER_SNI_ATTEMPT) {
2365+
if (ech != NULL && ech->sniState == ECH_INNER_SNI_ATTEMPT &&
2366+
ech->privateName != NULL) {
23662367
matched = cacheOnly || (XSTRLEN(ech->privateName) == size &&
23672368
XSTRNCMP(ech->privateName, (const char*)input + offset, size) == 0);
23682369
}

tests/api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13506,7 +13506,6 @@ static int test_wolfSSL_CTX_add_client_CA(void)
1350613506
defined(HAVE_IO_TESTS_DEPENDENCIES)
1350713507
static THREAD_RETURN WOLFSSL_THREAD server_task_ech(void* args)
1350813508
{
13509-
EXPECT_DECLS;
1351013509
callback_functions* callbacks = ((func_args*)args)->callbacks;
1351113510
WOLFSSL_CTX* ctx = callbacks->ctx;
1351213511
WOLFSSL* ssl = NULL;
@@ -13536,7 +13535,7 @@ static THREAD_RETURN WOLFSSL_THREAD server_task_ech(void* args)
1353613535
if (callbacks->ctx_ready)
1353713536
callbacks->ctx_ready(ctx);
1353813537

13539-
ExpectNotNull(ssl = wolfSSL_new(ctx));
13538+
AssertNotNull(ssl = wolfSSL_new(ctx));
1354013539

1354113540
/* set the sni for the server */
1354213541
AssertIntEQ(WOLFSSL_SUCCESS,

wolfssl/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,9 +2979,9 @@ typedef struct Options Options;
29792979
#define TLSXT_CONNECTION_ID 0x0036
29802980
#define TLSXT_KEY_QUIC_TP_PARAMS 0x0039 /* RFC 9001, ch. 8.2 */
29812981
#define TLSXT_ECH 0xfe0d /* from */
2982-
/* draft-ietf-tls-esni-13 */
2982+
/* draft-ietf-tls-esni-25 */
29832983
#define TLSXT_ECH_OUTER_EXTENSIONS 0xfd00 /* from
2984-
draft-ietf-tls-esni-13 */
2984+
draft-ietf-tls-esni-25 */
29852985
/* The 0xFF section is experimental/custom/personal use */
29862986
#define TLSXT_CKS 0xff92 /* X9.146 */
29872987
#define TLSXT_RENEGOTIATION_INFO 0xff01

0 commit comments

Comments
 (0)