@@ -4054,7 +4054,6 @@ static int EchCalcAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
40544054#endif
40554055 return ret;
40564056}
4057-
40584057#endif
40594058
40604059#ifndef NO_WOLFSSL_CLIENT
@@ -5065,12 +5064,20 @@ static int Dtls13ClientDoDowngrade(WOLFSSL* ssl)
50655064#endif /* WOLFSSL_DTLS13 && !WOLFSSL_NO_CLIENT*/
50665065
50675066#if defined(HAVE_ECH)
5068- /* check if the server accepted ech or not, return status */
5067+ /* Calculate ECH acceptance and verify the server accepted ECH.
5068+ *
5069+ * ssl SSL/TLS object.
5070+ * label Ascii string describing ECH acceptance type.
5071+ * labelSz Length of label excluding NULL character.
5072+ * input The buffer to calculate confirmation off of.
5073+ * acceptOffset Where the 8 ECH confirmation bytes start.
5074+ * helloSz Size of hello message.
5075+ * returns 0 on success and otherwise failure.
5076+ */
50695077static int EchCheckAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
5070- const byte* input, int acceptOffset, int helloSz)
5078+ const byte* input, int acceptOffset, int helloSz, byte msgType )
50715079{
50725080 int ret = 0;
5073- int isHrr = 0;
50745081 int headerSz;
50755082 HS_Hashes* tmpHashes;
50765083 byte acceptConfirmation[ECH_ACCEPT_CONFIRMATION_SZ];
@@ -5084,13 +5091,8 @@ static int EchCheckAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
50845091 headerSz = HANDSHAKE_HEADER_SZ;
50855092#endif
50865093
5087- if (labelSz == ECH_HRR_ACCEPT_CONFIRMATION_LABEL_SZ &&
5088- XMEMCMP(label, echHrrAcceptConfirmationLabel, labelSz) == 0) {
5089- isHrr = 1;
5090- }
5091-
50925094 ret = EchCalcAcceptance(ssl, label, labelSz, input, acceptOffset, helloSz,
5093- isHrr , acceptConfirmation);
5095+ msgType == hello_retry_request , acceptConfirmation);
50945096
50955097 tmpHashes = ssl->hsHashes;
50965098 ssl->hsHashes = ssl->hsHashesEch;
@@ -5105,7 +5107,7 @@ static int EchCheckAcceptance(WOLFSSL* ssl, byte* label, word16 labelSz,
51055107
51065108 /* after HRR, hsHashesEch must contain:
51075109 * message_hash(ClientHelloInner1) || HRR (actual, not zeros) */
5108- if (isHrr ) {
5110+ if (msgType == hello_retry_request ) {
51095111 ret = HashRaw(ssl, input, helloSz + headerSz);
51105112 }
51115113 /* normal TLS code will calculate transcript of ServerHello */
@@ -5663,7 +5665,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
56635665 }
56645666
56655667#if defined(HAVE_ECH)
5666- /* check for acceptConfirmation, must be done after hashes restart */
5668+ /* check for acceptConfirmation */
56675669 if (ssl->echConfigs != NULL && !ssl->options.disableECH) {
56685670 args->echX = TLSX_Find(ssl->extensions, TLSX_ECH);
56695671 /* account for hrr extension instead of server random */
@@ -5680,7 +5682,8 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
56805682 /* check acceptance */
56815683 if (ret == 0) {
56825684 ret = EchCheckAcceptance(ssl, args->acceptLabel,
5683- args->acceptLabelSz, input, args->acceptOffset, helloSz);
5685+ args->acceptLabelSz, input, args->acceptOffset, helloSz,
5686+ args->extMsgType);
56845687 }
56855688 if (ret != 0)
56865689 return ret;
0 commit comments