From 6076f4124a1df99a782229f814578b5e2fa3533f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 28 Mar 2023 11:43:36 +0200 Subject: [PATCH] Remove hash_info.[ch] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- include/mbedtls/psa_util.h | 2 +- library/CMakeLists.txt | 1 - library/Makefile | 1 - library/ecjpake.c | 2 - library/hash_info.c | 56 ------------------- library/hash_info.h | 39 ------------- library/pem.c | 1 - library/pk.c | 2 - library/pk_wrap.c | 1 - library/pkcs12.c | 1 - library/pkcs5.c | 1 - library/psa_crypto.c | 1 - library/psa_crypto_ecp.c | 1 - library/psa_crypto_rsa.c | 1 - library/rsa.c | 1 - library/ssl_misc.h | 1 - library/ssl_tls12_client.c | 2 - library/ssl_tls12_server.c | 1 - library/x509_crt.c | 1 - library/x509write_crt.c | 2 - library/x509write_csr.c | 1 - tests/include/test/ssl_helpers.h | 1 - .../test_suite_constant_time_hmac.function | 1 - tests/suites/test_suite_ecdsa.function | 1 - tests/suites/test_suite_pk.function | 2 - tests/suites/test_suite_ssl.function | 2 - tests/suites/test_suite_x509write.function | 2 - 27 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 library/hash_info.c delete mode 100644 library/hash_info.h diff --git a/include/mbedtls/psa_util.h b/include/mbedtls/psa_util.h index 5fdecc6021..cdc20e8af7 100644 --- a/include/mbedtls/psa_util.h +++ b/include/mbedtls/psa_util.h @@ -123,7 +123,7 @@ static inline psa_key_usage_t mbedtls_psa_translate_cipher_operation( /* Translations for hashing. */ /* Note: this function should not be used from inside the library, use - * mbedtls_md_psa_alg_from_type() from the internal hash_info.h instead. + * mbedtls_md_psa_alg_from_type() from the internal md_psa.h instead. * It is kept only for compatibility in case applications were using it. */ static inline psa_algorithm_t mbedtls_psa_translate_md(mbedtls_md_type_t md_alg) { diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index a08f3ff0b1..915c8200fa 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -42,7 +42,6 @@ set(src_crypto entropy_poll.c error.c gcm.c - hash_info.c hkdf.c hmac_drbg.c lmots.c diff --git a/library/Makefile b/library/Makefile index 51e7a15a6a..01da1c9cff 100644 --- a/library/Makefile +++ b/library/Makefile @@ -107,7 +107,6 @@ OBJS_CRYPTO= \ entropy_poll.o \ error.o \ gcm.o \ - hash_info.o \ hkdf.o \ hmac_drbg.o \ lmots.o \ diff --git a/library/ecjpake.c b/library/ecjpake.c index c2ab4b86ad..19ad2c6e0f 100644 --- a/library/ecjpake.c +++ b/library/ecjpake.c @@ -30,8 +30,6 @@ #include "mbedtls/platform_util.h" #include "mbedtls/error.h" -#include "hash_info.h" - #include #if !defined(MBEDTLS_ECJPAKE_ALT) diff --git a/library/hash_info.c b/library/hash_info.c deleted file mode 100644 index 3a26251691..0000000000 --- a/library/hash_info.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Hash information that's independent from the crypto implementation. - * - * (See the corresponding header file for usage notes.) - */ -/* - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hash_info.h" -#include "mbedtls/error.h" - -typedef struct { - psa_algorithm_t psa_alg; - mbedtls_md_type_t md_type; - unsigned char size; - unsigned char block_size; -} hash_entry; - -static const hash_entry hash_table[] = { -#if defined(MBEDTLS_MD_CAN_MD5) - { PSA_ALG_MD5, MBEDTLS_MD_MD5, 16, 64 }, -#endif -#if defined(MBEDTLS_MD_CAN_RIPEMD160) - { PSA_ALG_RIPEMD160, MBEDTLS_MD_RIPEMD160, 20, 64 }, -#endif -#if defined(MBEDTLS_MD_CAN_SHA1) - { PSA_ALG_SHA_1, MBEDTLS_MD_SHA1, 20, 64 }, -#endif -#if defined(MBEDTLS_MD_CAN_SHA224) - { PSA_ALG_SHA_224, MBEDTLS_MD_SHA224, 28, 64 }, -#endif -#if defined(MBEDTLS_MD_CAN_SHA256) - { PSA_ALG_SHA_256, MBEDTLS_MD_SHA256, 32, 64 }, -#endif -#if defined(MBEDTLS_MD_CAN_SHA384) - { PSA_ALG_SHA_384, MBEDTLS_MD_SHA384, 48, 128 }, -#endif -#if defined(MBEDTLS_MD_CAN_SHA512) - { PSA_ALG_SHA_512, MBEDTLS_MD_SHA512, 64, 128 }, -#endif - { PSA_ALG_NONE, MBEDTLS_MD_NONE, 0, 0 }, -}; diff --git a/library/hash_info.h b/library/hash_info.h deleted file mode 100644 index 26e60e4f8d..0000000000 --- a/library/hash_info.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Hash information that's independent from the crypto implementation. - * - * This can be used by: - * - code based on PSA - * - code based on the legacy API - * - code based on either of them depending on MBEDTLS_USE_PSA_CRYPTO - * - code based on either of them depending on what's available - * - * Note: this internal module will go away when everything becomes based on - * PSA Crypto; it is a helper for the transition while hash algorithms are - * still represented using mbedtls_md_type_t in most places even when PSA is - * used for the actual crypto computations. - * - * Copyright The Mbed TLS Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef MBEDTLS_HASH_INFO_H -#define MBEDTLS_HASH_INFO_H - -#include "common.h" - -#include "mbedtls/md.h" -#include "psa/crypto.h" -#include "mbedtls/platform_util.h" - -#endif /* MBEDTLS_HASH_INFO_H */ diff --git a/library/pem.c b/library/pem.c index aed4788bfe..056c98c771 100644 --- a/library/pem.c +++ b/library/pem.c @@ -29,7 +29,6 @@ #include "mbedtls/cipher.h" #include "mbedtls/platform_util.h" #include "mbedtls/error.h" -#include "hash_info.h" #include diff --git a/library/pk.c b/library/pk.c index 74a1ffae35..91796dec9d 100644 --- a/library/pk.c +++ b/library/pk.c @@ -25,8 +25,6 @@ #include "pkwrite.h" #include "pk_internal.h" -#include "hash_info.h" - #include "mbedtls/platform_util.h" #include "mbedtls/error.h" diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 1bafd1fa03..087a7a386a 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -47,7 +47,6 @@ #if defined(MBEDTLS_USE_PSA_CRYPTO) #include "psa/crypto.h" -#include "hash_info.h" #if defined(MBEDTLS_PK_CAN_ECDSA_SOME) #include "mbedtls/asn1write.h" diff --git a/library/pkcs12.c b/library/pkcs12.c index 2e6ed7e814..ce2dcf27ea 100644 --- a/library/pkcs12.c +++ b/library/pkcs12.c @@ -39,7 +39,6 @@ #include "mbedtls/des.h" #endif -#include "hash_info.h" #include "mbedtls/psa_util.h" #if defined(MBEDTLS_ASN1_PARSE_C) diff --git a/library/pkcs5.c b/library/pkcs5.c index 0f4baf1bdb..94da9813e9 100644 --- a/library/pkcs5.c +++ b/library/pkcs5.c @@ -44,7 +44,6 @@ #include "mbedtls/platform.h" -#include "hash_info.h" #include "mbedtls/psa_util.h" #if defined(MBEDTLS_ASN1_PARSE_C) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7fb1063f0b..9a4cfdbdd7 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -82,7 +82,6 @@ #include "mbedtls/sha1.h" #include "mbedtls/sha256.h" #include "mbedtls/sha512.h" -#include "hash_info.h" #define ARRAY_LENGTH(array) (sizeof(array) / sizeof(*(array))) diff --git a/library/psa_crypto_ecp.c b/library/psa_crypto_ecp.c index bf2cae82b2..488020882f 100644 --- a/library/psa_crypto_ecp.c +++ b/library/psa_crypto_ecp.c @@ -26,7 +26,6 @@ #include "psa_crypto_core.h" #include "psa_crypto_ecp.h" #include "psa_crypto_random_impl.h" -#include "hash_info.h" #include "md_psa.h" #include diff --git a/library/psa_crypto_rsa.c b/library/psa_crypto_rsa.c index bb8371a885..ab93146deb 100644 --- a/library/psa_crypto_rsa.c +++ b/library/psa_crypto_rsa.c @@ -38,7 +38,6 @@ #include #include #include "pk_wrap.h" -#include "hash_info.h" #if defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_CRYPT) || \ defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP) || \ diff --git a/library/rsa.c b/library/rsa.c index aa8cdf6a82..950d8e91c0 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -46,7 +46,6 @@ #include "mbedtls/error.h" #include "constant_time_internal.h" #include "mbedtls/constant_time.h" -#include "hash_info.h" #include "md_psa.h" #include diff --git a/library/ssl_misc.h b/library/ssl_misc.h index 17149c59e6..2d6d7bace5 100644 --- a/library/ssl_misc.h +++ b/library/ssl_misc.h @@ -30,7 +30,6 @@ #if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_SSL_PROTO_TLS1_3) #include "psa/crypto.h" #include "mbedtls/psa_util.h" -#include "hash_info.h" #endif #if defined(MBEDTLS_MD_CAN_MD5) diff --git a/library/ssl_tls12_client.c b/library/ssl_tls12_client.c index df4c00373d..fc96dae1e2 100644 --- a/library/ssl_tls12_client.c +++ b/library/ssl_tls12_client.c @@ -50,8 +50,6 @@ #include "mbedtls/platform_util.h" #endif -#include "hash_info.h" - #if defined(MBEDTLS_SSL_RENEGOTIATION) MBEDTLS_CHECK_RETURN_CRITICAL static int ssl_write_renegotiation_ext(mbedtls_ssl_context *ssl, diff --git a/library/ssl_tls12_server.c b/library/ssl_tls12_server.c index 40e6fc9795..30c35f3a45 100644 --- a/library/ssl_tls12_server.c +++ b/library/ssl_tls12_server.c @@ -30,7 +30,6 @@ #include "mbedtls/platform_util.h" #include "constant_time_internal.h" #include "mbedtls/constant_time.h" -#include "hash_info.h" #include diff --git a/library/x509_crt.c b/library/x509_crt.c index 69c3c03481..65b464a724 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -48,7 +48,6 @@ #include "psa/crypto.h" #include "mbedtls/psa_util.h" #endif /* MBEDTLS_USE_PSA_CRYPTO */ -#include "hash_info.h" #include "x509_invasive.h" #include "pk_internal.h" diff --git a/library/x509write_crt.c b/library/x509write_crt.c index a8ea945997..6c781933eb 100644 --- a/library/x509write_crt.c +++ b/library/x509write_crt.c @@ -47,8 +47,6 @@ #include "mbedtls/psa_util.h" #endif /* MBEDTLS_USE_PSA_CRYPTO */ -#include "hash_info.h" - #define CHECK_OVERFLOW_ADD(a, b) \ do \ { \ diff --git a/library/x509write_csr.c b/library/x509write_csr.c index f4fad884af..1862388777 100644 --- a/library/x509write_csr.c +++ b/library/x509write_csr.c @@ -37,7 +37,6 @@ #include "psa/crypto.h" #include "mbedtls/psa_util.h" #endif /* MBEDTLS_USE_PSA_CRYPTO */ -#include "hash_info.h" #include #include diff --git a/tests/include/test/ssl_helpers.h b/tests/include/test/ssl_helpers.h index 572b6cb71e..2841691c9c 100644 --- a/tests/include/test/ssl_helpers.h +++ b/tests/include/test/ssl_helpers.h @@ -36,7 +36,6 @@ #include #include #include -#include "hash_info.h" #include "test/certs.h" diff --git a/tests/suites/test_suite_constant_time_hmac.function b/tests/suites/test_suite_constant_time_hmac.function index 35ed0430e5..42b1e7c62f 100644 --- a/tests/suites/test_suite_constant_time_hmac.function +++ b/tests/suites/test_suite_constant_time_hmac.function @@ -3,7 +3,6 @@ #include #include #include -#include #include /* END_HEADER */ diff --git a/tests/suites/test_suite_ecdsa.function b/tests/suites/test_suite_ecdsa.function index 14fe2f058b..f16a6d4134 100644 --- a/tests/suites/test_suite_ecdsa.function +++ b/tests/suites/test_suite_ecdsa.function @@ -1,6 +1,5 @@ /* BEGIN_HEADER */ #include "mbedtls/ecdsa.h" -#include "hash_info.h" /* END_HEADER */ /* BEGIN_DEPENDENCIES diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index 0adf1fc69e..eca46c86ab 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -9,8 +9,6 @@ #include "mbedtls/rsa.h" #include "pk_internal.h" -#include "hash_info.h" - #include #include diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index fb71b835b0..a8c714f391 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -7,8 +7,6 @@ #include #include -#include "hash_info.h" - #include #include diff --git a/tests/suites/test_suite_x509write.function b/tests/suites/test_suite_x509write.function index be6a066fef..c3b67684db 100644 --- a/tests/suites/test_suite_x509write.function +++ b/tests/suites/test_suite_x509write.function @@ -8,8 +8,6 @@ #include "mbedtls/asn1write.h" #include "mbedtls/pk.h" -#include "hash_info.h" - #if defined(MBEDTLS_RSA_C) int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen, const unsigned char *input, unsigned char *output,