MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxCsslDataIntegrity_SecureCounter.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2023-2024 NXP */
3/* */
4/* NXP Confidential and Proprietary. This software is owned or controlled */
5/* by NXP and may only be used strictly in accordance with the applicable */
6/* license terms. By expressly accepting such terms or by downloading, */
7/* installing, activating and/or otherwise using the software, you are */
8/* agreeing that you have read, and that you agree to comply with and are */
9/* bound by, such license terms. If you do not agree to be bound by the */
10/* applicable license terms, then you may not retain, install, activate or */
11/* otherwise use the software. */
12/*--------------------------------------------------------------------------*/
13
18
19#ifndef MCUXCSSLDATAINTEGRITY_SECURECOUNTER_H_
20#define MCUXCSSLDATAINTEGRITY_SECURECOUNTER_H_
21
22#include <mcuxCsslAnalysis.h>
24
25#if (1 == MCUX_CSSL_SC_USE_SW_LOCAL) && (0 == MCUX_CSSL_FP_USE_SECURE_COUNTER)
26 #error "Local SW SC is not supported for DI when FP does not use this local SW SC, as SC_ALLOC would be missing."
27#endif
28
36
37
43
44
45/****************************************************************************/
46/* Constants */
47/****************************************************************************/
48
54#define MCUX_CSSL_DI_CHECK_PASSED_IMPL (MCUX_CSSL_SC_CHECK_PASSED)
55
61#define MCUX_CSSL_DI_CHECK_FAILED_IMPL (MCUX_CSSL_SC_CHECK_FAILED)
62
63
64/****************************************************************************/
65/* Macros that depend on the implementation of the secure counter mechanism */
66/****************************************************************************/
67
68#if (1 == MCUX_CSSL_SC_USE_HW_SCM)
77#define MCUX_CSSL_DI_BACKUP_SC(backupValue) \
78 uint32_t backupValue = MCUX_CSSL_SC_REF_VALUE_IMPL(); \
79 MCUX_CSSL_SC_REF_VALUE_IMPL() = MCUX_CSSL_SC_VALUE()
80
88#define MCUX_CSSL_DI_RESTORE_SC_REF(reference) \
89 MCUX_CSSL_SC_REF_VALUE_IMPL() = (reference)
90
91#else
99#define MCUX_CSSL_DI_BACKUP_SC(backupValue) \
100 uint32_t backupValue = MCUX_CSSL_SC_VALUE()
101
109#define MCUX_CSSL_DI_RESTORE_SC_REF(reference)
110
111#endif
112
113/****************************************************************************/
114/* Initialization */
115/****************************************************************************/
116
117#if (1 == MCUX_CSSL_FP_USE_SECURE_COUNTER)
129#define MCUX_CSSL_DI_INIT_IMPL(backupValue) \
130 uint32_t backupValue = 0u
131#else
143#define MCUX_CSSL_DI_INIT_IMPL(backupValue) \
144 MCUX_CSSL_DI_BACKUP_SC(backupValue)
145#endif
146
147
148/****************************************************************************/
149/* Check */
150/****************************************************************************/
151
161#define MCUX_CSSL_DI_CHECK_IMPL(reference) \
162 MCUX_CSSL_SC_CHECK(reference)
163
164#if (1 == MCUX_CSSL_FP_USE_SECURE_COUNTER)
176#define MCUX_CSSL_DI_CHECK_EXIT_IMPL(id, reference, fail) \
177 (void)(reference)
178#else
194#define MCUX_CSSL_DI_CHECK_EXIT_IMPL(id, reference, fail) \
195 if (MCUX_CSSL_DI_CHECK_PASSED != MCUX_CSSL_DI_CHECK(reference)) \
196 { \
197 MCUX_CSSL_FP_FUNCTION_EXIT(id, fail); \
198 } \
199 MCUX_CSSL_DI_RESTORE_SC_REF(reference);
200#endif
201
202
203/****************************************************************************/
204/* Updates */
205/****************************************************************************/
206
212
221#define MCUX_CSSL_DI_RECORD_IMPL(identifier, value) \
222 MCUX_CSSL_ANALYSIS_START_PATTERN_DI_CAST() \
223 MCUX_CSSL_SC_ADD(value) \
224 MCUX_CSSL_ANALYSIS_STOP_PATTERN_DI_CAST()
225
234#define MCUX_CSSL_DI_EXPUNGE_IMPL(identifier, value) \
235 MCUX_CSSL_ANALYSIS_START_PATTERN_DI_CAST() \
236 MCUX_CSSL_SC_SUB(value) \
237 MCUX_CSSL_ANALYSIS_STOP_PATTERN_DI_CAST()
238
239#endif /* MCUXCSSLDATAINTEGRITY_SECURECOUNTER_H_ */
Provides the API for the CSSL flow protection mechanism.