Skip to content

Commit 93acd46

Browse files
authored
Merge pull request #6805 from jpbland1/ech-hello-retry
Ech hello retry request
2 parents 517f4bd + c48b4f2 commit 93acd46

9 files changed

Lines changed: 673 additions & 440 deletions

File tree

src/internal.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7298,7 +7298,7 @@ int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
72987298

72997299
/* save the original so we can put it back afterward */
73007300
tmpHashes = ssl->hsHashes;
7301-
ssl->hsHashes = NULL;
7301+
ssl->hsHashes = *destination;
73027302

73037303
ret = InitHandshakeHashes(ssl);
73047304
if (ret != 0) {
@@ -8435,6 +8435,13 @@ void wolfSSL_ResourceFree(WOLFSSL* ssl)
84358435
}
84368436
FreeSuites(ssl);
84378437
FreeHandshakeHashes(ssl);
8438+
#ifdef HAVE_ECH
8439+
/* try to free the ech hashes in case we errored out */
8440+
ssl->hsHashes = ssl->hsHashesEch;
8441+
FreeHandshakeHashes(ssl);
8442+
ssl->hsHashes = ssl->hsHashesEchInner;
8443+
FreeHandshakeHashes(ssl);
8444+
#endif
84388445
XFREE(ssl->buffers.domainName.buffer, ssl->heap, DYNAMIC_TYPE_DOMAIN);
84398446

84408447
/* clear keys struct after session */
@@ -8448,9 +8455,6 @@ void wolfSSL_ResourceFree(WOLFSSL* ssl)
84488455
if (ssl->options.useEch == 1) {
84498456
FreeEchConfigs(ssl->echConfigs, ssl->heap);
84508457
ssl->echConfigs = NULL;
8451-
/* free the ech specific hashes */
8452-
ssl->hsHashes = ssl->hsHashesEch;
8453-
FreeHandshakeHashes(ssl);
84548458
ssl->options.useEch = 0;
84558459
}
84568460
#endif /* HAVE_ECH */

src/ssl.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ int wolfSSL_SetEchConfigsBase64(WOLFSSL* ssl, char* echConfigs64,
556556
/* set the ech config from a raw buffer, this is the format ech configs are
557557
* sent using retry_configs from the ech server */
558558
int wolfSSL_SetEchConfigs(WOLFSSL* ssl, const byte* echConfigs,
559-
word32 echConfigsLen)
559+
word32 echConfigsLen)
560560
{
561561
int ret = 0;
562562
int i;
@@ -683,16 +683,17 @@ int wolfSSL_SetEchConfigs(WOLFSSL* ssl, const byte* echConfigs,
683683
&workingConfig->cipherSuites[j].aeadId);
684684
}
685685
echConfig += cipherSuitesLen;
686+
/* ignore the maximum name length */
687+
echConfig++;
686688
/* publicNameLen */
687-
ato16(echConfig, &publicNameLen);
689+
publicNameLen = *(echConfig);
688690
workingConfig->publicName = (char*)XMALLOC(publicNameLen + 1,
689691
ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
690692
if (workingConfig->publicName == NULL) {
691693
ret = MEMORY_E;
692694
break;
693695
}
694-
695-
echConfig += 2;
696+
echConfig++;
696697
/* publicName */
697698
XMEMCPY(workingConfig->publicName, echConfig, publicNameLen);
698699
/* null terminated */
@@ -869,9 +870,13 @@ int GetEchConfig(WOLFSSL_EchConfig* config, byte* output, word32* outputLen)
869870
output += 2;
870871
}
871872

873+
/* set maximum name length to 0 */
874+
*output = 0;
875+
output++;
876+
872877
/* publicName len */
873-
c16toa(XSTRLEN(config->publicName), output);
874-
output += 2;
878+
*output = XSTRLEN(config->publicName);
879+
output++;
875880

876881
/* publicName */
877882
XMEMCPY(output, config->publicName,

0 commit comments

Comments
 (0)