|
72 | 72 | * (no ciphersuite requires it currently) |
73 | 73 | * WOLFSSL_ERROR_CODE_OPENSSL: Use OpenSSL-compatible error codes default: off |
74 | 74 | * WOLFSSL_SSLKEYLOGFILE_OUTPUT: Set key log output file path default: off |
| 75 | + * WOLFSSL_SSLKEYLOGFILE_USE_ENV: Use SSLKEYLOGFILE env var path default: off |
75 | 76 | * WOLFSSL_RW_THREADED: Enable read/write threading support default: off |
76 | 77 | * WOLFSSL_ASYNC_IO: Enable async I/O operations default: off |
77 | 78 | * WOLFSSL_NONBLOCK_OCSP: Non-blocking OCSP processing default: off |
@@ -6004,12 +6005,12 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, |
6004 | 6005 | #endif |
6005 | 6006 | #ifdef WOLFSSL_CERT_WITH_EXTERN_PSK |
6006 | 6007 | if (ssl->options.certWithExternPsk && psk->resumption) { |
6007 | | - /* RFC8773bis mode requires external PSK, not ticket resumption. */ |
| 6008 | + /* RFC 9973 mode requires external PSK, not ticket resumption. */ |
6008 | 6009 | WOLFSSL_ERROR_VERBOSE(PSK_KEY_ERROR); |
6009 | 6010 | return PSK_KEY_ERROR; |
6010 | 6011 | } |
6011 | 6012 | if (ssl->options.certWithExternPsk && ssl->options.shSentKeyShare == 0) { |
6012 | | - /* RFC8773bis Sec. 3: cert_with_extern_psk requires psk_dhe_ke; |
| 6013 | + /* RFC 9973 Sect. 3: cert_with_extern_psk requires psk_dhe_ke; |
6013 | 6014 | * a ServerHello without a key_share confirms only psk_ke. */ |
6014 | 6015 | WOLFSSL_MSG("cert_with_extern_psk: ServerHello missing key_share"); |
6015 | 6016 | WOLFSSL_ERROR_VERBOSE(EXT_MISSING); |
@@ -6244,8 +6245,10 @@ static int DoTls13CertificateRequest(WOLFSSL* ssl, const byte* input, |
6244 | 6245 | *inOutIdx += OPAQUE16_LEN; |
6245 | 6246 | if ((*inOutIdx - begin) + len > size) |
6246 | 6247 | return BUFFER_ERROR; |
6247 | | - if (len == 0) |
6248 | | - return INVALID_PARAMETER; |
| 6248 | + /* RFC 9846 Section 4.4.2: CertificateRequest.extensions has a lower bound of |
| 6249 | + * 0, so an empty extensions block is parsed rather than rejected here. A |
| 6250 | + * request missing the mandatory signature_algorithms extension is caught by |
| 6251 | + * the check below. */ |
6249 | 6252 | if ((ret = TLSX_Parse(ssl, input + *inOutIdx, len, certificate_request, |
6250 | 6253 | &peerSuites))) { |
6251 | 6254 | return ret; |
@@ -6554,7 +6557,7 @@ static int DoPreSharedKeys(WOLFSSL* ssl, const byte* input, word32 inputSz, |
6554 | 6557 | } |
6555 | 6558 | if (ret == WOLFSSL_TICKET_RET_OK) { |
6556 | 6559 | #if defined(WOLFSSL_CERT_WITH_EXTERN_PSK) && defined(HAVE_SESSION_TICKET) |
6557 | | - /* RFC 8773bis Sect. 5.1: all PSKs listed alongside |
| 6560 | + /* RFC 9973 Sect. 5.1: all PSKs listed alongside |
6558 | 6561 | * tls_cert_with_extern_psk MUST be external PSKs. A successfully |
6559 | 6562 | * decrypted session ticket identity is a resumption PSK, so the |
6560 | 6563 | * server MUST abort with illegal_parameter regardless of whether |
@@ -6879,7 +6882,7 @@ static int CheckPreSharedKeys(WOLFSSL* ssl, const byte* input, word32 helloSz, |
6879 | 6882 | extEarlyData = TLSX_Find(ssl->extensions, TLSX_EARLY_DATA); |
6880 | 6883 | if (extEarlyData != NULL) { |
6881 | 6884 | /* Check if accepting early data and first PSK. |
6882 | | - * RFC 8773bis: early_data is not compatible with |
| 6885 | + * RFC 9973: early_data is not compatible with |
6883 | 6886 | * cert_with_extern_psk, so skip key derivation in that case. */ |
6884 | 6887 | if (ssl->earlyData != no_early_data && first |
6885 | 6888 | && ssl->options.maxEarlyDataSz > 0 |
@@ -6949,7 +6952,7 @@ static int CheckPreSharedKeys(WOLFSSL* ssl, const byte* input, word32 helloSz, |
6949 | 6952 | ssl->options.sendVerify = SEND_CERT; |
6950 | 6953 | certExt->resp = 1; |
6951 | 6954 | #ifdef WOLFSSL_EARLY_DATA |
6952 | | - /* RFC 8773bis: early_data is not compatible with |
| 6955 | + /* RFC 9973: early_data is not compatible with |
6953 | 6956 | * cert_with_extern_psk. TLSX_Parse already rejects the |
6954 | 6957 | * combination in the ClientHello, but clear the response flag |
6955 | 6958 | * here as a defense-in-depth measure. */ |
@@ -12401,6 +12404,19 @@ int SendTls13KeyUpdate(WOLFSSL* ssl) |
12401 | 12404 | } |
12402 | 12405 | #endif /* WOLFSSL_DTLS13 */ |
12403 | 12406 |
|
| 12407 | + if (!ssl->options.dtls) { |
| 12408 | + /* RFC 9846 Section 4.7.3: a sending implementation MUST NOT allow its |
| 12409 | + * number of key updates to exceed 2^48-1. Receivers MUST NOT enforce |
| 12410 | + * this on the peer. */ |
| 12411 | + if (w64GTE(ssl->keys.keyUpdateCount, |
| 12412 | + w64From32(TLS13_KEY_UPDATE_MAX_HI32, |
| 12413 | + TLS13_KEY_UPDATE_MAX_LO32))) { |
| 12414 | + WOLFSSL_MSG("TLS 1.3 key update count at maximum; refusing " |
| 12415 | + "KeyUpdate"); |
| 12416 | + return BAD_STATE_E; |
| 12417 | + } |
| 12418 | + } |
| 12419 | + |
12404 | 12420 | outputSz = OPAQUE8_LEN + MAX_MSG_EXTRA; |
12405 | 12421 | /* Check buffers are big enough and grow if needed. */ |
12406 | 12422 | if ((ret = CheckAvailableSize(ssl, outputSz)) != 0) |
@@ -12472,6 +12488,9 @@ int SendTls13KeyUpdate(WOLFSSL* ssl) |
12472 | 12488 | return ret; |
12473 | 12489 | if ((ret = SetKeysSide(ssl, ENCRYPT_SIDE_ONLY)) != 0) |
12474 | 12490 | return ret; |
| 12491 | + |
| 12492 | + /* Count this key update against the RFC 9846 sender limit. */ |
| 12493 | + w64Increment(&ssl->keys.keyUpdateCount); |
12475 | 12494 | } |
12476 | 12495 |
|
12477 | 12496 |
|
@@ -16419,10 +16438,25 @@ int tls13ShowSecrets(WOLFSSL* ssl, int id, const unsigned char* secret, |
16419 | 16438 | byte clientRandom[RAN_LEN]; |
16420 | 16439 | int clientRandomSz; |
16421 | 16440 | XFILE fp; |
| 16441 | +#if defined(WOLFSSL_SSLKEYLOGFILE_OUTPUT) && defined(WOLFSSL_SSLKEYLOGFILE_USE_ENV) |
| 16442 | + const char* keyLogFile; |
| 16443 | +#endif |
16422 | 16444 |
|
16423 | 16445 | (void) ctx; |
16424 | 16446 | #ifdef WOLFSSL_SSLKEYLOGFILE_OUTPUT |
| 16447 | +#ifdef WOLFSSL_SSLKEYLOGFILE_USE_ENV |
| 16448 | + /* RFC 9850: prefer the SSLKEYLOGFILE environment variable so tools such as |
| 16449 | + * curl and Wireshark can share the path, else use the compile-time path. |
| 16450 | + * XGETENV resolves to NULL where environment access is unavailable. Opt-in |
| 16451 | + * so a build with the variable exported for other applications is not |
| 16452 | + * affected. */ |
| 16453 | + keyLogFile = XGETENV("SSLKEYLOGFILE"); |
| 16454 | + if (keyLogFile == NULL || keyLogFile[0] == '\0') |
| 16455 | + keyLogFile = WOLFSSL_SSLKEYLOGFILE_OUTPUT; |
| 16456 | + fp = XFOPEN(keyLogFile, "ab"); |
| 16457 | +#else |
16425 | 16458 | fp = XFOPEN(WOLFSSL_SSLKEYLOGFILE_OUTPUT, "ab"); |
| 16459 | +#endif |
16426 | 16460 | if (fp == XBADFILE) { |
16427 | 16461 | return BAD_FUNC_ARG; |
16428 | 16462 | } |
|
0 commit comments