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-2024, 2026 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
55
56/**********************************************
57 * KEY TYPE DEFS
58 **********************************************/
59
66
67MCUX_CSSL_ANALYSIS_START_SUPPRESS_DECLARED_BUT_NEVER_REFERENCED("Consumed by user / customer. Hence, it is declared but never referenced. ")
68
69
79#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
80extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_6144;
81extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_8192;
82#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_Public_Structures */
86
100#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
104static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_6144 = &mcuxClKey_TypeDescriptor_Rsa_Public_6144;
105static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_8192 = &mcuxClKey_TypeDescriptor_Rsa_Public_8192;
106#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_Public_Pointers */
110
111/* TODO CLNS-15273: the condition of defined(MCUXCL_FEATURE_RSA_SWONLY) shall be removed after SIGNATURE_RSA_SIGN or CIPHER_RSA_DECRYPT is enabled for NCCL */
112
123#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
124extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_6144;
125extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_8192;
126#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_PrivatePlain_Structures */
130
144#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
148static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_6144 = &mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_6144;
149static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_8192 = &mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_8192;
150#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_PrivatePlain_Pointers */
154
165#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
166extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_6144;
167extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_8192;
168#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_PrivateCrt_Structures */
172
186#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
190static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_6144 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_6144;
191static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_8192 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_8192;
192#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_PrivateCrt_Pointers */
196
207#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
208extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_6144;
209extern const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_8192;
210#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_PrivateCrt_DFA_Structures */
214
228#ifdef MCUXCL_FEATURE_RSA_8K_KEYS
232static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_6144 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_6144;
233static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_8192 = &mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_8192;
234#endif /* MCUXCL_FEATURE_RSA_8K_KEYS */ /* mcuxClRsa_KeyTypes_PrivateCrt_DFA_Pointers */
238
239
240MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DECLARED_BUT_NEVER_REFERENCED() /* mcuxClRsa_KeyTypes */
244
245
246/**********************************************
247 * KEY ENCODING DEFS
248 **********************************************/
249
250MCUX_CSSL_ANALYSIS_START_SUPPRESS_DECLARED_BUT_NEVER_REFERENCED("Consumed by user / customer. Hence, it is declared but never referenced. ")
251
256static const mcuxClKey_Encoding_t mcuxClRsa_Encoding_PrivPlainKey_Plain = &mcuxClRsa_EncodingDescriptor_PrivPlainKey_Plain;
257
262static const mcuxClKey_Encoding_t mcuxClRsa_Encoding_PublicKey_Plain = &mcuxClRsa_EncodingDescriptor_PublicKey_Plain;
263
268static const mcuxClKey_Encoding_t mcuxClRsa_Encoding_PrivCrtKey_Plain = &mcuxClRsa_EncodingDescriptor_PrivCrtKey_Plain;
269
270MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DECLARED_BUT_NEVER_REFERENCED()
271
272/**********************************************
273 * MACROS AND DEFINITIONS TO SETUP RSA KEY
274 **********************************************/
275
282
286typedef struct
287{
288 mcuxClRsa_KeyEntry_t modulus;
289 mcuxClRsa_KeyEntry_t exponent;
291
295typedef struct
296{
297 mcuxClRsa_KeyEntry_t p;
298 mcuxClRsa_KeyEntry_t q;
299 mcuxClRsa_KeyEntry_t qInv;
300 mcuxClRsa_KeyEntry_t dp;
301 mcuxClRsa_KeyEntry_t dq;
302 mcuxClRsa_KeyEntry_t e;
304
305// TODO CLNS-9057: remove those definitions
306#define MCUXCLRSA_KEYSTRUCT_PLAIN_SIZE (sizeof(mcuxClRsa_KeyData_Plain_t))
307#define MCUXCLRSA_KEYSTRUCT_CRT_SIZE (sizeof(mcuxClRsa_KeyData_Crt_t))
308 /* mcuxClRsa_KeyData */
312
313
314
315#ifdef __cplusplus
316} /* extern "C" */
317#endif
318
319#endif /* MCUXCLRSA_KEYTYPES_H_ */
Type definitions for the mcuxClKey component.
const mcuxClKey_EncodingDescriptor_t mcuxClRsa_EncodingDescriptor_PrivPlainKey_Plain
Plain encoding descriptor for RSA private plain keys.
const mcuxClKey_EncodingDescriptor_t mcuxClRsa_EncodingDescriptor_PrivCrtKey_Plain
Plain encoding descriptor for RSA private CRT keys.
const mcuxClKey_EncodingDescriptor_t mcuxClRsa_EncodingDescriptor_PublicKey_Plain
Plain encoding descriptor for RSA public keys.
Type definitions for the mcuxClRsa component.
const mcuxClKey_EncodingDescriptor_t * mcuxClKey_Encoding_t
Key encoding mechanism type.
Definition mcuxClKey_Types.h:164
struct mcuxClKey_EncodingDescriptor mcuxClKey_EncodingDescriptor_t
Key encoding mechanism descriptor type.
Definition mcuxClKey_Types.h:157
const mcuxClKey_TypeDescriptor_t * mcuxClKey_Type_t
Key type handle type.
Definition mcuxClKey_Types.h:134
struct mcuxClKey_TypeDescriptor mcuxClKey_TypeDescriptor_t
Key type descriptor type.
Definition mcuxClKey_Types.h:127
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_3072
Key type structure for RSA public key and key size 3072 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_1024
Key type structure for RSA public key and key size 1024 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_4096
Key type structure for RSA public key and key size 4096 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_Public_2048
Key type structure for RSA public key and key size 2048 bits.
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_2048
Key type pointer for RSA public key and key size 2048 bits.
Definition mcuxClRsa_KeyTypes.h:97
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_3072
Key type pointer for RSA public key and key size 3072 bits.
Definition mcuxClRsa_KeyTypes.h:98
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_4096
Key type pointer for RSA public key and key size 4096 bits.
Definition mcuxClRsa_KeyTypes.h:99
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_Public_1024
Key type pointer for RSA public key and key size 1024 bits.
Definition mcuxClRsa_KeyTypes.h:96
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_1024
Key type structure for RSA private plain key and key size 1024 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_2048
Key type structure for RSA private plain key and key size 2048 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_3072
Key type structure for RSA private plain key and key size 3072 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivatePlain_4096
Key type structure for RSA private plain key and key size 4096 bits.
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_4096
Key type pointer for RSA private plain key and key size 4096 bits.
Definition mcuxClRsa_KeyTypes.h:143
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_3072
Key type pointer for RSA private plain key and key size 3072 bits.
Definition mcuxClRsa_KeyTypes.h:142
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_2048
Key type pointer for RSA private plain key and key size 2048 bits.
Definition mcuxClRsa_KeyTypes.h:141
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivatePlain_1024
Key type pointer for RSA private plain key and key size 1024 bits.
Definition mcuxClRsa_KeyTypes.h:140
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_4096
Key type structure for RSA private CRT key and key size 4096 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_2048
Key type structure for RSA private CRT key and key size 2048 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_3072
Key type structure for RSA private CRT key and key size 3072 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_1024
Key type structure for RSA private CRT key and key size 1024 bits.
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_1024
Key type pointer for RSA private CRT key and key size 1024 bits.
Definition mcuxClRsa_KeyTypes.h:182
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_2048
Key type pointer for RSA private CRT key and key size 2048 bits.
Definition mcuxClRsa_KeyTypes.h:183
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_4096
Key type pointer for RSA private CRT key and key size 4096 bits.
Definition mcuxClRsa_KeyTypes.h:185
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_3072
Key type pointer for RSA private CRT key and key size 3072 bits.
Definition mcuxClRsa_KeyTypes.h:184
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_1024
Key type structure for RSA private CRT_DFA key and key size 1024 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_4096
Key type structure for RSA private CRT_DFA key and key size 4096 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_2048
Key type structure for RSA private CRT_DFA key and key size 2048 bits.
const mcuxClKey_TypeDescriptor_t mcuxClKey_TypeDescriptor_Rsa_PrivateCRT_DFA_3072
Key type structure for RSA private CRT_DFA key and key size 3072 bits.
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_1024
Key type pointer for RSA private CRT_DFA key and key size 1024 bits.
Definition mcuxClRsa_KeyTypes.h:224
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_3072
Key type pointer for RSA private CRT_DFA key and key size 3072 bits.
Definition mcuxClRsa_KeyTypes.h:226
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_4096
Key type pointer for RSA private CRT_DFA key and key size 4096 bits.
Definition mcuxClRsa_KeyTypes.h:227
static const mcuxClKey_Type_t mcuxClKey_Type_Rsa_PrivateCRT_DFA_2048
Key type pointer for RSA private CRT_DFA key and key size 2048 bits.
Definition mcuxClRsa_KeyTypes.h:225
Structure type for Rsa plain key data.
Definition mcuxClRsa_KeyTypes.h:287
mcuxClRsa_KeyEntry_t modulus
Key entry for the modulus.
Definition mcuxClRsa_KeyTypes.h:288
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:289
Structure type for Rsa CRT key data.
Definition mcuxClRsa_KeyTypes.h:296
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:302
mcuxClRsa_KeyEntry_t dq
Key entry for the exponent DQ = D % (Q-1).
Definition mcuxClRsa_KeyTypes.h:301
mcuxClRsa_KeyEntry_t p
Key entry for the prime factor P.
Definition mcuxClRsa_KeyTypes.h:297
mcuxClRsa_KeyEntry_t dp
Key entry for the exponent DP = D % (P-1).
Definition mcuxClRsa_KeyTypes.h:300
mcuxClRsa_KeyEntry_t q
Key entry for the prime factor Q.
Definition mcuxClRsa_KeyTypes.h:298
mcuxClRsa_KeyEntry_t qInv
Key entry for the QInv = (1 / (Q % P)).
Definition mcuxClRsa_KeyTypes.h:299