diff --git a/src/ssl.c b/src/ssl.c index 314f1e8e2..14a160dc2 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -11957,11 +11957,8 @@ int wolfSSL_export_keying_material(WOLFSSL *ssl, const unsigned char *context, size_t contextLen, int use_context) { - byte* seed = NULL; - /* clientRandom + serverRandom - * OR - * clientRandom + serverRandom + ctx len encoding + ctx */ - word32 seedLen = !use_context ? SEED_LEN : SEED_LEN + 2 + (word32)contextLen; + byte* seed = NULL; + word32 seedLen; const struct ForbiddenLabels* fl; WOLFSSL_ENTER("wolfSSL_export_keying_material"); @@ -11972,6 +11969,12 @@ int wolfSSL_export_keying_material(WOLFSSL *ssl, return WOLFSSL_FAILURE; } + /* clientRandom + serverRandom + * OR + * clientRandom + serverRandom + ctx len encoding + ctx */ + seedLen = !use_context ? (word32)SEED_LEN : + (word32)SEED_LEN + 2 + (word32)contextLen; + if (ssl->options.saveArrays == 0 || ssl->arrays == NULL) { WOLFSSL_MSG("To export keying material wolfSSL needs to keep handshake " "data. Call wolfSSL_KeepArrays before attempting to " diff --git a/src/tls13.c b/src/tls13.c index a108551bf..b2fd50f2f 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -777,24 +777,24 @@ int Tls13_Exporter(WOLFSSL* ssl, unsigned char *out, size_t outLen, switch (ssl->specs.mac_algorithm) { #ifndef NO_SHA256 case sha256_mac: - hashType = WC_SHA256; - hashLen = WC_SHA256_DIGEST_SIZE; + hashType = WC_HASH_TYPE_SHA256; + hashLen = WC_SHA256_DIGEST_SIZE; emptyHash = emptySHA256Hash; break; #endif #ifdef WOLFSSL_SHA384 case sha384_mac: - hashType = WC_SHA384; - hashLen = WC_SHA384_DIGEST_SIZE; + hashType = WC_HASH_TYPE_SHA384; + hashLen = WC_SHA384_DIGEST_SIZE; emptyHash = emptySHA384Hash; break; #endif #ifdef WOLFSSL_TLS13_SHA512 case sha512_mac: - hashType = WC_SHA512; - hashLen = WC_SHA512_DIGEST_SIZE; + hashType = WC_HASH_TYPE_SHA512; + hashLen = WC_SHA512_DIGEST_SIZE; emptyHash = emptySHA512Hash; break; #endif diff --git a/tests/api.c b/tests/api.c index 619a52f9a..a103fdec6 100644 --- a/tests/api.c +++ b/tests/api.c @@ -40234,7 +40234,7 @@ static void test_export_keying_material(void) start_thread(test_server_nofail, &server_args, &serverThread); wait_tcp_ready(&server_args); - test_client_nofail(&client_args, test_export_keying_material_cb); + test_client_nofail(&client_args, (void*)test_export_keying_material_cb); join_thread(serverThread); AssertTrue(client_args.return_code);