MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClRsa_KeyTypes.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2022-2023 NXP */
3/* */
4/* SPDX-License-Identifier: BSD-3-Clause */
5/* */
6/* Redistribution and use in source and binary forms, with or without */
7/* modification, are permitted provided that the following conditions are */
8/* met: */
9/* */
10/* 1. Redistributions of source code must retain the above copyright */
11/* notice, this list of conditions and the following disclaimer. */
12/* */
13/* 2. Redistributions in binary form must reproduce the above copyright */
14/* notice, this list of conditions and the following disclaimer in the */
15/* documentation and/or other materials provided with the distribution. */
16/* */
17/* 3. Neither the name of the copyright holder nor the names of its */
18/* contributors may be used to endorse or promote products derived from */
19/* this software without specific prior written permission. */
20/* */
21/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32/*--------------------------------------------------------------------------*/
33
38
39#ifndef MCUXCLRSA_KEYTYPES_H_
40#define MCUXCLRSA_KEYTYPES_H_
41
42#include <mcuxClConfig.h> // Exported features flags header
43#include <stdint.h>
44#include <stdbool.h>
45
46#include <mcuxClKey_Types.h>
47#include <mcuxClRsa_Types.h>
48
49#include <mcuxCsslAnalysis.h>
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
61
62/**********************************************
63 * KEY TYPE DEFS
64 **********************************************/
65
66MCUX_CSSL_ANALYSIS_START_SUPPRESS_DECLARED_BUT_NEVER_REFERENCED("Consumed by user / customer. Hence, it is declared but never referenced. ")
67#if defined(MCUXCL_FEATURE_CIPHER_RSA_ENCRYPT)
68
75extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_1024;
76extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_2048;
77extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_3072;
78extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_4096; /* mcuxClRsa_KeyTypes_Public_Structures */
82
89static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_1024 = &mcuxClKey_TypeDescriptor_Rsa_Public_1024;
90static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_2048 = &mcuxClKey_TypeDescriptor_Rsa_Public_2048;
91static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_3072 = &mcuxClKey_TypeDescriptor_Rsa_Public_3072;
92static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_4096 = &mcuxClKey_TypeDescriptor_Rsa_Public_4096; /* mcuxClRsa_KeyTypes_Public_Pointers */
96#endif /* defined(MCUXCL_FEATURE_SIGNATURE_RSA_VERIFY) || defined(MCUXCL_FEATURE_CIPHER_RSA_ENCRYPT) || defined(MCUXCL_FEATURE_KEY_GENERATION_RSA) */
97
98#if defined(MCUXCL_FEATURE_CIPHER_RSA_DECRYPT)
99
106extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_1024;
107extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_2048;
108extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_3072;
109extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_4096; /* mcuxClRsa_KeyTypes_PrivatePlain_Structures */
113
120static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_1024 = &mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_1024;
121static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_2048 = &mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_2048;
122static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_3072 = &mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_3072;
123static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_4096 = &mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_4096; /* mcuxClRsa_KeyTypes_PrivatePlain_Pointers */
127
134extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_1024;
135extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_2048;
136extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_3072;
137extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_4096; /* mcuxClRsa_KeyTypes_PrivateCrt_Structures */
141
148static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_1024 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_1024;
149static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_2048 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_2048;
150static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_3072 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_3072;
151static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_4096 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_4096; /* mcuxClRsa_KeyTypes_PrivateCrt_Pointers */
155
162extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_1024;
163extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_2048;
164extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_3072;
165extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_4096; /* mcuxClRsa_KeyTypes_PrivateCrt_DFA_Structures */
169
176static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_1024 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_1024;
177static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_2048 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_2048;
178static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_3072 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_3072;
179static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_4096 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_4096; /* mcuxClRsa_KeyTypes_PrivateCrt_DFA_Pointers */
183
184#endif /* defined(MCUXCL_FEATURE_SIGNATURE_RSA_SIGN) || defined(MCUXCL_FEATURE_CIPHER_RSA_DECRYPT) || defined(MCUXCL_FEATURE_KEY_GENERATION_RSA) */
185
186MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DECLARED_BUT_NEVER_REFERENCED() /* mcuxClRsa_KeyTypes */
190
191
197/**********************************************
198 * MACROS AND DEFINITIONS TO SETUP RSA KEY
199 **********************************************/
200
201
209
222
223// TODO CLNS-6135: remove those definitions
224#define MCUXCLRSA_KEYSTRUCT_PLAIN_SIZE (sizeof(mcuxClRsa_KeyData_Plain_t))
225#define MCUXCLRSA_KEYSTRUCT_PLAIN_SIZE_IN_WORDS MCUXCLCORE_NUM_OF_CPUWORDS_CEIL(MCUXCLRSA_KEYSTRUCT_PLAIN_SIZE)
226#define MCUXCLRSA_KEYSTRUCT_CRT_SIZE (sizeof(mcuxClRsa_KeyData_Crt_t))
227#define MCUXCLRSA_KEYSTRUCT_CRT_SIZE_IN_WORDS MCUXCLCORE_NUM_OF_CPUWORDS_CEIL(MCUXCLRSA_KEYSTRUCT_CRT_SIZE) /* mcuxClRsa_KeyTypes */
231
232#ifdef __cplusplus
233} /* extern "C" */
234#endif
235
236#endif /* MCUXCLRSA_KEYTYPES_H_ */
Type definitions for the mcuxClKey component.
Type definitions for the mcuxClRsa component.
const mcuxClKey_TypeDescriptor_t * mcuxClKey_Type_t
Key type handle type.
Definition mcuxClKey_Types.h:131
struct mcuxClKey_TypeDescriptor mcuxClKey_TypeDescriptor_t
Key type descriptor type.
Definition mcuxClKey_Types.h:124
Structure type for Rsa plain key data.
Definition mcuxClRsa_KeyTypes.h:205
mcuxClRsa_KeyEntry_t modulus
Key entry for the modulus.
Definition mcuxClRsa_KeyTypes.h:206
mcuxClRsa_KeyEntry_t exponent
Key entry for the exponent - it can be the public or the private exponent, depending on the key type.
Definition mcuxClRsa_KeyTypes.h:207
Structure type for Rsa CRT key data.
Definition mcuxClRsa_KeyTypes.h:214
mcuxClRsa_KeyEntry_t e
Key entry for the public exponent E - it should be specified for a key type Rsa_PrivateCRT_DFA,...
Definition mcuxClRsa_KeyTypes.h:220
mcuxClRsa_KeyEntry_t dq
Key entry for the exponent DQ = D % (Q-1).
Definition mcuxClRsa_KeyTypes.h:219
mcuxClRsa_KeyEntry_t p
Key entry for the prime factor P.
Definition mcuxClRsa_KeyTypes.h:215
mcuxClRsa_KeyEntry_t dp
Key entry for the exponent DP = D % (P-1).
Definition mcuxClRsa_KeyTypes.h:218
mcuxClRsa_KeyEntry_t q
Key entry for the prime factor Q.
Definition mcuxClRsa_KeyTypes.h:216
mcuxClRsa_KeyEntry_t qInv
Key entry for the QInv = (1 / (Q % P)).
Definition mcuxClRsa_KeyTypes.h:217
Structure type for Rsa key entries, specifying key entry length and data.
Definition mcuxClRsa_Types.h:152