Merge pull request #6784 from valeriosetti/issue6702
Make SHA224_C/SHA384_C independent from SHA256_C/SHA512_C
This commit is contained in:
commit
7a389ddc84
21 changed files with 259 additions and 177 deletions
|
@ -695,10 +695,6 @@
|
|||
#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C) && !defined(MBEDTLS_SHA512_C)
|
||||
#error "MBEDTLS_SHA384_C defined without MBEDTLS_SHA512_C"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT) && \
|
||||
defined(MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY)
|
||||
#error "Must only define one of MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
|
@ -754,14 +750,6 @@
|
|||
#error "MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY defined on non-Aarch64 system"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA224_C) && !defined(MBEDTLS_SHA256_C)
|
||||
#error "MBEDTLS_SHA224_C defined without MBEDTLS_SHA256_C"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C) && !defined(MBEDTLS_SHA224_C)
|
||||
#error "MBEDTLS_SHA256_C defined without MBEDTLS_SHA224_C"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT) && \
|
||||
defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY)
|
||||
#error "Must only define one of MBEDTLS_SHA256_USE_A64_CRYPTO_*"
|
||||
|
|
|
@ -3046,9 +3046,6 @@
|
|||
*
|
||||
* Enable the SHA-224 cryptographic hash algorithm.
|
||||
*
|
||||
* Requires: MBEDTLS_SHA256_C. The library does not currently support enabling
|
||||
* SHA-224 without SHA-256.
|
||||
*
|
||||
* Module: library/sha256.c
|
||||
* Caller: library/md.c
|
||||
* library/ssl_cookie.c
|
||||
|
@ -3062,9 +3059,6 @@
|
|||
*
|
||||
* Enable the SHA-256 cryptographic hash algorithm.
|
||||
*
|
||||
* Requires: MBEDTLS_SHA224_C. The library does not currently support enabling
|
||||
* SHA-256 without SHA-224.
|
||||
*
|
||||
* Module: library/sha256.c
|
||||
* Caller: library/entropy.c
|
||||
* library/md.c
|
||||
|
@ -3132,8 +3126,6 @@
|
|||
*
|
||||
* Enable the SHA-384 cryptographic hash algorithm.
|
||||
*
|
||||
* Requires: MBEDTLS_SHA512_C
|
||||
*
|
||||
* Module: library/sha512.c
|
||||
* Caller: library/md.c
|
||||
* library/psa_crypto_hash.c
|
||||
|
|
|
@ -65,8 +65,14 @@ typedef enum {
|
|||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
|
||||
#elif defined(MBEDTLS_SHA384_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 48 /* longest known is SHA384 */
|
||||
#elif defined(MBEDTLS_SHA256_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 */
|
||||
#elif defined(MBEDTLS_SHA224_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 28 /* longest known is SHA224 */
|
||||
#else
|
||||
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
|
||||
#define MBEDTLS_MD_MAX_SIZE 20 /* longest known is SHA1 or RIPE MD-160 */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
|
|
|
@ -96,6 +96,10 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
|
|||
* \param is224 This determines which function to use. This must be
|
||||
* either \c 0 for SHA-256, or \c 1 for SHA-224.
|
||||
*
|
||||
* \note is224 must be defined accordingly to the enabled
|
||||
* MBEDTLS_SHA224_C/MBEDTLS_SHA256_C symbols otherwise the
|
||||
* function will return #MBEDTLS_ERR_SHA512_BAD_INPUT_DATA.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return A negative error code on failure.
|
||||
*/
|
||||
|
@ -178,13 +182,25 @@ int mbedtls_sha256( const unsigned char *input,
|
|||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
/**
|
||||
* \brief The SHA-224 and SHA-256 checkup routine.
|
||||
* \brief The SHA-224 checkup routine.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return \c 1 on failure.
|
||||
*/
|
||||
int mbedtls_sha224_self_test( int verbose );
|
||||
#endif /* MBEDTLS_SHA224_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
/**
|
||||
* \brief The SHA-256 checkup routine.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return \c 1 on failure.
|
||||
*/
|
||||
int mbedtls_sha256_self_test( int verbose );
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
|
|
|
@ -99,9 +99,9 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
|
|||
* \param is384 Determines which function to use. This must be
|
||||
* either \c 0 for SHA-512, or \c 1 for SHA-384.
|
||||
*
|
||||
* \note When \c MBEDTLS_SHA384_C is not defined,
|
||||
* \p is384 must be \c 0, or the function will return
|
||||
* #MBEDTLS_ERR_SHA512_BAD_INPUT_DATA.
|
||||
* \note is384 must be defined accordingly to the enabled
|
||||
* MBEDTLS_SHA384_C/MBEDTLS_SHA512_C symbols otherwise the
|
||||
* function will return #MBEDTLS_ERR_SHA512_BAD_INPUT_DATA.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return A negative error code on failure.
|
||||
|
@ -175,8 +175,11 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
|
|||
* \param is384 Determines which function to use. This must be either
|
||||
* \c 0 for SHA-512, or \c 1 for SHA-384.
|
||||
*
|
||||
* \note When \c MBEDTLS_SHA384_C is not defined, \p is384 must
|
||||
* be \c 0, or the function will return
|
||||
* \note is384 must be defined accordingly with the supported
|
||||
* symbols in the config file. If:
|
||||
* - is384 is 0, but \c MBEDTLS_SHA384_C is not defined, or
|
||||
* - is384 is 1, but \c MBEDTLS_SHA512_C is not defined
|
||||
* then the function will return
|
||||
* #MBEDTLS_ERR_SHA512_BAD_INPUT_DATA.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
|
@ -189,13 +192,26 @@ int mbedtls_sha512( const unsigned char *input,
|
|||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
/**
|
||||
* \brief The SHA-384 or SHA-512 checkup routine.
|
||||
* \brief The SHA-384 checkup routine.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return \c 1 on failure.
|
||||
*/
|
||||
int mbedtls_sha384_self_test( int verbose );
|
||||
#endif /* MBEDTLS_SHA384_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
/**
|
||||
* \brief The SHA-512 checkup routine.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return \c 1 on failure.
|
||||
*/
|
||||
int mbedtls_sha512_self_test( int verbose );
|
||||
#endif /* MBEDTLS_SHA512_C */
|
||||
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue