@@ -5094,10 +5094,10 @@ static int EchCheckAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
50945094 ret = EchCalcAcceptance(ssl, label, labelSz, input, acceptOffset, helloSz,
50955095 msgType == hello_retry_request, acceptConfirmation);
50965096
5097- tmpHashes = ssl->hsHashes;
5098- ssl->hsHashes = ssl->hsHashesEch;
5099-
51005097 if (ret == 0) {
5098+ tmpHashes = ssl->hsHashes;
5099+ ssl->hsHashes = ssl->hsHashesEch;
5100+
51015101 /* last 8 bytes must match the expand output */
51025102 ret = ConstantCompare(acceptConfirmation, input + acceptOffset,
51035103 ECH_ACCEPT_CONFIRMATION_SZ);
@@ -5126,9 +5126,10 @@ static int EchCheckAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
51265126 FreeHandshakeHashes(ssl);
51275127 ssl->hsHashesEch = NULL;
51285128 }
5129+
5130+ ssl->hsHashes = tmpHashes;
51295131 }
51305132
5131- ssl->hsHashes = tmpHashes;
51325133 return ret;
51335134}
51345135#endif /* HAVE_ECH */
@@ -6806,25 +6807,28 @@ static int EchWriteAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
68066807 helloSz - headerSz, msgType == hello_retry_request,
68076808 output + acceptOffset);
68086809
6809- tmpHashes = ssl->hsHashes;
6810- ssl->hsHashes = ssl->hsHashesEch;
6810+ if (ret == 0) {
6811+ tmpHashes = ssl->hsHashes;
6812+ ssl->hsHashes = ssl->hsHashesEch;
68116813
6812- /* after HRR, hsHashesEch must contain:
6813- * message_hash(ClientHelloInner1) || HRR (actual, not zeros) */
6814- if (ret == 0 && msgType == hello_retry_request) {
6815- ret = HashRaw(ssl, output, helloSz);
6816- }
6817- /* normal TLS code will calculate transcript of ServerHello */
6818- else if (ret == 0) {
6819- ssl->options.echAccepted = 1;
6814+ /* after HRR, hsHashesEch must contain:
6815+ * message_hash(ClientHelloInner1) || HRR (actual, not zeros) */
6816+ if (msgType == hello_retry_request) {
6817+ ret = HashRaw(ssl, output, helloSz);
6818+ }
6819+ /* normal TLS code will calculate transcript of ServerHello */
6820+ else {
6821+ ssl->options.echAccepted = 1;
6822+
6823+ ssl->hsHashes = tmpHashes;
6824+ FreeHandshakeHashes(ssl);
6825+ tmpHashes = ssl->hsHashesEch;
6826+ ssl->hsHashesEch = NULL;
6827+ }
68206828
68216829 ssl->hsHashes = tmpHashes;
6822- FreeHandshakeHashes(ssl);
6823- tmpHashes = ssl->hsHashesEch;
6824- ssl->hsHashesEch = NULL;
68256830 }
68266831
6827- ssl->hsHashes = tmpHashes;
68286832 return ret;
68296833}
68306834#endif
0 commit comments