dtls13: fix: use dtls label to derive ExportKey/Resumption secrets

This commit is contained in:
Marco Oliverio
2023-05-09 09:30:47 +00:00
parent 1a8f09d013
commit e9303a5e77

View File

@ -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: