blob: 3a262516918ff20f56d6424aa892ca3fe392cf79 [file] [log] [blame]
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +02001/*
2 * Hash information that's independent from the crypto implementation.
3 *
4 * (See the corresponding header file for usage notes.)
5 */
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22
23#include "hash_info.h"
Przemek Stekiel71bf28b2022-07-29 12:12:00 +020024#include "mbedtls/error.h"
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020025
Gilles Peskine449bd832023-01-11 14:50:10 +010026typedef struct {
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020027 psa_algorithm_t psa_alg;
28 mbedtls_md_type_t md_type;
29 unsigned char size;
30 unsigned char block_size;
31} hash_entry;
32
33static const hash_entry hash_table[] = {
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010034#if defined(MBEDTLS_MD_CAN_MD5)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020035 { PSA_ALG_MD5, MBEDTLS_MD_MD5, 16, 64 },
36#endif
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010037#if defined(MBEDTLS_MD_CAN_RIPEMD160)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020038 { PSA_ALG_RIPEMD160, MBEDTLS_MD_RIPEMD160, 20, 64 },
39#endif
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010040#if defined(MBEDTLS_MD_CAN_SHA1)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020041 { PSA_ALG_SHA_1, MBEDTLS_MD_SHA1, 20, 64 },
42#endif
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010043#if defined(MBEDTLS_MD_CAN_SHA224)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020044 { PSA_ALG_SHA_224, MBEDTLS_MD_SHA224, 28, 64 },
45#endif
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010046#if defined(MBEDTLS_MD_CAN_SHA256)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020047 { PSA_ALG_SHA_256, MBEDTLS_MD_SHA256, 32, 64 },
48#endif
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010049#if defined(MBEDTLS_MD_CAN_SHA384)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020050 { PSA_ALG_SHA_384, MBEDTLS_MD_SHA384, 48, 128 },
51#endif
Manuel Pégourié-Gonnardebef58d2023-03-16 12:48:24 +010052#if defined(MBEDTLS_MD_CAN_SHA512)
Manuel Pégourié-Gonnard47728842022-07-18 13:00:40 +020053 { PSA_ALG_SHA_512, MBEDTLS_MD_SHA512, 64, 128 },
54#endif
55 { PSA_ALG_NONE, MBEDTLS_MD_NONE, 0, 0 },
56};