feat(crypto): update crypto module for DRTM support

Updated crypto module to include crypto calls necessary for a
DRTM supported build.

Signed-off-by: Manish V Badarkhe <manish.badarkhe@arm.com>
Change-Id: I4f945997824393f46864b7fb7fd380308a025452
This commit is contained in:
Manish V Badarkhe 2022-02-25 08:29:35 +00:00 committed by Manish V Badarkhe
parent 9e0d2bae7e
commit e43caf3890
3 changed files with 13 additions and 13 deletions

View file

@ -730,7 +730,7 @@ ifeq ($(DYN_DISABLE_AUTH), 1)
endif
endif
ifneq ($(filter 1,${MEASURED_BOOT} ${TRUSTED_BOARD_BOOT}),)
ifneq ($(filter 1,${MEASURED_BOOT} ${TRUSTED_BOARD_BOOT} ${DRTM_SUPPORT}),)
CRYPTO_SUPPORT := 1
else
CRYPTO_SUPPORT := 0

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2021, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -50,9 +50,9 @@ void crypto_mod_init(void)
assert(crypto_lib_desc.verify_signature != NULL);
assert(crypto_lib_desc.verify_hash != NULL);
#endif /* TRUSTED_BOARD_BOOT */
#if MEASURED_BOOT
#if MEASURED_BOOT || DRTM_SUPPORT
assert(crypto_lib_desc.calc_hash != NULL);
#endif /* MEASURED_BOOT */
#endif /* MEASURED_BOOT || DRTM_SUPPORT */
/* Initialize the cryptographic library */
crypto_lib_desc.init();
@ -109,7 +109,7 @@ int crypto_mod_verify_hash(void *data_ptr, unsigned int data_len,
digest_info_ptr, digest_info_len);
}
#if MEASURED_BOOT
#if MEASURED_BOOT || DRTM_SUPPORT
/*
* Calculate a hash
*
@ -129,7 +129,7 @@ int crypto_mod_calc_hash(enum crypto_md_algo alg, void *data_ptr,
return crypto_lib_desc.calc_hash(alg, data_ptr, data_len, output);
}
#endif /* MEASURED_BOOT */
#endif /* MEASURED_BOOT || DRTM_SUPPORT */
/*
* Authenticated decryption of data

View file

@ -57,12 +57,12 @@ typedef struct crypto_lib_desc_s {
int (*verify_hash)(void *data_ptr, unsigned int data_len,
void *digest_info_ptr, unsigned int digest_info_len);
#if MEASURED_BOOT
#if MEASURED_BOOT || DRTM_SUPPORT
/* Calculate a hash. Return hash value */
int (*calc_hash)(enum crypto_md_algo md_alg, void *data_ptr,
unsigned int data_len,
unsigned char output[CRYPTO_MD_MAX_SIZE]);
#endif /* MEASURED_BOOT */
#endif /* MEASURED_BOOT || DRTM_SUPPORT */
/*
* Authenticated decryption. Return one of the
@ -96,13 +96,13 @@ int crypto_mod_auth_decrypt(enum crypto_dec_algo dec_algo, void *data_ptr,
unsigned int iv_len, const void *tag,
unsigned int tag_len);
#if MEASURED_BOOT
#if MEASURED_BOOT || DRTM_SUPPORT
int crypto_mod_calc_hash(enum crypto_md_algo alg, void *data_ptr,
unsigned int data_len,
unsigned char output[CRYPTO_MD_MAX_SIZE]);
#endif /* MEASURED_BOOT */
#endif /* MEASURED_BOOT || DRTM_SUPPORT */
#if MEASURED_BOOT && TRUSTED_BOARD_BOOT
#if (MEASURED_BOOT || DRTM_SUPPORT) && TRUSTED_BOARD_BOOT
/* Macro to register a cryptographic library */
#define REGISTER_CRYPTO_LIB(_name, _init, _verify_signature, _verify_hash, \
_calc_hash, _auth_decrypt) \
@ -124,14 +124,14 @@ int crypto_mod_calc_hash(enum crypto_md_algo alg, void *data_ptr,
.verify_hash = _verify_hash, \
.auth_decrypt = _auth_decrypt \
}
#elif MEASURED_BOOT
#elif MEASURED_BOOT || DRTM_SUPPORT
#define REGISTER_CRYPTO_LIB(_name, _init, _calc_hash) \
const crypto_lib_desc_t crypto_lib_desc = { \
.name = _name, \
.init = _init, \
.calc_hash = _calc_hash, \
}
#endif /* MEASURED_BOOT && TRUSTED_BOARD_BOOT */
#endif /* (MEASURED_BOOT || DRTM_SUPPORT) && TRUSTED_BOARD_BOOT */
extern const crypto_lib_desc_t crypto_lib_desc;