auth_mod.h 1.37 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
8
#ifndef AUTH_MOD_H
#define AUTH_MOD_H
9
10
11

#if TRUSTED_BOARD_BOOT

12
13
14
15
#include <common/tbbr/cot_def.h>
#include <common/tbbr/tbbr_img_def.h>
#include <drivers/auth/auth_common.h>
#include <drivers/auth/img_parser_mod.h>
16

17
18
#include <lib/utils_def.h>

19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Image flags
 */
#define IMG_FLAG_AUTHENTICATED		(1 << 0)


/*
 * Authentication image descriptor
 */
typedef struct auth_img_desc_s {
	unsigned int img_id;
	img_type_t img_type;
31
	const struct auth_img_desc_s *parent;
32
33
	const auth_method_desc_t *const img_auth_methods;
	const auth_param_desc_t *const authenticated_data;
34
35
36
37
38
39
40
41
42
} auth_img_desc_t;

/* Public functions */
void auth_mod_init(void);
int auth_mod_get_parent_id(unsigned int img_id, unsigned int *parent_id);
int auth_mod_verify_img(unsigned int img_id,
			void *img_ptr,
			unsigned int img_len);

43
/* Macro to register a CoT defined as an array of auth_img_desc_t pointers */
44
#define REGISTER_COT(_cot) \
Sandrine Bailleux's avatar
Sandrine Bailleux committed
45
	const auth_img_desc_t *const *const cot_desc_ptr = (_cot); \
46
	const size_t cot_desc_size = ARRAY_SIZE(_cot);		   \
Roberto Vargas's avatar
Roberto Vargas committed
47
	unsigned int auth_img_flags[MAX_NUMBER_IDS]
48

Sandrine Bailleux's avatar
Sandrine Bailleux committed
49
extern const auth_img_desc_t *const *const cot_desc_ptr;
50
extern const size_t cot_desc_size;
Roberto Vargas's avatar
Roberto Vargas committed
51
52
extern unsigned int auth_img_flags[MAX_NUMBER_IDS];

53
54
#endif /* TRUSTED_BOARD_BOOT */

55
#endif /* AUTH_MOD_H */