xref: /rk3399_ARM-atf/include/drivers/auth/auth_mod.h (revision 6f8a2565593f602bfe9f6069f086960f8cc745cd)
105799ae0SJuan Castillo /*
2*6f8a2565SSandrine Bailleux  * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
305799ae0SJuan Castillo  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
505799ae0SJuan Castillo  */
605799ae0SJuan Castillo 
7c3cf06f1SAntonio Nino Diaz #ifndef AUTH_MOD_H
8c3cf06f1SAntonio Nino Diaz #define AUTH_MOD_H
905799ae0SJuan Castillo 
1005799ae0SJuan Castillo #if TRUSTED_BOARD_BOOT
1105799ae0SJuan Castillo 
1209d40e0eSAntonio Nino Diaz #include <common/tbbr/cot_def.h>
1309d40e0eSAntonio Nino Diaz #include <common/tbbr/tbbr_img_def.h>
1409d40e0eSAntonio Nino Diaz #include <drivers/auth/auth_common.h>
1509d40e0eSAntonio Nino Diaz #include <drivers/auth/img_parser_mod.h>
1605799ae0SJuan Castillo 
17*6f8a2565SSandrine Bailleux #include <lib/utils_def.h>
18*6f8a2565SSandrine Bailleux 
1905799ae0SJuan Castillo /*
2005799ae0SJuan Castillo  * Image flags
2105799ae0SJuan Castillo  */
2205799ae0SJuan Castillo #define IMG_FLAG_AUTHENTICATED		(1 << 0)
2305799ae0SJuan Castillo 
2405799ae0SJuan Castillo 
2505799ae0SJuan Castillo /*
2605799ae0SJuan Castillo  * Authentication image descriptor
2705799ae0SJuan Castillo  */
2805799ae0SJuan Castillo typedef struct auth_img_desc_s {
2905799ae0SJuan Castillo 	unsigned int img_id;
3005799ae0SJuan Castillo 	img_type_t img_type;
31b313d755SSoby Mathew 	const struct auth_img_desc_s *parent;
3230070427SJoel Hutton 	const auth_method_desc_t *const img_auth_methods;
3330070427SJoel Hutton 	const auth_param_desc_t *const authenticated_data;
3405799ae0SJuan Castillo } auth_img_desc_t;
3505799ae0SJuan Castillo 
3605799ae0SJuan Castillo /* Public functions */
3705799ae0SJuan Castillo void auth_mod_init(void);
3805799ae0SJuan Castillo int auth_mod_get_parent_id(unsigned int img_id, unsigned int *parent_id);
3905799ae0SJuan Castillo int auth_mod_verify_img(unsigned int img_id,
4005799ae0SJuan Castillo 			void *img_ptr,
4105799ae0SJuan Castillo 			unsigned int img_len);
4205799ae0SJuan Castillo 
430b6377d1SJoel Hutton /* Macro to register a CoT defined as an array of auth_img_desc_t pointers */
4405799ae0SJuan Castillo #define REGISTER_COT(_cot) \
452efb7ddcSSandrine Bailleux 	const auth_img_desc_t *const *const cot_desc_ptr = (_cot); \
46*6f8a2565SSandrine Bailleux 	const size_t cot_desc_size = ARRAY_SIZE(_cot);		   \
47735181b6SRoberto Vargas 	unsigned int auth_img_flags[MAX_NUMBER_IDS]
4805799ae0SJuan Castillo 
492efb7ddcSSandrine Bailleux extern const auth_img_desc_t *const *const cot_desc_ptr;
50*6f8a2565SSandrine Bailleux extern const size_t cot_desc_size;
513b94189aSRoberto Vargas extern unsigned int auth_img_flags[MAX_NUMBER_IDS];
523b94189aSRoberto Vargas 
5305799ae0SJuan Castillo #endif /* TRUSTED_BOARD_BOOT */
5405799ae0SJuan Castillo 
55c3cf06f1SAntonio Nino Diaz #endif /* AUTH_MOD_H */
56