TF-M Reference Manual
1.2.0
TrustedFirmware-M
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
its_utils.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017-2019, Arm Limited. All rights reserved.
3
*
4
* SPDX-License-Identifier: BSD-3-Clause
5
*
6
*/
7
8
#include "
its_utils.h
"
9
10
psa_status_t
its_utils_check_contained_in
(
size_t
superset_size,
11
size_t
subset_offset,
12
size_t
subset_size)
13
{
14
/* Check that subset_offset is valid */
15
if
(subset_offset > superset_size) {
16
return
PSA_ERROR_INVALID_ARGUMENT
;
17
}
18
19
/* Check that subset_offset + subset_size fits in superset_size.
20
* The previous check passed, so we know that subset_offset <= superset_size
21
* and so the right hand side of the inequality cannot underflow.
22
*/
23
if
(subset_size > (superset_size - subset_offset)) {
24
return
PSA_ERROR_INVALID_ARGUMENT
;
25
}
26
27
return
PSA_SUCCESS
;
28
}
29
30
psa_status_t
its_utils_validate_fid
(
const
uint8_t *fid)
31
{
32
uint32_t fid_size =
ITS_FILE_ID_SIZE
;
33
34
/* A file ID is valid if it is non-zero */
35
while
(fid_size--) {
36
if
(*fid++) {
37
return
PSA_SUCCESS
;
38
}
39
}
40
41
return
PSA_ERROR_DOES_NOT_EXIST
;
42
}
PSA_SUCCESS
#define PSA_SUCCESS
Definition:
crypto_values.h:35
its_utils.h
its_utils_validate_fid
psa_status_t its_utils_validate_fid(const uint8_t *fid)
Validates file ID.
Definition:
its_utils.c:30
PSA_ERROR_INVALID_ARGUMENT
#define PSA_ERROR_INVALID_ARGUMENT
Definition:
crypto_values.h:116
its_utils_check_contained_in
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
ITS_FILE_ID_SIZE
#define ITS_FILE_ID_SIZE
Definition:
its_utils.h:20
PSA_ERROR_DOES_NOT_EXIST
#define PSA_ERROR_DOES_NOT_EXIST
Definition:
crypto_values.h:89
psa_status_t
int32_t psa_status_t
Function return status.
Definition:
crypto_types.h:43
secure_fw
partitions
internal_trusted_storage
its_utils.c
Generated on Thu Feb 18 2021 13:29:10 for TF-M Reference Manual by
1.8.6