From d6f65b147253cc8c501d28943b6d3191249cc7bd Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Mon, 27 Nov 2023 18:17:53 +0530 Subject: [PATCH] fix(wpa_supplicant): Remove deprecated mbedtls functions used in fast pbkdf2 and fix ci error --- components/mbedtls/test/test_sha.c | 13 +++++++------ components/wpa_supplicant/src/crypto/fastpbkdf2.c | 14 +++++++------- docs/en/COPYRIGHT.rst | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/components/mbedtls/test/test_sha.c b/components/mbedtls/test/test_sha.c index 4f076a741c..df157344d9 100644 --- a/components/mbedtls/test/test_sha.c +++ b/components/mbedtls/test/test_sha.c @@ -141,6 +141,7 @@ TEST_CASE("Test esp_sha() function with long input", "[hw_crypto]") #if SOC_SHA_SUPPORT_SHA512 TEST_ASSERT_EQUAL_MEMORY_MESSAGE(sha512_espsha, sha512_mbedtls, sizeof(sha512_espsha), "SHA512 results should match"); #endif +} #if CONFIG_MBEDTLS_HARDWARE_SHA @@ -160,7 +161,8 @@ TEST_CASE("Test mbedtls_internal_sha_process()", "[hw_crypto]") 0xa4, 0xae, 0x4d, 0xe9 }; mbedtls_sha1_init(&sha1_ctx); - mbedtls_sha1_starts(&sha1_ctx); + ret = mbedtls_sha1_starts_ret(&sha1_ctx); + TEST_ASSERT_EQUAL(0, ret); ret = mbedtls_internal_sha1_process(&sha1_ctx, buffer); TEST_ASSERT_EQUAL(0, ret); @@ -180,7 +182,7 @@ TEST_CASE("Test mbedtls_internal_sha_process()", "[hw_crypto]") // Check if the intermediate states are correct TEST_ASSERT_EQUAL_HEX8_ARRAY(sha1_expected, output, sizeof(sha1_expected)); - ret = mbedtls_sha1_finish(&sha1_ctx, output); + ret = mbedtls_sha1_finish_ret(&sha1_ctx, output); TEST_ASSERT_EQUAL(0, ret); mbedtls_sha1_free(&sha1_ctx); @@ -198,7 +200,8 @@ TEST_CASE("Test mbedtls_internal_sha_process()", "[hw_crypto]") 0x07, 0x0a, 0x3a, 0x03, 0x44, 0xf0, 0xb8, 0xfe }; mbedtls_sha512_init(&sha512_ctx); - mbedtls_sha512_starts(&sha512_ctx, 0); + ret = mbedtls_sha512_starts_ret(&sha512_ctx, 0); + TEST_ASSERT_EQUAL(0, ret); ret = mbedtls_internal_sha512_process(&sha512_ctx, buffer); TEST_ASSERT_EQUAL(0, ret); @@ -218,7 +221,7 @@ TEST_CASE("Test mbedtls_internal_sha_process()", "[hw_crypto]") // Check if the intermediate states are correct TEST_ASSERT_EQUAL_HEX8_ARRAY(sha512_expected, output, sizeof(sha512_expected)); - ret = mbedtls_sha512_finish(&sha512_ctx, output); + ret = mbedtls_sha512_finish_ret(&sha512_ctx, output); TEST_ASSERT_EQUAL(0, ret); mbedtls_sha512_free(&sha512_ctx); @@ -228,5 +231,3 @@ TEST_CASE("Test mbedtls_internal_sha_process()", "[hw_crypto]") } #endif - -} diff --git a/components/wpa_supplicant/src/crypto/fastpbkdf2.c b/components/wpa_supplicant/src/crypto/fastpbkdf2.c index 4f8fa2f804..9084eef09c 100644 --- a/components/wpa_supplicant/src/crypto/fastpbkdf2.c +++ b/components/wpa_supplicant/src/crypto/fastpbkdf2.c @@ -301,13 +301,13 @@ static inline void sha1_xor(mbedtls_sha1_context *restrict out, const mbedtls_sh static int mbedtls_sha1_init_start(mbedtls_sha1_context *ctx) { - mbedtls_sha1_init(ctx); - mbedtls_sha1_starts(ctx); + mbedtls_sha1_init(ctx); + mbedtls_sha1_starts_ret(ctx); #if defined(CONFIG_IDF_TARGET_ESP32) && defined(MBEDTLS_SHA1_ALT) - /* Use software mode for esp32 since hardware can't give output more than 20 */ - esp_mbedtls_set_sha1_mode(ctx, ESP_MBEDTLS_SHA1_SOFTWARE); + /* Use software mode for esp32 since hardware can't give output more than 20 */ + esp_mbedtls_set_sha1_mode(ctx, ESP_MBEDTLS_SHA1_SOFTWARE); #endif - return 0; + return 0; } #ifndef MBEDTLS_SHA1_ALT @@ -374,10 +374,10 @@ DECL_PBKDF2(sha1, // _name 20, // _hashsz mbedtls_sha1_context, // _ctx mbedtls_sha1_init_start, // _init - mbedtls_sha1_update, // _update + mbedtls_sha1_update_ret, // _update mbedtls_internal_sha1_process, // _xform #if defined(MBEDTLS_SHA1_ALT) - mbedtls_sha1_finish, // _final + mbedtls_sha1_finish_ret, // _final #else sha1_finish, // _final #endif diff --git a/docs/en/COPYRIGHT.rst b/docs/en/COPYRIGHT.rst index 256a6dbb71..871cc197ed 100644 --- a/docs/en/COPYRIGHT.rst +++ b/docs/en/COPYRIGHT.rst @@ -25,7 +25,7 @@ These third party libraries can be included into the application (firmware) prod * `wpa_supplicant`_ Copyright (c) 2003-2005 Jouni Malinen and licensed under the BSD license. -* :component_file:`Fast PBKDF2 ` Copyright (c) 2015 Joseph Birr-Pixton and licensed under CC0 Public Domain Dedication license. +* :component_file:`Fast PBKDF2 ` Copyright (c) 2015 Joseph Birr-Pixton and licensed under CC0 Public Domain Dedication license. * `FreeBSD net80211`_ Copyright (c) 2004-2008 Sam Leffler, Errno Consulting and licensed under the BSD license.