Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 1 | /* |
Sandrine Bailleux | 4bca140 | 2020-03-25 11:22:34 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2020, 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 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef AUTH_MOD_H |
| 8 | #define AUTH_MOD_H |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 9 | |
| 10 | #if TRUSTED_BOARD_BOOT |
| 11 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | #include <common/tbbr/cot_def.h> |
| 13 | #include <common/tbbr/tbbr_img_def.h> |
| 14 | #include <drivers/auth/auth_common.h> |
| 15 | #include <drivers/auth/img_parser_mod.h> |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 16 | |
Sandrine Bailleux | 4bca140 | 2020-03-25 11:22:34 +0100 | [diff] [blame] | 17 | #include <lib/utils_def.h> |
| 18 | |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 19 | /* |
| 20 | * Image flags |
| 21 | */ |
| 22 | #define IMG_FLAG_AUTHENTICATED (1 << 0) |
| 23 | |
| 24 | |
| 25 | /* |
| 26 | * Authentication image descriptor |
| 27 | */ |
| 28 | typedef struct auth_img_desc_s { |
| 29 | unsigned int img_id; |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 30 | img_type_t img_type; |
Soby Mathew | 6d4f262 | 2016-01-12 10:30:59 +0000 | [diff] [blame] | 31 | const struct auth_img_desc_s *parent; |
Joel Hutton | 69931af | 2019-03-11 11:37:38 +0000 | [diff] [blame] | 32 | const auth_method_desc_t *const img_auth_methods; |
| 33 | const auth_param_desc_t *const authenticated_data; |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 34 | } auth_img_desc_t; |
| 35 | |
| 36 | /* Public functions */ |
| 37 | void auth_mod_init(void); |
| 38 | int auth_mod_get_parent_id(unsigned int img_id, unsigned int *parent_id); |
| 39 | int auth_mod_verify_img(unsigned int img_id, |
| 40 | void *img_ptr, |
| 41 | unsigned int img_len); |
| 42 | |
Joel Hutton | e9919bb | 2019-02-20 11:56:46 +0000 | [diff] [blame] | 43 | /* Macro to register a CoT defined as an array of auth_img_desc_t pointers */ |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 44 | #define REGISTER_COT(_cot) \ |
Sandrine Bailleux | 25532c7 | 2019-06-07 14:33:51 +0200 | [diff] [blame] | 45 | const auth_img_desc_t *const *const cot_desc_ptr = (_cot); \ |
Sandrine Bailleux | 4bca140 | 2020-03-25 11:22:34 +0100 | [diff] [blame] | 46 | const size_t cot_desc_size = ARRAY_SIZE(_cot); \ |
Roberto Vargas | be126ed | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 47 | unsigned int auth_img_flags[MAX_NUMBER_IDS] |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 48 | |
Sandrine Bailleux | 25532c7 | 2019-06-07 14:33:51 +0200 | [diff] [blame] | 49 | extern const auth_img_desc_t *const *const cot_desc_ptr; |
Sandrine Bailleux | 4bca140 | 2020-03-25 11:22:34 +0100 | [diff] [blame] | 50 | extern const size_t cot_desc_size; |
Roberto Vargas | 52f707f | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 51 | extern unsigned int auth_img_flags[MAX_NUMBER_IDS]; |
| 52 | |
Juan Castillo | 8e55d93 | 2015-04-02 09:48:16 +0100 | [diff] [blame] | 53 | #endif /* TRUSTED_BOARD_BOOT */ |
| 54 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 55 | #endif /* AUTH_MOD_H */ |