Mbed OS Reference
Loading...
Searching...
No Matches
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
45extern "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 */
62typedef 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}
102
103#endif /* MBEDTLS_RSA_ALT */
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif /* rsa_alt.h */
Multi-precision integer library.
Configuration options (set of defines)
This file contains the generic message-digest wrapper.
MPI structure.
Definition: bignum.h:185
The RSA context structure.
Definition: rsa.h:106
mbedtls_mpi N
Definition: rsa.h:110
mbedtls_mpi P
Definition: rsa.h:114
mbedtls_mpi Vi
Definition: rsa.h:126
mbedtls_mpi D
Definition: rsa.h:113
mbedtls_mpi RP
Definition: rsa.h:123
mbedtls_mpi Vf
Definition: rsa.h:127
mbedtls_mpi DQ
Definition: rsa.h:118
size_t len
Definition: rsa.h:108
mbedtls_mpi DP
Definition: rsa.h:117
mbedtls_mpi QP
Definition: rsa.h:119
mbedtls_mpi Q
Definition: rsa.h:115
mbedtls_mpi RN
Definition: rsa.h:121
mbedtls_mpi RQ
Definition: rsa.h:124
mbedtls_mpi E
Definition: rsa.h:111
Threading abstraction layer.