TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
its_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __ITS_UTILS_H__
9 #define __ITS_UTILS_H__
10 
11 #include <stddef.h>
12 #include <stdint.h>
13 
14 #include "psa/error.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define ITS_FILE_ID_SIZE 12
21 #define ITS_DEFAULT_EMPTY_BUFF_VAL 0
22 
35 #define ITS_UTILS_BOUND_CHECK(err_msg, data_size, data_buf_size) \
36 typedef char err_msg[(data_size <= data_buf_size)*2 - 1]
37 
41 #define ITS_UTILS_MIN(x, y) (((x) < (y)) ? (x) : (y))
42 
46 #define ITS_UTILS_MAX(x, y) (((x) > (y)) ? (x) : (y))
47 
56 #define ITS_UTILS_ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
57 
66 #define ITS_UTILS_IS_ALIGNED(x, a) (((x) & ((a) - 1)) == 0)
67 
82 psa_status_t its_utils_check_contained_in(size_t superset_size,
83  size_t subset_offset,
84  size_t subset_size);
85 
93 psa_status_t its_utils_validate_fid(const uint8_t *fid);
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* __ITS_UTILS_H__ */
psa_status_t its_utils_check_contained_in(size_t superset_size, size_t subset_offset, size_t subset_size)
Checks if a subset region is fully contained within a superset region.
Definition: its_utils.c:10
Standard error codes for the SPM and RoT Services.
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
psa_status_t its_utils_validate_fid(const uint8_t *fid)
Validates file ID.
Definition: its_utils.c:30