@@ -5775,7 +5775,14 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
57755775 ) {
57765776 /* RFC 9147 Section 5.3 / RFC 9001 Section 8.4: DTLS 1.3 and QUIC
57775777 * ServerHello must have empty legacy_session_id_echo. */
5778- if (args->sessIdSz != 0) {
5778+ int requireEmptyEcho = 1;
5779+ #ifdef WOLFSSL_DTLS13_5_9_0_COMPAT
5780+ /* Compat: a wolfSSL <= 5.9.0 DTLS 1.3 server echoes the client's
5781+ * legacy_session_id; accept any echo. */
5782+ if (ssl->options.dtls)
5783+ requireEmptyEcho = 0;
5784+ #endif
5785+ if (requireEmptyEcho && args->sessIdSz != 0) {
57795786 WOLFSSL_MSG("args->sessIdSz != 0");
57805787 WOLFSSL_ERROR_VERBOSE(INVALID_PARAMETER);
57815788 return INVALID_PARAMETER;
@@ -6973,7 +6980,7 @@ static int RestartHandshakeHashWithCookie(WOLFSSL* ssl, Cookie* cookie)
69736980
69746981 /* Reconstruct the HelloRetryMessage for handshake hash. */
69756982 sessIdSz = ssl->session->sessionIDSz;
6976- #ifdef WOLFSSL_DTLS13
6983+ #if defined( WOLFSSL_DTLS13) && !defined(WOLFSSL_DTLS13_5_9_0_COMPAT)
69776984 /* RFC 9147 Section 5.3: DTLS 1.3 must use empty legacy_session_id. */
69786985 if (ssl->options.dtls)
69796986 sessIdSz = 0;
@@ -7453,7 +7460,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
74537460 if (sessIdSz + args->idx > helloSz)
74547461 ERROR_OUT(BUFFER_ERROR, exit_dch);
74557462
7456- #ifdef WOLFSSL_DTLS13
7463+ #if defined( WOLFSSL_DTLS13) && !defined(WOLFSSL_DTLS13_5_9_0_COMPAT)
74577464 /* RFC 9147 Section 5.3: DTLS 1.3 ServerHello must have empty
74587465 * legacy_session_id_echo. Don't store the client's value so it
74597466 * won't be echoed in SendTls13ServerHello. */
@@ -8058,7 +8065,7 @@ int SendTls13ServerHello(WOLFSSL* ssl, byte extMsgType)
80588065 WOLFSSL_BUFFER(ssl->arrays->serverRandom, RAN_LEN);
80598066#endif
80608067
8061- #ifdef WOLFSSL_DTLS13
8068+ #if defined( WOLFSSL_DTLS13) && !defined(WOLFSSL_DTLS13_5_9_0_COMPAT)
80628069 if (ssl->options.dtls) {
80638070 /* RFC 9147 Section 5.3: DTLS 1.3 ServerHello must have empty
80648071 * legacy_session_id_echo. */
0 commit comments