TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ps_utils.c
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 #include "ps_utils.h"
9 
11  uint32_t subset_offset,
12  uint32_t subset_size)
13 {
14  /* Check that subset_offset is valid */
15  if (subset_offset > superset_size) {
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)) {
25  }
26 
27  return PSA_SUCCESS;
28 }
#define PSA_SUCCESS
Definition: crypto_values.h:35
psa_status_t ps_utils_check_contained_in(uint32_t superset_size, uint32_t subset_offset, uint32_t subset_size)
Checks if a subset region is fully contained within a superset region.
Definition: ps_utils.c:10
#define PSA_ERROR_INVALID_ARGUMENT
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43