From e9303a5e771378c5e64e751d06ad32c9d204241f Mon Sep 17 00:00:00 2001 From: Marco Oliverio Date: Tue, 9 May 2023 09:30:47 +0000 Subject: [PATCH] dtls13: fix: use dtls label to derive ExportKey/Resumption secrets --- src/tls13.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/tls13.c b/src/tls13.c index bbe55396c..0200ca33e 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -885,9 +885,19 @@ int Tls13_Exporter(WOLFSSL* ssl, unsigned char *out, size_t outLen, const byte* protocol = tls13ProtocolLabel; word32 protocolLen = TLS13_PROTOCOL_LABEL_SZ; - if (ssl->version.minor != TLSv1_3_MINOR) + if (ssl->options.dtls && ssl->version.minor != DTLSv1_3_MINOR) return VERSION_ERROR; + if (!ssl->options.dtls && ssl->version.minor != TLSv1_3_MINOR) + return VERSION_ERROR; + +#ifdef WOLFSSL_DTLS13 + if (ssl->options.dtls) { + protocol = dtls13ProtocolLabel; + protocolLen = DTLS13_PROTOCOL_LABEL_SZ; + } +#endif /* WOLFSSL_DTLS13 */ + switch (ssl->specs.mac_algorithm) { #ifndef NO_SHA256 case sha256_mac: @@ -1166,6 +1176,13 @@ int DeriveResumptionPSK(WOLFSSL* ssl, byte* nonce, byte nonceLen, byte* secret) WOLFSSL_MSG("Derive Resumption PSK"); +#ifdef WOLFSSL_DTLS13 + if (ssl->options.dtls) { + protocol = dtls13ProtocolLabel; + protocolLen = DTLS13_PROTOCOL_LABEL_SZ; + } +#endif /* WOLFSSL_DTLS13 */ + switch (ssl->specs.mac_algorithm) { #ifndef NO_SHA256 case sha256_mac: