Add TLSv1.3 KDF to wolfCrypt Test

Added a test for the TLSv1.3 KDF to the wolfcrypt test. It uses 6
different test cases from the CAVP tests. A set of 8 session keys are
generated using multiple exporters.
This commit is contained in:
John Safranek
2022-04-05 08:54:31 -07:00
parent a914d782c0
commit eefc0f2f57

View File

@ -408,6 +408,7 @@ WOLFSSL_TEST_SUBROUTINE int hmac_sha3_test(void);
static int hkdf_test(void);
#endif
WOLFSSL_TEST_SUBROUTINE int sshkdf_test(void);
WOLFSSL_TEST_SUBROUTINE int tls13_kdf_test(void);
WOLFSSL_TEST_SUBROUTINE int x963kdf_test(void);
WOLFSSL_TEST_SUBROUTINE int arc4_test(void);
#ifdef WC_RC2
@ -1009,6 +1010,15 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
PRIVATE_KEY_LOCK();
#endif /* WOLFSSL_WOLFSSH */
#ifdef WOLFSSL_TLS13
PRIVATE_KEY_UNLOCK();
if ( (ret = tls13_kdf_test()) != 0)
return err_sys("TLSv1.3 KDF test failed!\n", ret);
else
TEST_PASS("TLSv1.3 KDF test passed!\n");
PRIVATE_KEY_LOCK();
#endif /* WOLFSSL_TLS13 */
#if defined(HAVE_X963_KDF) && defined(HAVE_ECC)
if ( (ret = x963kdf_test()) != 0)
return err_sys("X963-KDF test failed!\n", ret);
@ -20252,6 +20262,696 @@ int sshkdf_test(void)
#endif /* WOLFSSL_WOLFSSH */
#ifdef WOLFSSL_TLS13
#define TLSV13_PSK_DHE_SZ 40
typedef struct {
enum wc_HashType hashAlg;
word32 pskSz;
word32 dheSz;
byte psk[TLSV13_PSK_DHE_SZ];
byte dhe[TLSV13_PSK_DHE_SZ];
byte hashHello1[WC_MAX_DIGEST_SIZE];
byte hashHello2[WC_MAX_DIGEST_SIZE];
byte hashFinished1[WC_MAX_DIGEST_SIZE];
byte hashFinished2[WC_MAX_DIGEST_SIZE];
/* Expected */
byte clientEarlyTrafficSecret[WC_MAX_DIGEST_SIZE];
byte earlyExporterMasterSecret[WC_MAX_DIGEST_SIZE];
byte clientHandshakeTrafficSecret[WC_MAX_DIGEST_SIZE];
byte serverHandshakeTrafficSecret[WC_MAX_DIGEST_SIZE];
byte clientApplicationTrafficSecret[WC_MAX_DIGEST_SIZE];
byte serverApplicationTrafficSecret[WC_MAX_DIGEST_SIZE];
byte exporterMasterSecret[WC_MAX_DIGEST_SIZE];
byte resumptionMasterSecret[WC_MAX_DIGEST_SIZE];
} Tls13KdfTestVector;
/* The following tests come from the CAVP test vectors we used for
* our FIPS validation. The hash values used are the components from
* the test hashed together. hashHello1 is the hash of the
* clientHelloRandom value of the test vector. hashHello2 is the hash
* of the clientHelloRandom and serverHelloRandom values from the test
* vector. hashFinished1 is clientHelloRandom, serverHelloRandom, and
* serverFinishedRandom. hashFinished2 is clientHelloRandom,
* serverHelloRandom, serverFinishedRandom, and clietnFinishedRandom
* hashed together. */
static const Tls13KdfTestVector tls13KdfTestVectors[] = {
{ /* 1 */
WC_HASH_TYPE_SHA256, 35, 35,
{ /* PSK */
0x7b, 0xf1, 0x05, 0x31, 0x36, 0xfa, 0x03, 0xdc,
0x31, 0x97, 0x88, 0x04, 0x9c, 0xbc, 0xee, 0xf7,
0x8d, 0x84, 0x95, 0x26, 0xaf, 0x1d, 0x68, 0xb0,
0x60, 0x7a, 0xcc, 0x4f, 0xc1, 0xd3, 0xa1, 0x68,
0x7f, 0x6d, 0xbe
},
{ /* DHE */
0x6e, 0xa1, 0x77, 0xab, 0x2f, 0x43, 0xd2, 0x4b,
0xe5, 0xa1, 0x09, 0xe0, 0x7a, 0xd0, 0x01, 0x35,
0x8d, 0xf8, 0xf2, 0x5c, 0x91, 0x02, 0xb0, 0x6c,
0x3f, 0xeb, 0xee, 0xa4, 0x42, 0x19, 0xce, 0xdc,
0x81, 0x26, 0x40
},
{ /* Hello 1 */
0xd9, 0x4b, 0xe4, 0x17, 0xef, 0x58, 0x73, 0x7d,
0x28, 0x3d, 0xf0, 0xcc, 0x05, 0x03, 0xaf, 0xac,
0x3d, 0x92, 0x79, 0x48, 0xe8, 0x8c, 0xdb, 0xce,
0x95, 0x82, 0x21, 0x31, 0x7b, 0x61, 0xd7, 0xc6
},
{ /* Hello 2 */
0xb7, 0x7f, 0x29, 0x91, 0xa4, 0x8b, 0x34, 0xdb,
0xbd, 0xc7, 0x54, 0x1c, 0x3b, 0x86, 0xa3, 0x69,
0xfe, 0x26, 0xe4, 0x7b, 0xac, 0x57, 0x71, 0xb3,
0x32, 0x97, 0xed, 0xd2, 0x0e, 0x95, 0xb8, 0x63
},
{ /* Finished 1 */
0x65, 0xdb, 0x6d, 0x71, 0x71, 0xd0, 0xd8, 0x49,
0xd0, 0x3c, 0x8e, 0x2b, 0x24, 0xdf, 0xc2, 0xe9,
0xd6, 0xfd, 0xea, 0x04, 0x95, 0x7c, 0xf0, 0x7e,
0x57, 0x74, 0x7c, 0xdd, 0xa3, 0x0b, 0x2b, 0x36
},
{ /* Finished 2 */
0x28, 0xf2, 0xf2, 0x79, 0xcf, 0x20, 0x52, 0x90,
0x1d, 0x91, 0x05, 0xad, 0x44, 0x26, 0x23, 0x96,
0x32, 0xce, 0xec, 0x61, 0xd1, 0xbf, 0x00, 0x48,
0x4a, 0xa5, 0x60, 0xcc, 0x28, 0xb5, 0x8d, 0x98
},
{ /* Client Early Traffic Secret */
0x07, 0x14, 0x6a, 0x26, 0x5b, 0x6c, 0x7f, 0x4d, 0x6b, 0x47, 0x3f, 0xd5,
0x03, 0x1d, 0xd2, 0x23, 0x3d, 0x89, 0x3e, 0xc6, 0x51, 0xd1, 0xac, 0xf8,
0x28, 0xae, 0x4b, 0x76, 0xc8, 0x10, 0x7e, 0xdd
},
{ /* Early Exporter Master Secret */
0xb8, 0xd3, 0x25, 0x7e, 0x2d, 0x41, 0x7b, 0xcb, 0x5e, 0x82, 0x49, 0xf5,
0x51, 0x3d, 0xb7, 0x59, 0x32, 0xb3, 0xdf, 0x99, 0x4e, 0x04, 0x69, 0xc6,
0x96, 0x8e, 0xe6, 0x3d, 0x91, 0xe4, 0x81, 0x11
},
{ /* Client Handshake Traffic Secret */
0xd9, 0x3b, 0x54, 0xe2, 0xb0, 0xd1, 0x85, 0xf0, 0xfd, 0xf3, 0x48, 0x4a,
0xf8, 0x0b, 0xa5, 0xdc, 0x4c, 0x37, 0xcb, 0xd4, 0x20, 0xaf, 0x60, 0xc7,
0xd5, 0x50, 0x5d, 0x0c, 0x77, 0x3b, 0x6f, 0xd2
},
{ /* Server Handshake Traffic Secret */
0x4d, 0x40, 0x2b, 0xd2, 0x8c, 0x33, 0x90, 0x39, 0x67, 0x67, 0x05, 0xf7,
0x5d, 0x37, 0x1e, 0xdc, 0x4a, 0x70, 0x6b, 0x9e, 0xf8, 0x06, 0x61, 0x89,
0x70, 0xe1, 0x3d, 0x36, 0xad, 0x88, 0x7e, 0x5b
},
{ /* Client Application Traffic Secret */
0x74, 0x6e, 0xa0, 0x13, 0x18, 0x34, 0x48, 0x4d, 0x23, 0x31, 0xf1, 0xf9,
0xee, 0x44, 0x6d, 0xad, 0xc1, 0xad, 0x92, 0x73, 0xca, 0x27, 0x16, 0x91,
0xa2, 0x50, 0x9a, 0xfc, 0xec, 0xf0, 0x6b, 0x24
},
{ /* Server Application Traffic Secret */
0x89, 0x18, 0x7e, 0x34, 0x8d, 0xfc, 0x14, 0xb1, 0x4f, 0x21, 0xd8, 0x29,
0xdb, 0x9b, 0xfb, 0x55, 0xcf, 0xa1, 0x4f, 0x95, 0xf8, 0xe0, 0xb0, 0x83,
0xd5, 0x34, 0x9e, 0x0b, 0x83, 0x37, 0x42, 0x93
},
{ /* Exporter Master Secret */
0x7d, 0xc8, 0x88, 0x46, 0xd5, 0x57, 0x15, 0xb6, 0x24, 0x25, 0x92, 0x61,
0xb1, 0x18, 0x86, 0x2a, 0x6d, 0xa5, 0x84, 0xeb, 0x59, 0xdf, 0x13, 0xbd,
0x73, 0xaa, 0x5d, 0x65, 0xab, 0xd9, 0xb4, 0x56
},
{ /* Resumption Master Secret */
0x20, 0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* Hello 2 */
0xe6, 0x4f, 0x3a, 0x4f, 0xd7, 0xe0, 0x64, 0xd4,
0x69, 0x50, 0xe4, 0x8b, 0xba, 0xbc, 0x47, 0x74,
0xa7, 0x9b, 0x40, 0x91, 0x8f, 0xa8, 0x72, 0x22,
0x97, 0xad, 0x43, 0xa7, 0x11, 0x86, 0xb5, 0x72
},
{ /* Finished 1 */
0x5f, 0xa6, 0x10, 0xe2, 0xa3, 0x99, 0x0b, 0x5e,
0x57, 0xee, 0xc3, 0x3a, 0x8e, 0x04, 0xf3, 0x0e,
0x58, 0x02, 0x09, 0xb2, 0x7e, 0x2d, 0xc6, 0xd2,
0x08, 0xae, 0x68, 0x0a, 0x55, 0xa5, 0xda, 0x51
},
{ /* Finished 2 */
0xfc, 0x5b, 0xc0, 0x7e, 0x1b, 0xaa, 0xc0, 0xb4,
0x34, 0x85, 0x49, 0x8e, 0x16, 0x31, 0x98, 0xdf,
0x10, 0x54, 0x22, 0xda, 0x1e, 0x6b, 0x51, 0xf6,
0x97, 0x57, 0xa0, 0x7a, 0x92, 0xe7, 0x47, 0x52
},
{
0x80, 0xfa, 0x36, 0x30, 0xb8, 0x65, 0xb3, 0x2a, 0x1d, 0x68, 0x91, 0x06,
0x98, 0xa0, 0x17, 0x8f, 0xee, 0xb7, 0x9e, 0x3d, 0xd8, 0x84, 0x99, 0x30,
0xb9, 0xd6, 0x09, 0x25, 0x5e, 0xfb, 0x8f, 0xd3 },
{
0xa9, 0x89, 0x29, 0x70, 0xe4, 0x55, 0xec, 0x97, 0xfb, 0x24, 0x5b, 0xf9,
0xf1, 0xa3, 0x19, 0x3d, 0xf1, 0x31, 0x14, 0xcd, 0x2a, 0xed, 0x21, 0xc8,
0xb1, 0x53, 0xad, 0x11, 0x0b, 0x9e, 0x5a, 0xee },
{
0x72, 0xad, 0x8d, 0x7f, 0xfc, 0xb7, 0x68, 0xda, 0x27, 0x60, 0x37, 0xa3,
0x4a, 0x63, 0xe8, 0xa5, 0xc8, 0xcd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YPE_SHA384, 35, 35,
{ /* PSK */
0x62, 0x83, 0x25, 0xc7, 0xcc, 0x08, 0x5e, 0x63,
0x64, 0x56, 0xf0, 0xc6, 0x88, 0x27, 0x5a, 0x5b,
0x68, 0x59, 0x0b, 0x14, 0x55, 0x13, 0x2e, 0xfd,
0x8f, 0x28, 0x5b, 0x3d, 0xe3, 0xad, 0x67, 0xe4,
0x68, 0xba, 0xf9
},
{ /* DHE */
0xa8, 0xb1, 0xab, 0xd8, 0xc8, 0x5b, 0x52, 0xdf,
0x7f, 0x49, 0x10, 0xf4, 0xa1, 0x31, 0xd1, 0x91,
0x36, 0xc1, 0x87, 0x5d, 0x42, 0x2a, 0xe7, 0x1d,
0x2c, 0x29, 0x3d, 0x40, 0x64, 0x61, 0x63, 0x76,
0xd8, 0x66, 0xac
},
{ /* Hello 1 */
0x6f, 0xc6, 0x4c, 0xe1, 0xc6, 0x68, 0x34, 0x8c,
0x0a, 0xe1, 0xf8, 0xb8, 0x3e, 0xd4, 0xf8, 0x0b,
0x54, 0x50, 0xe4, 0xc5, 0x4a, 0x33, 0x7d, 0xbd,
0x90, 0xd2, 0xa2, 0xb9, 0xb7, 0x92, 0xed, 0xab,
0x14, 0xf1, 0xe4, 0x86, 0x22, 0x67, 0xd7, 0x44,
0x03, 0x21, 0xdc, 0x51, 0x52, 0x7f, 0x35, 0x80
},
{ /* Hello 2 */
0x3e, 0xcf, 0x2f, 0xc3, 0x87, 0xba, 0xc5, 0xbd,
0x7c, 0xe8, 0x35, 0x5b, 0x95, 0x51, 0x30, 0x3b,
0x08, 0xcc, 0x2a, 0x7d, 0xb5, 0x74, 0x7c, 0x16,
0xb3, 0x0b, 0xe7, 0x61, 0xa3, 0x7c, 0x6c, 0xbd,
0x39, 0x74, 0xfd, 0x1e, 0x4c, 0xff, 0xc8, 0xcc,
0xa0, 0xef, 0x29, 0x4d, 0x94, 0xaa, 0x55, 0x6f,
},
{ /* Finished 1 */
0x06, 0xc1, 0x47, 0x78, 0x66, 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f, 0x83, 0xb1, 0xca, 0x59, 0x56
}
},
{ /* 41 */
WC_HASH_TYPE_SHA384, 33, 0,
{ /* PSK */
0xa4, 0x8b, 0x1b, 0x5f, 0xd0, 0xea, 0x75, 0x62,
0x06, 0x4d, 0x68, 0x40, 0x85, 0x20, 0x45, 0x95,
0x4a, 0x00, 0xca, 0x05, 0xeb, 0xd4, 0x1d, 0x48,
0x81, 0x89, 0xe8, 0x86, 0x43, 0xfa, 0x28, 0x17,
0x12
},
{ 0 }, /* DHE */
{ /* Hello 1 */
0x03, 0x7c, 0x33, 0x75, 0xdc, 0xc5, 0x46, 0x3a,
0x0d, 0x56, 0xc6, 0xfb, 0xab, 0x1e, 0x1d, 0xda,
0x59, 0xc2, 0xb2, 0xb1, 0x7c, 0x48, 0x9b, 0x06,
0x0a, 0x5a, 0xbb, 0xf8, 0x98, 0x53, 0x78, 0x2d,
0xd2, 0xcc, 0x87, 0x68, 0x25, 0xdd, 0x88, 0x22,
0xcd, 0xb7, 0x74, 0x55, 0x21, 0xf9, 0x34, 0x98
},
{ /* Hello 2 */
0x03, 0xb4, 0xfb, 0xcc, 0x28, 0x2c, 0xc1, 0x70,
0x42, 0x73, 0x57, 0xac, 0xdb, 0x47, 0x71, 0xf6,
0x2e, 0x11, 0x8a, 0x5b, 0x47, 0x2f, 0x02, 0x54,
0x95, 0x34, 0xed, 0x5f, 0x19, 0xc1, 0x75, 0xe0,
0x76, 0xad, 0xb0, 0x90, 0x57, 0xcd, 0xfd, 0xd7,
0x58, 0x1f, 0x0d, 0x6b, 0x9e, 0x51, 0x3c, 0x08
},
{ /* Finished 1 */
0x2b, 0x50, 0xd9, 0xa7, 0x43, 0x24, 0xda, 0x2c,
0x7a, 0xaa, 0x0e, 0x37, 0xd7, 0x6b, 0x2c, 0xab,
0x8e, 0xb2, 0xfe, 0x31, 0x1b, 0xa8, 0x12, 0x59,
0x5b, 0x7b, 0xdc, 0x3e, 0xa7, 0x86, 0xa5, 0x48,
0xe4, 0x46, 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
0x92, 0xba, 0x0e, 0x2d, 0xb4, 0xd1, 0x8b, 0x97, 0xd0, 0x85, 0xbb, 0x2e,
0x4f, 0x26, 0x93, 0xf5, 0x1d, 0xf3, 0xd2, 0x43, 0x4f, 0xd2, 0x47, 0xaa,
0x91, 0x1e, 0xf3, 0x67, 0x10, 0x18, 0x2c, 0xb9, 0x01, 0xba, 0x10, 0x9f
},
{
0x79, 0xb6, 0x9c, 0xbe, 0xf1, 0x6a, 0xb0, 0x92, 0xa0, 0x29, 0x52, 0x61,
0xf1, 0xcd, 0x3a, 0x67, 0xe1, 0x6b, 0xb8, 0x9d, 0x0d, 0x95, 0xb6, 0x03,
0x80, 0x1f, 0xd5, 0x75, 0xb6, 0x1d, 0x79, 0x02, 0x93, 0x43, 0x77, 0xa7,
0x9d, 0x2f, 0xc3, 0x84, 0xc6, 0x83, 0x76, 0x16, 0x06, 0x98, 0x7b, 0x79
}
},
#endif /* WOLFSSL_SHA384 */
};
const char protocolLabel[] = "tls13 ";
const char ceTrafficLabel[] = "c e traffic";
const char eExpMasterLabel[] = "e exp master";
const char cHsTrafficLabel[] = "c hs traffic";
const char sHsTrafficLabel[] = "s hs traffic";
const char cAppTrafficLabel[] = "c ap traffic";
const char sAppTrafficLabel[] = "s ap traffic";
const char expMasterLabel[] = "exp master";
const char resMasterLabel[] = "res master";
const char derivedLabel[] = "derived";
int tls13_kdf_test(void)
{
int ret = 0;
word32 i;
word32 tc = sizeof(tls13KdfTestVectors)/sizeof(Tls13KdfTestVector);
const Tls13KdfTestVector* tv = NULL;
for (i = 0, tv = tls13KdfTestVectors; i < tc; i++, tv++) {
byte output[WC_MAX_DIGEST_SIZE];
byte secret[WC_MAX_DIGEST_SIZE];
byte salt[WC_MAX_DIGEST_SIZE];
byte zeroes[WC_MAX_DIGEST_SIZE];
byte hashZero[WC_MAX_DIGEST_SIZE];
int hashAlgSz;
XMEMSET(zeroes, 0, sizeof zeroes);
hashAlgSz = wc_HashGetDigestSize(tv->hashAlg);
if (hashAlgSz == BAD_FUNC_ARG) break;
ret = wc_Hash(tv->hashAlg, NULL, 0, hashZero, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Extract(secret, NULL, 0,
(tv->pskSz == 0) ? zeroes : (byte*)tv->psk,
tv->pskSz, tv->hashAlg);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)ceTrafficLabel, (word32)strlen(ceTrafficLabel),
tv->hashHello1, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->clientEarlyTrafficSecret, output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)eExpMasterLabel, (word32)strlen(eExpMasterLabel),
tv->hashHello1, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->earlyExporterMasterSecret, output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(salt, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)derivedLabel, (word32)strlen(derivedLabel),
hashZero, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Extract(secret, salt, hashAlgSz,
(tv->dheSz == 0) ? zeroes : (byte*)tv->dhe,
tv->dheSz, tv->hashAlg);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)cHsTrafficLabel, (word32)strlen(cHsTrafficLabel),
tv->hashHello2, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->clientHandshakeTrafficSecret,
output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)sHsTrafficLabel, (word32)strlen(sHsTrafficLabel),
tv->hashHello2, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->serverHandshakeTrafficSecret, output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(salt, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)derivedLabel, (word32)strlen(derivedLabel),
hashZero, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Extract(secret, salt, hashAlgSz,
zeroes, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)cAppTrafficLabel, (word32)strlen(cAppTrafficLabel),
tv->hashFinished1, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->clientApplicationTrafficSecret, output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)sAppTrafficLabel, (word32)strlen(sAppTrafficLabel),
tv->hashFinished1, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->serverApplicationTrafficSecret, output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)expMasterLabel, (word32)strlen(expMasterLabel),
tv->hashFinished1, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->exporterMasterSecret, output, hashAlgSz);
if (ret != 0) break;
ret = wc_Tls13_HKDF_Expand_Label(output, hashAlgSz,
secret, hashAlgSz,
(byte*)protocolLabel, (word32)strlen(protocolLabel),
(byte*)resMasterLabel, (word32)strlen(resMasterLabel),
tv->hashFinished2, hashAlgSz, tv->hashAlg);
if (ret != 0) break;
ret = XMEMCMP(tv->resumptionMasterSecret, output, hashAlgSz);
if (ret != 0) break;
}
return ret;
}
#endif /* WOLFSSL_TLS13 */
#if defined(HAVE_ECC) && defined(HAVE_X963_KDF)
WOLFSSL_TEST_SUBROUTINE int x963kdf_test(void)