Skip to content

Commit 1ea604d

Browse files
author
Hanno Becker
committed
Guard mbedtls_pkcs5_pbes2() by MBEDTLS_ASN1_PARSE_C
Previously, mbedtls_pkcs5_pbes2() was unconditionally declared in `pkcs5.h` but defined as a stub returning `MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE` in case MBEDTLS_ASN1_PARSE_C was not defined. In line with the previous commits, this commit removes declaration and definition from both `pkcs5.h` and `pkcs5.c` in case MBEDTLS_ASN1_PARSE_C is not defined.
1 parent 8a89f9f commit 1ea604d

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

include/mbedtls/pkcs5.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
extern "C" {
4545
#endif
4646

47+
#if defined(MBEDTLS_ASN1_PARSE_C)
48+
4749
/**
4850
* \brief PKCS#5 PBES2 function
4951
*
@@ -62,6 +64,8 @@ int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode,
6264
const unsigned char *data, size_t datalen,
6365
unsigned char *output );
6466

67+
#endif /* MBEDTLS_ASN1_PARSE_C */
68+
6569
/**
6670
* \brief PKCS#5 PBKDF2 using HMAC
6771
*

library/pkcs5.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,7 @@
5454
#define mbedtls_printf printf
5555
#endif
5656

57-
#if !defined(MBEDTLS_ASN1_PARSE_C)
58-
int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode,
59-
const unsigned char *pwd, size_t pwdlen,
60-
const unsigned char *data, size_t datalen,
61-
unsigned char *output )
62-
{
63-
((void) pbe_params);
64-
((void) mode);
65-
((void) pwd);
66-
((void) pwdlen);
67-
((void) data);
68-
((void) datalen);
69-
((void) output);
70-
return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE );
71-
}
72-
#else
57+
#if defined(MBEDTLS_ASN1_PARSE_C)
7358
static int pkcs5_parse_pbkdf2_params( const mbedtls_asn1_buf *params,
7459
mbedtls_asn1_buf *salt, int *iterations,
7560
int *keylen, mbedtls_md_type_t *md_type )

0 commit comments

Comments
 (0)