Skip to content

Commit

Permalink
Change the pkcs5_pbkdf2_hmac deprecation approach
Browse files Browse the repository at this point in the history
The shared part has now been extracted and will
be used regardless of the deprecation define.
  • Loading branch information
Andrzej Kurek authored and Andrzej Kurek committed Sep 1, 2022
1 parent c235ad3 commit 82efdcd
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions library/pkcs5.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,11 @@ int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode,
#endif /* MBEDTLS_ASN1_PARSE_C */

#if defined(MBEDTLS_MD_C)
#if defined(MBEDTLS_DEPRECATED_REMOVED)
static
#endif
int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx,
const unsigned char *password,
size_t plen, const unsigned char *salt, size_t slen,
unsigned int iteration_count,
uint32_t key_length, unsigned char *output )
static int pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx,
const unsigned char *password,
size_t plen, const unsigned char *salt, size_t slen,
unsigned int iteration_count,
uint32_t key_length, unsigned char *output )
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
int j;
Expand Down Expand Up @@ -294,7 +291,17 @@ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx,
return( ret );
}
#endif /* MBEDTLS_MD_C */

#if !defined(MBEDTLS_DEPRECATED_REMOVED)
int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx,
const unsigned char *password,
size_t plen, const unsigned char *salt, size_t slen,
unsigned int iteration_count,
uint32_t key_length, unsigned char *output )
{
return( pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count,
key_length, output ) );
}
#endif
int mbedtls_pkcs5_pbkdf2_hmac_ext( mbedtls_md_type_t md_alg,
const unsigned char *password,
size_t plen, const unsigned char *salt, size_t slen,
Expand All @@ -314,8 +321,8 @@ int mbedtls_pkcs5_pbkdf2_hmac_ext( mbedtls_md_type_t md_alg,

if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 1 ) ) != 0 )
goto exit;
ret = mbedtls_pkcs5_pbkdf2_hmac( &md_ctx, password, plen, salt, slen,
iteration_count, key_length, output );
ret = pkcs5_pbkdf2_hmac( &md_ctx, password, plen, salt, slen,
iteration_count, key_length, output );
exit:
mbedtls_md_free( &md_ctx );
return( ret );
Expand Down

0 comments on commit 82efdcd

Please sign in to comment.