Switch metadata functions to the PSA-aware availability symbols
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com> Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
416d0e2b01
commit
83d9e09b15
2 changed files with 35 additions and 34 deletions
|
@ -149,19 +149,20 @@ typedef enum {
|
|||
MBEDTLS_MD_RIPEMD160, /**< The RIPEMD-160 message digest. */
|
||||
} mbedtls_md_type_t;
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA512)
|
||||
#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
|
||||
#elif defined(MBEDTLS_SHA384_C)
|
||||
#elif defined(MBEDTLS_MD_CAN_SHA384)
|
||||
#define MBEDTLS_MD_MAX_SIZE 48 /* longest known is SHA384 */
|
||||
#elif defined(MBEDTLS_SHA256_C)
|
||||
#elif defined(MBEDTLS_MD_CAN_SHA256)
|
||||
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 */
|
||||
#elif defined(MBEDTLS_SHA224_C)
|
||||
#elif defined(MBEDTLS_MD_CAN_SHA224)
|
||||
#define MBEDTLS_MD_MAX_SIZE 28 /* longest known is SHA224 */
|
||||
#else
|
||||
#define MBEDTLS_MD_MAX_SIZE 20 /* longest known is SHA1 or RIPE MD-160 */
|
||||
#define MBEDTLS_MD_MAX_SIZE 20 /* longest known is SHA1 or RIPE MD-160
|
||||
or smaller (MD5 and earlier) */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA512)
|
||||
#define MBEDTLS_MD_MAX_BLOCK_SIZE 128
|
||||
#else
|
||||
#define MBEDTLS_MD_MAX_BLOCK_SIZE 64
|
||||
|
|
56
library/md.c
56
library/md.c
|
@ -60,7 +60,7 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
#if defined(MBEDTLS_MD_CAN_MD5)
|
||||
const mbedtls_md_info_t mbedtls_md5_info = {
|
||||
"MD5",
|
||||
MBEDTLS_MD_MD5,
|
||||
|
@ -69,7 +69,7 @@ const mbedtls_md_info_t mbedtls_md5_info = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_RIPEMD160_C)
|
||||
#if defined(MBEDTLS_MD_CAN_RIPEMD160)
|
||||
const mbedtls_md_info_t mbedtls_ripemd160_info = {
|
||||
"RIPEMD160",
|
||||
MBEDTLS_MD_RIPEMD160,
|
||||
|
@ -78,7 +78,7 @@ const mbedtls_md_info_t mbedtls_ripemd160_info = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA1)
|
||||
const mbedtls_md_info_t mbedtls_sha1_info = {
|
||||
"SHA1",
|
||||
MBEDTLS_MD_SHA1,
|
||||
|
@ -87,7 +87,7 @@ const mbedtls_md_info_t mbedtls_sha1_info = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA224)
|
||||
const mbedtls_md_info_t mbedtls_sha224_info = {
|
||||
"SHA224",
|
||||
MBEDTLS_MD_SHA224,
|
||||
|
@ -96,7 +96,7 @@ const mbedtls_md_info_t mbedtls_sha224_info = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA256)
|
||||
const mbedtls_md_info_t mbedtls_sha256_info = {
|
||||
"SHA256",
|
||||
MBEDTLS_MD_SHA256,
|
||||
|
@ -105,7 +105,7 @@ const mbedtls_md_info_t mbedtls_sha256_info = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA384)
|
||||
const mbedtls_md_info_t mbedtls_sha384_info = {
|
||||
"SHA384",
|
||||
MBEDTLS_MD_SHA384,
|
||||
|
@ -114,7 +114,7 @@ const mbedtls_md_info_t mbedtls_sha384_info = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA512)
|
||||
const mbedtls_md_info_t mbedtls_sha512_info = {
|
||||
"SHA512",
|
||||
MBEDTLS_MD_SHA512,
|
||||
|
@ -126,31 +126,31 @@ const mbedtls_md_info_t mbedtls_sha512_info = {
|
|||
const mbedtls_md_info_t *mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
|
||||
{
|
||||
switch (md_type) {
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
#if defined(MBEDTLS_MD_CAN_MD5)
|
||||
case MBEDTLS_MD_MD5:
|
||||
return &mbedtls_md5_info;
|
||||
#endif
|
||||
#if defined(MBEDTLS_RIPEMD160_C)
|
||||
#if defined(MBEDTLS_MD_CAN_RIPEMD160)
|
||||
case MBEDTLS_MD_RIPEMD160:
|
||||
return &mbedtls_ripemd160_info;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA1)
|
||||
case MBEDTLS_MD_SHA1:
|
||||
return &mbedtls_sha1_info;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA224)
|
||||
case MBEDTLS_MD_SHA224:
|
||||
return &mbedtls_sha224_info;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA256)
|
||||
case MBEDTLS_MD_SHA256:
|
||||
return &mbedtls_sha256_info;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA384)
|
||||
case MBEDTLS_MD_SHA384:
|
||||
return &mbedtls_sha384_info;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA512)
|
||||
case MBEDTLS_MD_SHA512:
|
||||
return &mbedtls_sha512_info;
|
||||
#endif
|
||||
|
@ -536,30 +536,30 @@ mbedtls_md_type_t mbedtls_md_get_type(const mbedtls_md_info_t *md_info)
|
|||
*/
|
||||
static const int supported_digests[] = {
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA512)
|
||||
MBEDTLS_MD_SHA512,
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA384)
|
||||
MBEDTLS_MD_SHA384,
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA256)
|
||||
MBEDTLS_MD_SHA256,
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA224)
|
||||
MBEDTLS_MD_SHA224,
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA1)
|
||||
MBEDTLS_MD_SHA1,
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_RIPEMD160_C)
|
||||
#if defined(MBEDTLS_MD_CAN_RIPEMD160)
|
||||
MBEDTLS_MD_RIPEMD160,
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
#if defined(MBEDTLS_MD_CAN_MD5)
|
||||
MBEDTLS_MD_MD5,
|
||||
#endif
|
||||
|
||||
|
@ -578,37 +578,37 @@ const mbedtls_md_info_t *mbedtls_md_info_from_string(const char *md_name)
|
|||
}
|
||||
|
||||
/* Get the appropriate digest information */
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
#if defined(MBEDTLS_MD_CAN_MD5)
|
||||
if (!strcmp("MD5", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_MD5);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_RIPEMD160_C)
|
||||
#if defined(MBEDTLS_MD_CAN_RIPEMD160)
|
||||
if (!strcmp("RIPEMD160", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_RIPEMD160);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA1)
|
||||
if (!strcmp("SHA1", md_name) || !strcmp("SHA", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_SHA1);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA224_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA224)
|
||||
if (!strcmp("SHA224", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_SHA224);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA256)
|
||||
if (!strcmp("SHA256", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_SHA256);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA384)
|
||||
if (!strcmp("SHA384", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_SHA384);
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(MBEDTLS_MD_CAN_SHA512)
|
||||
if (!strcmp("SHA512", md_name)) {
|
||||
return mbedtls_md_info_from_type(MBEDTLS_MD_SHA512);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue