Skip to content

Commit 001d054

Browse files
tomi-fontkartben
authored andcommitted
secure_storage: its: make definitions available outside of transform.h
Some ITS store module implementations may make use of them. This is the case of the custom one in the secure_storage.psa.its.secure_storage.custom.store test. Instead of making transform.h conditionally available, move the definitions to common.h and simply make them available whenever the ITS transform module is enabled. At the same time, remove unneeded/redundant includes/build asserts. Signed-off-by: Tomi Fontanilles <[email protected]>
1 parent 9379678 commit 001d054

File tree

7 files changed

+16
-25
lines changed

7 files changed

+16
-25
lines changed

subsys/secure_storage/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ if(CONFIG_SECURE_STORAGE_PS_IMPLEMENTATION_CUSTOM)
3131
make_available(ps.h)
3232
endif()
3333

34-
if(CONFIG_SECURE_STORAGE_ITS_TRANSFORM_IMPLEMENTATION_CUSTOM
35-
OR (CONFIG_SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_CUSTOM
36-
AND CONFIG_SECURE_STORAGE_ITS_TRANSFORM_MODULE))
34+
if(CONFIG_SECURE_STORAGE_ITS_TRANSFORM_IMPLEMENTATION_CUSTOM)
3735
make_available(its/transform.h)
3836
endif()
3937

subsys/secure_storage/include/internal/zephyr/secure_storage/its/common.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,19 @@ typedef struct {
2828
secure_storage_its_caller_id_t caller_id;
2929
} __packed secure_storage_its_uid_t;
3030

31+
#ifdef CONFIG_SECURE_STORAGE_ITS_TRANSFORM_MODULE
32+
33+
/** The maximum size, in bytes, of an entry's data after it has been transformed for storage. */
34+
enum { SECURE_STORAGE_ITS_TRANSFORM_MAX_STORED_DATA_SIZE
35+
= CONFIG_SECURE_STORAGE_ITS_MAX_DATA_SIZE
36+
+ sizeof(secure_storage_packed_create_flags_t)
37+
+ CONFIG_SECURE_STORAGE_ITS_TRANSFORM_OUTPUT_OVERHEAD };
38+
39+
/** The size, in bytes, of an entry's data given its size once transformed for storage. */
40+
#define SECURE_STORAGE_ITS_TRANSFORM_DATA_SIZE(transformed_data_size) \
41+
(transformed_data_size - (SECURE_STORAGE_ITS_TRANSFORM_MAX_STORED_DATA_SIZE \
42+
- CONFIG_SECURE_STORAGE_ITS_MAX_DATA_SIZE))
43+
44+
#endif /* CONFIG_SECURE_STORAGE_ITS_TRANSFORM_MODULE */
45+
3146
#endif

subsys/secure_storage/include/internal/zephyr/secure_storage/its/transform.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@
1313
*/
1414
#include <zephyr/secure_storage/its/common.h>
1515

16-
/** The maximum size, in bytes, of an entry's data after it has been transformed for storage. */
17-
enum { SECURE_STORAGE_ITS_TRANSFORM_MAX_STORED_DATA_SIZE
18-
= CONFIG_SECURE_STORAGE_ITS_MAX_DATA_SIZE
19-
+ sizeof(secure_storage_packed_create_flags_t)
20-
+ CONFIG_SECURE_STORAGE_ITS_TRANSFORM_OUTPUT_OVERHEAD };
21-
22-
#define SECURE_STORAGE_ITS_TRANSFORM_DATA_SIZE(stored_data_len) \
23-
(stored_data_len - (SECURE_STORAGE_ITS_TRANSFORM_MAX_STORED_DATA_SIZE \
24-
- CONFIG_SECURE_STORAGE_ITS_MAX_DATA_SIZE))
25-
2616
/** @brief Transforms the data of an ITS entry for storage.
2717
*
2818
* @param[in] uid The entry's UID.

subsys/secure_storage/src/its/store/settings.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include <errno.h>
1111
#include <stdio.h>
1212

13-
#ifdef CONFIG_SECURE_STORAGE_ITS_IMPLEMENTATION_ZEPHYR
14-
#include <zephyr/secure_storage/its/transform.h>
15-
#endif
16-
1713
LOG_MODULE_DECLARE(secure_storage, CONFIG_SECURE_STORAGE_LOG_LEVEL);
1814

1915
static int init_settings_subsys(void)

subsys/secure_storage/src/its/store/zms.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#include <zephyr/logging/log.h>
66
#include <zephyr/fs/zms.h>
77
#include <zephyr/storage/flash_map.h>
8-
#ifdef CONFIG_SECURE_STORAGE_ITS_IMPLEMENTATION_ZEPHYR
9-
#include <zephyr/secure_storage/its/transform.h>
10-
#endif
118

129
LOG_MODULE_DECLARE(secure_storage, CONFIG_SECURE_STORAGE_LOG_LEVEL);
1310

subsys/secure_storage/src/its/transform/aead.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ static psa_status_t psa_aead_crypt(psa_key_usage_t operation, secure_storage_its
5757
enum { CIPHERTEXT_MAX_SIZE
5858
= PSA_AEAD_ENCRYPT_OUTPUT_MAX_SIZE(CONFIG_SECURE_STORAGE_ITS_MAX_DATA_SIZE) };
5959

60-
BUILD_ASSERT(CONFIG_SECURE_STORAGE_ITS_TRANSFORM_OUTPUT_OVERHEAD
61-
== CIPHERTEXT_MAX_SIZE - CONFIG_SECURE_STORAGE_ITS_MAX_DATA_SIZE
62-
+ CONFIG_SECURE_STORAGE_ITS_TRANSFORM_AEAD_NONCE_SIZE);
63-
6460
BUILD_ASSERT(SECURE_STORAGE_ALL_CREATE_FLAGS
6561
<= (1 << (8 * sizeof(secure_storage_packed_create_flags_t))) - 1);
6662

tests/subsys/secure_storage/psa/its/src/custom_store.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* SPDX-License-Identifier: Apache-2.0
33
*/
44
#include <zephyr/secure_storage/its/store.h>
5-
#include <zephyr/secure_storage/its/transform.h>
65
#include <zephyr/sys/util.h>
76
#include <string.h>
87

0 commit comments

Comments
 (0)