Mbed OS Reference
Loading...
Searching...
No Matches
crypto_rsa_hw.h
1
/*
2
* Copyright (c) 2022, Nuvoton Technology Corporation
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
#ifndef CRYPTO_RSA_HW_H
20
#define CRYPTO_RSA_HW_H
21
22
#include "
mbedtls/rsa.h
"
23
24
#if defined(MBEDTLS_RSA_ALT)
25
26
#include <stdbool.h>
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
31
32
/**
33
* \brief Initialize/Free Crypto RSA H/W
34
*
35
* \return \c 0 on success.
36
* \return A non-zero error code on failure.
37
*
38
* \note crypto_rsa_init()/crypto_rsa_free() are like pre-op/post-op calls
39
* and they guarantee:
40
*
41
* 1. Paired
42
* 2. No overlapping
43
* 3. Upper public function cannot return when RSA alter. is still activated.
44
*/
45
int
crypto_rsa_init(
mbedtls_rsa_context
*ctx);
46
void
crypto_rsa_free(
mbedtls_rsa_context
*ctx);
47
48
/**
49
* \brief Query whether or not RSA H/W supports encrypt/decrypt operation in this context
50
* in normal/CRT algorithm
51
*
52
* \param ctx The initialized RSA context to use.
53
* \param decrypt true for decrypt, or encrypt.
54
* \param crt true for CRT algorithm, or normal.
55
* \param blinding Blinding (SCAP) or not.
56
*
57
* \return \c 1 on capable, or 0 on incapable.
58
*
59
* \note Blinding is applicable only for decrypt operation.
60
* \note CRT is applicable only for decrypt operation.
61
*/
62
int
crypto_rsa_encrypt_norm_capable(
const
mbedtls_rsa_context
*ctx);
63
int
crypto_rsa_decrypt_norm_capable(
const
mbedtls_rsa_context
*ctx,
bool
blinding);
64
int
crypto_rsa_decrypt_crt_capable(
const
mbedtls_rsa_context
*ctx,
bool
blinding);
65
int
crypto_rsa_crypt_capable(
const
mbedtls_rsa_context
*ctx,
66
bool
decrypt,
67
bool
crt,
68
bool
blinding);
69
/**
70
* \brief Run RSA encrypt/decrypt operation in normal/CRT algorithm
71
*
72
* \param ctx The initialized RSA context to use.
73
* \param decrypt true for decrypt, or encrypt.
74
* \param crt true for CRT algorithm, or normal.
75
* \param blinding Blinding (SCAP) or not.
76
* \param input The input buffer. This must be a readable buffer
77
* of length \c ctx->len Bytes. For example, \c 256 Bytes
78
* for an 2048-bit RSA modulus.
79
* \param output The output buffer. This must be a writable buffer
80
* of length \c ctx->len Bytes. For example, \c 256 Bytes
81
* for an 2048-bit RSA modulus.
82
*
83
* \return \c 0 on success.
84
* \return An \c MBEDTLS_ERR_RSA_XXX error code on failure.
85
*/
86
int
crypto_rsa_encrypt_norm(
mbedtls_rsa_context
*ctx,
87
const
unsigned
char
*input,
88
unsigned
char
*output);
89
int
crypto_rsa_decrypt_norm(
mbedtls_rsa_context
*ctx,
90
bool
blinding,
91
const
unsigned
char
*input,
92
unsigned
char
*output);
93
int
crypto_rsa_decrypt_crt(
mbedtls_rsa_context
*ctx,
94
bool
blinding,
95
const
unsigned
char
*input,
96
unsigned
char
*output);
97
int
crypto_rsa_crypt(
mbedtls_rsa_context
*ctx,
98
bool
decrypt,
99
bool
crt,
100
bool
blinding,
101
const
unsigned
char
*input,
102
unsigned
char
*output);
103
104
/**
105
* \brief Abort Crypto RSA H/W
106
*
107
* \param ctx The initialized RSA context to use.
108
* \param timeout_us Timeout in microseconds.
109
*
110
* \return \c 0 on success.
111
* \return A non-zero error code on failure.
112
*/
113
int
crypto_rsa_abort(
mbedtls_rsa_context
*ctx,
114
uint32_t timeout_us);
115
116
#ifdef __cplusplus
117
}
118
#endif
119
120
#endif
/* MBEDTLS_RSA_ALT */
121
122
#endif
/* CRYPTO_RSA_HW_H */
rsa.h
This file provides an API for the RSA public-key cryptosystem.
mbedtls_rsa_context
The RSA context structure.
Definition:
rsa.h:106
connectivity
drivers
mbedtls
TARGET_NUVOTON
TARGET_M460
rsa
crypto_rsa_hw.h
Generated by
1.9.5