MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClCore_Toolchain.h
1/*--------------------------------------------------------------------------*/
2/* Copyright 2022-2023, 2026 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
14#ifndef MCUXCLCORE_TOOLCHAIN_H_
15#define MCUXCLCORE_TOOLCHAIN_H_
16
17#include <mcuxClCore_Platform.h>
19
20MCUX_CSSL_FP_FUNCTION_DEF(mcuxCl_Core_Swap64)
21static inline uint64_t mcuxCl_Core_Swap64(uint64_t value)
22{
23#if defined(__GNUC__) || defined(__clang__)
24 return __builtin_bswap64(value);
25#else
26 MCUX_CSSL_ANALYSIS_START_SUPPRESS_INTEGER_OVERFLOW("Offset calculations cannot overflow.")
27 return ((value >> 56) & 0x00000000000000FFULL) |
28 ((value >> 40) & 0x000000000000FF00ULL) |
29 ((value >> 24) & 0x0000000000FF0000ULL) |
30 ((value >> 8) & 0x00000000FF000000ULL) |
31 ((value << 8) & 0x000000FF00000000ULL) |
32 ((value << 24) & 0x0000FF0000000000ULL) |
33 ((value << 40) & 0x00FF000000000000ULL) |
34 ((value << 56) & 0xFF00000000000000ULL);
35 MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_INTEGER_OVERFLOW()
36#endif
37}
38
39MCUX_CSSL_FP_FUNCTION_DEF(mcuxCl_Core_Swap32)
40static inline uint32_t mcuxCl_Core_Swap32(uint32_t value)
41{
42#if defined(__GNUC__) || defined(__clang__)
43 return __builtin_bswap32(value);
44#else
45 MCUX_CSSL_ANALYSIS_START_SUPPRESS_INTEGER_OVERFLOW("Offset calculations cannot overflow.")
46 return ((value >> 24) & 0x000000FFUL) |
47 ((value << 24) & 0xFF000000UL) |
48 ((value >> 8) & 0x0000FF00UL) |
49 ((value << 8) & 0x00FF0000UL);
50 MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_INTEGER_OVERFLOW()
51#endif
52}
53
54
55#endif /* MCUXCLCORE_TOOLCHAIN_H_ */
Provides the API for the CSSL flow protection mechanism.
#define MCUX_CSSL_FP_FUNCTION_DEF(...)
Definition of a flow protected function.
Definition mcuxCsslFlowProtection.h:200