Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 1 | /* |
Roberto Vargas | be126ed | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __AUTH_MOD_H__ |
| 8 | #define __AUTH_MOD_H__ |
| 9 | |
| 10 | #if TRUSTED_BOARD_BOOT |
| 11 | |
| 12 | #include <auth_common.h> |
| 13 | #include <cot_def.h> |
| 14 | #include <img_parser_mod.h> |
Roberto Vargas | be126ed | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 15 | #include <tbbr_img_def.h> |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * Image flags |
| 19 | */ |
| 20 | #define IMG_FLAG_AUTHENTICATED (1 << 0) |
| 21 | |
| 22 | |
| 23 | /* |
| 24 | * Authentication image descriptor |
| 25 | */ |
| 26 | typedef struct auth_img_desc_s { |
| 27 | unsigned int img_id; |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 28 | img_type_t img_type; |
Soby Mathew | 6d4f262 | 2016-01-12 10:30:59 +0000 | [diff] [blame] | 29 | const struct auth_img_desc_s *parent; |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 30 | auth_method_desc_t img_auth_methods[AUTH_METHOD_NUM]; |
| 31 | auth_param_desc_t authenticated_data[COT_MAX_VERIFIED_PARAMS]; |
| 32 | } auth_img_desc_t; |
| 33 | |
| 34 | /* Public functions */ |
| 35 | void auth_mod_init(void); |
| 36 | int auth_mod_get_parent_id(unsigned int img_id, unsigned int *parent_id); |
| 37 | int auth_mod_verify_img(unsigned int img_id, |
| 38 | void *img_ptr, |
| 39 | unsigned int img_len); |
| 40 | |
| 41 | /* Macro to register a CoT defined as an array of auth_img_desc_t */ |
| 42 | #define REGISTER_COT(_cot) \ |
| 43 | const auth_img_desc_t *const cot_desc_ptr = \ |
| 44 | (const auth_img_desc_t *const)&_cot[0]; \ |
Roberto Vargas | be126ed | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 45 | unsigned int auth_img_flags[MAX_NUMBER_IDS] |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 46 | |
Roberto Vargas | 52f707f | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 47 | extern const auth_img_desc_t *const cot_desc_ptr; |
| 48 | extern unsigned int auth_img_flags[MAX_NUMBER_IDS]; |
| 49 | |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 50 | #endif /* TRUSTED_BOARD_BOOT */ |
| 51 | |
| 52 | #endif /* __AUTH_MOD_H__ */ |