Skip to content

Commit

Permalink
Add MBEDTLS_SELF_TEST check in header files
Browse files Browse the repository at this point in the history
Add the `MBEDTLS_SELF_TEST` precompilation surrounding the self test functions,
which were missing this check in the header files. ( most of the header files were missing this check).
Addresses issue Mbed-TLS#971
  • Loading branch information
Ron Eldor authored and Ron Eldor committed Jun 21, 2017
1 parent 5a1c0e7 commit 5af5cbe
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
mbed TLS ChangeLog (Sorted per branch, date)

= mbed TLS x.x.x released xxxx-xx-xx

Bugfix
* Add `MBEDTLS_SELF_TEST` for the mbedtls_self_test functions
in the header files, which missed the precompilation check. #971

= mbed TLS 2.5.1 released xxxx-xx-xx

Security
Expand Down
3 changes: 3 additions & 0 deletions include/mbedtls/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,16 @@ MBEDTLS_DEPRECATED static inline void mbedtls_aes_decrypt(
extern "C" {
#endif

#if defined(MBEDTLS_SELF_TEST)
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_aes_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/arc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned
extern "C" {
#endif

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_arc4_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions include/mbedtls/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen,
int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
const unsigned char *src, size_t slen );

#if defined(MBEDTLS_SELF_TEST)
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_base64_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,17 @@ int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_mpi_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/camellia.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,17 @@ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
extern "C" {
#endif

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_camellia_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/ctr_drbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,17 @@ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char
int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
#endif /* MBEDTLS_FS_IO */

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_ctr_drbg_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

/* Internal functions (do not call directly) */
int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *,
int (*)(void *, unsigned char *, size_t), void *,
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/des.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,17 @@ void mbedtls_des_setkey( uint32_t SK[32],
extern "C" {
#endif

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_des_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions include/mbedtls/dhm.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,16 @@ int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path );
#endif /* MBEDTLS_FS_IO */
#endif /* MBEDTLS_ASN1_PARSE_C */

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_dhm_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */
#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/gcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,17 @@ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx,
*/
void mbedtls_gcm_free( mbedtls_gcm_context *ctx );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_gcm_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/md2.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ extern "C" {
*/
void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_md2_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

/* Internal use */
void mbedtls_md2_process( mbedtls_md2_context *ctx );

Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/md4.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ extern "C" {
*/
void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_md4_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

/* Internal use */
void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] );

Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ extern "C" {
*/
void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_md5_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/pkcs5.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *p
unsigned int iteration_count,
uint32_t key_length, unsigned char *output );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_pkcs5_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/ripemd160.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ extern "C" {
void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
unsigned char output[20] );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_ripemd160_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,17 @@ int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src )
*/
void mbedtls_rsa_free( mbedtls_rsa_context *ctx );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_rsa_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ extern "C" {
*/
void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_sha1_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,17 @@ extern "C" {
void mbedtls_sha256( const unsigned char *input, size_t ilen,
unsigned char output[32], int is224 );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_sha256_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/sha512.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ extern "C" {
void mbedtls_sha512( const unsigned char *input, size_t ilen,
unsigned char output[64], int is384 );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_sha512_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

/* Internal use */
void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );

Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/x509.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,17 @@ int mbedtls_x509_time_is_past( const mbedtls_x509_time *time );
*/
int mbedtls_x509_time_is_future( const mbedtls_x509_time *time );

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_x509_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

/*
* Internal module functions. You probably do not want to use these unless you
* know you do.
Expand Down
4 changes: 4 additions & 0 deletions include/mbedtls/xtea.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx,
extern "C" {
#endif

#if defined(MBEDTLS_SELF_TEST)

/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_xtea_self_test( int verbose );

#endif /* MBEDTLS_SELF_TEST */

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 5af5cbe

Please sign in to comment.