Manually fix two remaining instances of old macros

Unless I missed something, all remaining instance of all macros are in
files where it makes sense to use these. I went over the output of:

    git grep -c -E 'MBEDTLS_(MD5|RIPEMD160|SHA[0-9]*)_C'

and I think all the files listed fall into one of the following
acceptable categories:

- documentation and historical documents: Changelog, docs/**/*.md
- config files and related: mbedtls_config.h, configs/*.h,
  check_config.h, config_psa.h, etc.
- scripts that build/modify configs: all.sh, depends.py,
  set_psa_test_dependencies.py, etc.
- implementation of MD or PSA or related: md.h, psa_util.h, etc. and
  corresponding test suites
- implementation of hashes: md5.c, sha256.h, etc. and corresponding test
  suites
- two example programs using a low-level hash API: hash/hello.c,
  pkey/ecdsa.c
- test/benchmark.c, test/selftest.c: actually want our built-in
  implementations
- a function in test_suite_psa_crypto_storage_format that is
  specifically for checking if the hash is built in.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2023-03-21 17:24:20 +01:00
parent 93302422fd
commit 33783b4646
3 changed files with 6 additions and 6 deletions

View file

@ -62,13 +62,13 @@
#include <psa/crypto.h> #include <psa/crypto.h>
/* If the build options we need are not enabled, compile a placeholder. */ /* If the build options we need are not enabled, compile a placeholder. */
#if !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \ #if !defined(PSA_WANT_ALG_SHA_256) || !defined(MBEDTLS_MD_C) || \
!defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CCM_C) || \ !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CCM_C) || \
!defined(MBEDTLS_PSA_CRYPTO_C) || !defined(MBEDTLS_FS_IO) || \ !defined(MBEDTLS_PSA_CRYPTO_C) || !defined(MBEDTLS_FS_IO) || \
defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER) defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
int main(void) int main(void)
{ {
printf("MBEDTLS_SHA256_C and/or MBEDTLS_MD_C and/or " printf("PSA_WANT_ALG_SHA_256 and/or MBEDTLS_MD_C and/or "
"MBEDTLS_AES_C and/or MBEDTLS_CCM_C and/or " "MBEDTLS_AES_C and/or MBEDTLS_CCM_C and/or "
"MBEDTLS_PSA_CRYPTO_C and/or MBEDTLS_FS_IO " "MBEDTLS_PSA_CRYPTO_C and/or MBEDTLS_FS_IO "
"not defined and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER " "not defined and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER "
@ -698,6 +698,6 @@ usage_failure:
usage(); usage();
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#endif /* MBEDTLS_SHA256_C && MBEDTLS_MD_C && #endif /* PSA_WANT_ALG_SHA_256 && MBEDTLS_MD_C &&
MBEDTLS_AES_C && MBEDTLS_CCM_C && MBEDTLS_AES_C && MBEDTLS_CCM_C &&
MBEDTLS_PSA_CRYPTO_C && MBEDTLS_FS_IO */ MBEDTLS_PSA_CRYPTO_C && MBEDTLS_FS_IO */

View file

@ -34,7 +34,7 @@
*/ */
#if defined(PSA_WANT_ALG_MD5) #if defined(PSA_WANT_ALG_MD5)
#define KNOWN_SUPPORTED_HASH_ALG PSA_ALG_MD5 #define KNOWN_SUPPORTED_HASH_ALG PSA_ALG_MD5
/* MBEDTLS_RIPEMD160_C omitted. This is necessary for the sake of /* PSA_WANT_ALG_RIPEMD160 omitted. This is necessary for the sake of
* exercise_signature_key() because Mbed TLS doesn't support RIPEMD160 * exercise_signature_key() because Mbed TLS doesn't support RIPEMD160
* in RSA PKCS#1v1.5 signatures. A RIPEMD160-only configuration would be * in RSA PKCS#1v1.5 signatures. A RIPEMD160-only configuration would be
* implausible anyway. */ * implausible anyway. */

View file

@ -720,7 +720,7 @@ static int smoke_test_key(mbedtls_svc_key_id_t key)
buffer, sizeof(buffer), NULL, 0, buffer, sizeof(buffer), NULL, 0,
buffer, sizeof(buffer), &length)); buffer, sizeof(buffer), &length));
#if defined(MBEDTLS_SHA256_C) #if defined(PSA_WANT_ALG_SHA_256)
/* Try the key in a plain key derivation. */ /* Try the key in a plain key derivation. */
PSA_ASSERT(psa_key_derivation_setup(&derivation_operation, PSA_ASSERT(psa_key_derivation_setup(&derivation_operation,
PSA_ALG_HKDF(PSA_ALG_SHA_256))); PSA_ALG_HKDF(PSA_ALG_SHA_256)));
@ -753,7 +753,7 @@ static int smoke_test_key(mbedtls_svc_key_id_t key)
alg, key, buffer, length, alg, key, buffer, length,
buffer, sizeof(buffer), &length)); buffer, sizeof(buffer), &length));
} }
#endif /* MBEDTLS_SHA256_C */ #endif /* PSA_WANT_ALG_SHA_256 */
ok = 1; ok = 1;