diff options
Diffstat (limited to 'src/Common/libzip/zip_crypto_mbedtls.c')
-rw-r--r-- | src/Common/libzip/zip_crypto_mbedtls.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Common/libzip/zip_crypto_mbedtls.c b/src/Common/libzip/zip_crypto_mbedtls.c index 95ac8990..84544a82 100644 --- a/src/Common/libzip/zip_crypto_mbedtls.c +++ b/src/Common/libzip/zip_crypto_mbedtls.c @@ -117,6 +117,8 @@ _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_ui mbedtls_md_context_t sha1_ctx; bool ok = true; +#if MBEDTLS_VERSION_NUMBER < 0x03030000 + mbedtls_md_init(&sha1_ctx); if (mbedtls_md_setup(&sha1_ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA1), 1) != 0) { @@ -128,6 +130,13 @@ _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_ui } mbedtls_md_free(&sha1_ctx); + +#else + + ok = mbedtls_pkcs5_pbkdf2_hmac_ext(MBEDTLS_MD_SHA1, (const unsigned char *)key, (size_t)key_length, (const unsigned char *)salt, (size_t)salt_length, (unsigned int)iterations, (uint32_t)output_length, (unsigned char *)output) == 0; + +#endif // !defined(MBEDTLS_DEPRECATED_REMOVED) || MBEDTLS_VERSION_NUMBER < 0x03030000 + return ok; } |