Mistake on this page?
Report an issue in GitHub or email us
rsa_alt.h
Go to the documentation of this file.
1 /**
2  * \file rsa_alt.h
3  *
4  * \brief This file provides an API for the RSA public-key cryptosystem.
5  *
6  * The RSA public-key cryptosystem is defined in <em>Public-Key
7  * Cryptography Standards (PKCS) #1 v1.5: RSA Encryption</em>
8  * and <em>Public-Key Cryptography Standards (PKCS) #1 v2.1:
9  * RSA Cryptography Specifications</em>.
10  *
11  */
12 /*
13  * Copyright The Mbed TLS Contributors
14  * SPDX-License-Identifier: Apache-2.0
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28 #ifndef MBEDTLS_RSA_ALT_H
29 #define MBEDTLS_RSA_ALT_H
30 
31 #if !defined(MBEDTLS_CONFIG_FILE)
32 #include "mbedtls/config.h"
33 #else
34 #include MBEDTLS_CONFIG_FILE
35 #endif
36 
37 #include "mbedtls/bignum.h"
38 #include "mbedtls/md.h"
39 
40 #if defined(MBEDTLS_THREADING_C)
41 #include "mbedtls/threading.h"
42 #endif
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #if defined(MBEDTLS_RSA_ALT)
49 // Regular implementation
50 //
51 
52 /* Enable Nuvoton's Crypto RSA H/W */
53 #define NU_CRYPTO_RSA_ENABLE
54 
55 /**
56  * \brief The RSA context structure.
57  *
58  * \note Direct manipulation of the members of this structure
59  * is deprecated. All manipulation should instead be done through
60  * the public interface functions.
61  */
62 typedef struct mbedtls_rsa_context
63 {
64  int ver; /*!< Always 0.*/
65  size_t len; /*!< The size of \p N in Bytes. */
66 
67  mbedtls_mpi N; /*!< The public modulus. */
68  mbedtls_mpi E; /*!< The public exponent. */
69 
70  mbedtls_mpi D; /*!< The private exponent. */
71  mbedtls_mpi P; /*!< The first prime factor. */
72  mbedtls_mpi Q; /*!< The second prime factor. */
73 
74  mbedtls_mpi DP; /*!< <code>D % (P - 1)</code>. */
75  mbedtls_mpi DQ; /*!< <code>D % (Q - 1)</code>. */
76  mbedtls_mpi QP; /*!< <code>1 / (Q % P)</code>. */
77 
78  mbedtls_mpi RN; /*!< cached <code>R^2 mod N</code>. */
79 
80  mbedtls_mpi RP; /*!< cached <code>R^2 mod P</code>. */
81  mbedtls_mpi RQ; /*!< cached <code>R^2 mod Q</code>. */
82 
83  mbedtls_mpi Vi; /*!< The cached blinding value. */
84  mbedtls_mpi Vf; /*!< The cached un-blinding value. */
85 
86  int padding; /*!< Selects padding mode:
87  #MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
88  #MBEDTLS_RSA_PKCS_V21 for OAEP or PSS. */
89  int hash_id; /*!< Hash identifier of mbedtls_md_type_t type,
90  as specified in md.h for use in the MGF
91  mask generating function used in the
92  EME-OAEP and EMSA-PSS encodings. */
93 #if defined(MBEDTLS_THREADING_C)
94  mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex. */
95 #endif
96 
97 #if defined(NU_CRYPTO_RSA_ENABLE)
98  int hw_init; /*!< Initialized Crypto RSA H/W or not. */
99 #endif
100 }
101 mbedtls_rsa_context;
102 
103 #endif /* MBEDTLS_RSA_ALT */
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* rsa_alt.h */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.