blob: 705d16384a82508fde78ba0ae3cadbc98466673d [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file rsa.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief The RSA public-key cryptosystem
5 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02007 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000020 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000021 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#ifndef MBEDTLS_RSA_H
24#define MBEDTLS_RSA_H
Paul Bakker5121ce52009-01-03 21:22:43 +000025
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakkered27a042013-04-18 22:46:23 +020027#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020028#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020030#endif
Paul Bakkered27a042013-04-18 22:46:23 +020031
Paul Bakker314052f2011-08-15 09:07:52 +000032#include "bignum.h"
Paul Bakkerc70b9822013-04-07 22:00:46 +020033#include "md.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000034
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020035#if defined(MBEDTLS_THREADING_C)
Paul Bakkerc9965dc2013-09-29 14:58:17 +020036#include "threading.h"
37#endif
38
Paul Bakker13e2dfe2009-07-28 07:18:38 +000039/*
40 * RSA Error codes
41 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020042#define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */
43#define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */
44#define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */
Manuel Pégourié-Gonnardeecb43c2015-05-12 12:56:41 +020045#define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the library's validity check. */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020046#define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */
47#define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */
48#define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */
49#define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */
50#define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */
Hanno Becker91c194d2017-09-29 12:50:12 +010051#define MBEDTLS_ERR_RSA_EXPORT_UNSUPPORTED -0x4500 /**< The requested parameter export is not possible/allowed. */
Paul Bakker5121ce52009-01-03 21:22:43 +000052
53/*
Paul Bakkerc70b9822013-04-07 22:00:46 +020054 * RSA constants
Paul Bakker5121ce52009-01-03 21:22:43 +000055 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020056#define MBEDTLS_RSA_PUBLIC 0
57#define MBEDTLS_RSA_PRIVATE 1
Paul Bakker5121ce52009-01-03 21:22:43 +000058
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020059#define MBEDTLS_RSA_PKCS_V15 0
60#define MBEDTLS_RSA_PKCS_V21 1
Paul Bakker5121ce52009-01-03 21:22:43 +000061
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020062#define MBEDTLS_RSA_SIGN 1
63#define MBEDTLS_RSA_CRYPT 2
Paul Bakker5121ce52009-01-03 21:22:43 +000064
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020065#define MBEDTLS_RSA_SALT_LEN_ANY -1
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +020066
Manuel Pégourié-Gonnarde511ffc2013-08-22 17:33:21 +020067/*
68 * The above constants may be used even if the RSA module is compile out,
69 * eg for alternative (PKCS#11) RSA implemenations in the PK layers.
70 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020071#if defined(MBEDTLS_RSA_C)
Manuel Pégourié-Gonnarde511ffc2013-08-22 17:33:21 +020072
Paul Bakker407a0da2013-06-27 14:29:21 +020073#ifdef __cplusplus
74extern "C" {
75#endif
76
Paul Bakker5121ce52009-01-03 21:22:43 +000077/**
Hanno Beckera3ebec22017-08-23 14:06:24 +010078 * Helper functions for RSA-related operations on MPI's.
79 */
80
81/**
82 * \brief Compute RSA prime moduli P, Q from public modulus N=PQ
Hanno Beckerb0c5edc2017-08-23 22:16:10 +010083 * and a pair of private and public key.
Hanno Beckera3ebec22017-08-23 14:06:24 +010084 *
85 * \note This is a 'static' helper function not operating on
86 * an RSA context. Alternative implementations need not
87 * overwrite it.
88 *
89 * \param N RSA modulus N = PQ, with P, Q to be found
90 * \param D RSA private exponent
91 * \param E RSA public exponent
92 * \param f_rng PRNG to be used for randomization, or NULL
93 * \param p_rng PRNG context for f_rng, or NULL
94 * \param P Pointer to MPI holding first prime factor of N on success
95 * \param Q Pointer to MPI holding second prime factor of N on success
96 *
97 * \return - 0 if successful. In this case, P and Q constitute a
98 * factorization of N, and it is guaranteed that D and E
99 * are indeed modular inverses modulo P-1 and modulo Q-1.
100 * The values of N, D and E are unchanged. It is checked
101 * that P, Q are prime if a PRNG is provided.
102 * - A non-zero error code otherwise. In this case, the values
103 * of N, D, E are undefined.
104 *
105 * \note The input MPI's are deliberately not declared as constant
106 * and may therefore be used for in-place calculations by
107 * the implementation. In particular, their values can be
108 * corrupted when the function fails. If the user cannot
109 * tolerate this, he has to make copies of the MPI's prior
110 * to calling this function. See \c mbedtls_mpi_copy for this.
111 */
112int mbedtls_rsa_deduce_moduli( mbedtls_mpi *N, mbedtls_mpi *D, mbedtls_mpi *E,
113 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
114 mbedtls_mpi *P, mbedtls_mpi *Q );
115
116/**
117 * \brief Compute RSA private exponent from
118 * prime moduli and public key.
119 *
120 * \note This is a 'static' helper function not operating on
121 * an RSA context. Alternative implementations need not
122 * overwrite it.
123 *
124 * \param P First prime factor of RSA modulus
125 * \param Q Second prime factor of RSA modulus
126 * \param E RSA public exponent
127 * \param D Pointer to MPI holding the private exponent on success.
128 *
129 * \note This function does not check whether P and Q are primes.
130 *
131 * \return - 0 if successful. In this case, D is set to a simultaneous
132 * modular inverse of E modulo both P-1 and Q-1.
133 * - A non-zero error code otherwise. In this case, the values
134 * of P, Q, E are undefined.
135 *
136 * \note The input MPI's are deliberately not declared as constant
137 * and may therefore be used for in-place calculations by
138 * the implementation. In particular, their values can be
139 * corrupted when the function fails. If the user cannot
140 * tolerate this, he has to make copies of the MPI's prior
141 * to calling this function. See \c mbedtls_mpi_copy for this.
142 */
143int mbedtls_rsa_deduce_private( mbedtls_mpi *P, mbedtls_mpi *Q, mbedtls_mpi *E,
144 mbedtls_mpi *D );
145
146
147/**
148 * \brief Generate RSA-CRT parameters
149 *
150 * \note This is a 'static' helper function not operating on
151 * an RSA context. Alternative implementations need not
152 * overwrite it.
153 *
154 * \param P First prime factor of N
155 * \param Q Second prime factor of N
156 * \param D RSA private exponent
157 * \param DP Output variable for D modulo P-1
158 * \param DQ Output variable for D modulo Q-1
159 * \param QP Output variable for the modular inverse of Q modulo P.
160 *
161 * \return 0 on success, non-zero error code otherwise.
162 *
163 */
164int mbedtls_rsa_deduce_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
165 const mbedtls_mpi *D, mbedtls_mpi *DP,
166 mbedtls_mpi *DQ, mbedtls_mpi *QP );
167
168
169/**
170 * \brief Check validity of core RSA parameters
171 *
172 * \note This is a 'static' helper function not operating on
173 * an RSA context. Alternative implementations need not
174 * overwrite it.
175 *
176 * \param N RSA modulus N = PQ
177 * \param P First prime factor of N
178 * \param Q Second prime factor of N
179 * \param D RSA private exponent
180 * \param E RSA public exponent
181 * \param f_rng PRNG to be used for randomization, or NULL
182 * \param p_rng PRNG context for f_rng, or NULL
183 *
184 * \return - 0 if the following conditions are satisfied:
185 * - N = PQ if N,P,Q != NULL
186 * - D and E are modular inverses modulo P-1 and Q-1
187 * if D,E,P,Q != NULL
188 * - P prime if f_rng, P != NULL
189 * - Q prime if f_rng, Q != NULL
Hanno Becker750e8b42017-08-25 07:54:27 +0100190 * - A non-zero error code otherwise.
Hanno Beckera3ebec22017-08-23 14:06:24 +0100191 *
192 * \note The function can be used with a restricted set of arguments
193 * to perform specific checks only. E.g., calling it with
194 * (-,P,-,-,-) and a PRNG amounts to a primality check for P.
Hanno Beckera3ebec22017-08-23 14:06:24 +0100195 */
Hanno Becker750e8b42017-08-25 07:54:27 +0100196int mbedtls_rsa_validate_params( const mbedtls_mpi *N, const mbedtls_mpi *P,
197 const mbedtls_mpi *Q, const mbedtls_mpi *D,
198 const mbedtls_mpi *E,
199 int (*f_rng)(void *, unsigned char *, size_t),
200 void *p_rng );
Hanno Beckera3ebec22017-08-23 14:06:24 +0100201
202/**
Hanno Beckerd3637992017-08-25 07:55:03 +0100203 * \brief Check validity of RSA CRT parameters
204 *
205 * \note This is a 'static' helper function not operating on
206 * an RSA context. Alternative implementations need not
207 * overwrite it.
208 *
209 * \param P First prime factor of RSA modulus
210 * \param Q Second prime factor of RSA modulus
211 * \param D RSA private exponent
212 * \param DP MPI to check for D modulo P-1
213 * \param DQ MPI to check for D modulo P-1
214 * \param QP MPI to check for the modular inverse of Q modulo P.
215 *
216 * \return - 0 if the following conditions are satisfied:
217 * - D = DP mod P-1 if P, D, DP != NULL
218 * - Q = DQ mod P-1 if P, D, DQ != NULL
219 * - QP = Q^-1 mod P if P, Q, QP != NULL
220 * - MBEDTLS_ERR_RSA_KEY_CHECK_FAILED if check failed,
221 * potentially including MBEDTLS_ERR_MPI_XXX if some
222 * MPI calculations failed.
223 * - MBEDTLS_ERR_RSA_BAD_INPUT_DATA if insufficient
224 * data was provided to check DP, DQ or QP.
225 *
226 * \note The function can be used with a restricted set of arguments
227 * to perform specific checks only. E.g., calling it with the
228 * parameters (P, -, D, DP, -, -) will check DP = D mod P-1.
229 */
230int mbedtls_rsa_validate_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
231 const mbedtls_mpi *D, const mbedtls_mpi *DP,
232 const mbedtls_mpi *DQ, const mbedtls_mpi *QP );
233
234/**
Hanno Beckera3ebec22017-08-23 14:06:24 +0100235 * Implementation of RSA interface
236 */
237
Hanno Beckerab377312017-08-23 16:24:51 +0100238#if !defined(MBEDTLS_RSA_ALT)
239
Hanno Beckera3ebec22017-08-23 14:06:24 +0100240/**
Hanno Becker5063cd22017-09-29 11:49:12 +0100241 * \brief RSA context structure
242 *
243 * \note Direct manipulation of the members of this structure
244 * is deprecated and will no longer be supported starting
245 * from the next major release. All manipulation should instead
246 * be done through the public interface functions.
247 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000248 */
249typedef struct
250{
251 int ver; /*!< always 0 */
Paul Bakker23986e52011-04-24 08:57:21 +0000252 size_t len; /*!< size(N) in chars */
Paul Bakker5121ce52009-01-03 21:22:43 +0000253
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254 mbedtls_mpi N; /*!< public modulus */
255 mbedtls_mpi E; /*!< public exponent */
Paul Bakker5121ce52009-01-03 21:22:43 +0000256
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200257 mbedtls_mpi D; /*!< private exponent */
258 mbedtls_mpi P; /*!< 1st prime factor */
259 mbedtls_mpi Q; /*!< 2nd prime factor */
Hanno Becker1a59e792017-08-23 07:41:10 +0100260
261#if !defined(MBEDTLS_RSA_NO_CRT)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200262 mbedtls_mpi DP; /*!< D % (P - 1) */
263 mbedtls_mpi DQ; /*!< D % (Q - 1) */
264 mbedtls_mpi QP; /*!< 1 / (Q % P) */
Hanno Becker1a59e792017-08-23 07:41:10 +0100265#endif /* MBEDTLS_RSA_NO_CRT */
Paul Bakker5121ce52009-01-03 21:22:43 +0000266
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200267 mbedtls_mpi RN; /*!< cached R^2 mod N */
Hanno Becker1a59e792017-08-23 07:41:10 +0100268
269#if !defined(MBEDTLS_RSA_NO_CRT)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200270 mbedtls_mpi RP; /*!< cached R^2 mod P */
271 mbedtls_mpi RQ; /*!< cached R^2 mod Q */
Hanno Becker1a59e792017-08-23 07:41:10 +0100272#endif /* MBEDTLS_RSA_NO_CRT */
Paul Bakker5121ce52009-01-03 21:22:43 +0000273
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200274 mbedtls_mpi Vi; /*!< cached blinding value */
275 mbedtls_mpi Vf; /*!< cached un-blinding value */
Manuel Pégourié-Gonnardea53a552013-09-10 13:29:30 +0200276
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200277 int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
Hanno Becker8fd55482017-08-23 14:07:48 +0100278 MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200279 int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
280 specified in the mbedtls_md.h header file
Paul Bakker9dcc3222011-03-08 14:16:06 +0000281 for the EME-OAEP and EMSA-PSS
282 encoding */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200283#if defined(MBEDTLS_THREADING_C)
284 mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex */
Paul Bakkerc9965dc2013-09-29 14:58:17 +0200285#endif
Paul Bakker5121ce52009-01-03 21:22:43 +0000286}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200287mbedtls_rsa_context;
Paul Bakker5121ce52009-01-03 21:22:43 +0000288
Hanno Beckerab377312017-08-23 16:24:51 +0100289#else
290
291#include "rsa_alt.h"
292
293#endif /* MBEDTLS_RSA_ALT */
294
Paul Bakker5121ce52009-01-03 21:22:43 +0000295/**
296 * \brief Initialize an RSA context
297 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200298 * Note: Set padding to MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP
Paul Bakker9a736322012-11-14 12:39:52 +0000299 * encryption scheme and the RSASSA-PSS signature scheme.
300 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000301 * \param ctx RSA context to be initialized
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200302 * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
303 * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
Paul Bakker5121ce52009-01-03 21:22:43 +0000304 *
305 * \note The hash_id parameter is actually ignored
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200306 * when using MBEDTLS_RSA_PKCS_V15 padding.
Manuel Pégourié-Gonnarde6d1d822014-06-02 16:47:02 +0200307 *
308 * \note Choice of padding mode is strictly enforced for private key
309 * operations, since there might be security concerns in
310 * mixing padding modes. For public key operations it's merely
311 * a default value, which can be overriden by calling specific
312 * rsa_rsaes_xxx or rsa_rsassa_xxx functions.
313 *
314 * \note The chosen hash is always used for OEAP encryption.
315 * For PSS signatures, it's always used for making signatures,
316 * but can be overriden (and always is, if set to
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200317 * MBEDTLS_MD_NONE) for verifying them.
Paul Bakker5121ce52009-01-03 21:22:43 +0000318 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200319void mbedtls_rsa_init( mbedtls_rsa_context *ctx,
Hanno Becker8fd55482017-08-23 14:07:48 +0100320 int padding,
321 int hash_id);
Paul Bakker5121ce52009-01-03 21:22:43 +0000322
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100323
324/**
325 * \brief Import a set of core parameters into an RSA context
326 *
327 * \param ctx Initialized RSA context to store parameters
328 * \param N RSA modulus, or NULL
329 * \param P First prime factor of N, or NULL
330 * \param Q Second prime factor of N, or NULL
331 * \param D Private exponent, or NULL
332 * \param E Public exponent, or NULL
333 *
334 * \note This function can be called multiple times for successive
335 * imports if the parameters are not simultaneously present.
336 * Any sequence of calls to this function should be followed
337 * by a call to \c mbedtls_rsa_complete which will check
338 * and complete the provided information to a ready-for-use
339 * public or private RSA key.
340 *
341 * \return 0 if successful, non-zero error code on failure.
342 */
343int mbedtls_rsa_import( mbedtls_rsa_context *ctx,
344 const mbedtls_mpi *N,
345 const mbedtls_mpi *P, const mbedtls_mpi *Q,
346 const mbedtls_mpi *D, const mbedtls_mpi *E );
347
348/**
349 * \brief Import core RSA parameters in raw big-endian
350 * binary format into an RSA context
351 *
352 * \param ctx Initialized RSA context to store parameters
353 * \param N RSA modulus, or NULL
354 * \param N_len Byte length of N, ignored if N == NULL
355 * \param P First prime factor of N, or NULL
356 * \param P_len Byte length of P, ignored if P == NULL
357 * \param Q Second prime factor of N, or NULL
358 * \param Q_len Byte length of Q, ignored if Q == NULL
359 * \param D Private exponent, or NULL
360 * \param D_len Byte length of D, ignored if D == NULL
361 * \param E Public exponent, or NULL
362 * \param E_len Byte length of E, ignored if E == NULL
363 *
364 * \note This function can be called multiple times for successive
365 * imports if the parameters are not simultaneously present.
366 * Any sequence of calls to this function should be followed
367 * by a call to \c mbedtls_rsa_complete which will check
368 * and complete the provided information to a ready-for-use
369 * public or private RSA key.
370 *
371 * \return 0 if successful, non-zero error code on failure.
372 */
373
374int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
375 unsigned char *N, size_t N_len,
376 unsigned char *P, size_t P_len,
377 unsigned char *Q, size_t Q_len,
378 unsigned char *D, size_t D_len,
379 unsigned char *E, size_t E_len );
380
381/**
382 * \brief Attempt to complete an RSA context from
383 * a set of imported core parameters.
384 *
385 * \param ctx Initialized RSA context to store parameters
386 * \param f_rng RNG function,
387 * \param p_rng RNG parameter
388 *
389 * To setup an RSA public key, precisely N and E
390 * must have been imported.
391 *
392 * To setup an RSA private key, enough information must be
393 * present for the other parameters to be efficiently derivable.
394 *
395 * The default implementation supports the following:
396 * (a) Derive P, Q from N, D, E
397 * (b) Derive N, D from P, Q, E.
398 *
399 * Alternative implementations need not support these
400 * and may return MBEDTLS_ERR_RSA_BAD_INPUT_DATA instead.
401 *
402 * \note The PRNG is used for probabilistic algorithms
403 * like the derivation of P, Q from N, D, E, as
404 * well as primality checks.
405 *
Hanno Becker603b8c62017-08-25 11:03:07 +0100406 * \return - 0 if successful. In this case, all imported core
407 * parameters are guaranteed to be sane, the RSA context
408 * has been fully setup and is ready for use.
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100409 * - MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the attempted
410 * derivations failed.
411 */
412int mbedtls_rsa_complete( mbedtls_rsa_context *ctx,
413 int (*f_rng)(void *, unsigned char *, size_t),
414 void *p_rng );
415
416/**
417 * \brief Check if CRT-parameters match core parameters
418 *
419 * \param ctx Complete RSA private key context
420 * \param DP Private exponent modulo P-1, or NULL
421 * \param DQ Private exponent modulo Q-1, or NULL
422 * \param QP Modular inverse of Q modulo P, or NULL
423 *
424 * \return 0 if successful, testifying that the non-NULL optional
425 * parameters provided are in accordance with the core
426 * RSA parameters. Non-zero error code otherwise.
427 *
428 * \note This function performs in-place computations on the
429 * parameters DP, DQ and QP. If modification cannot be
430 * tolerated, you should make copies with mbedtls_mpi_copy
431 * before calling this function.
432 *
433 */
Hanno Beckerd3637992017-08-25 07:55:03 +0100434int mbedtls_rsa_check_crt( const mbedtls_rsa_context *ctx,
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100435 mbedtls_mpi *DP,
436 mbedtls_mpi *DQ,
437 mbedtls_mpi *QP );
438
439/**
440 * \brief Export core parameters of an RSA key
441 *
442 * \param ctx Initialized RSA context
443 * \param N MPI to hold the RSA modulus, or NULL
444 * \param P MPI to hold the first prime factor of N, or NULL
445 * \param Q MPI to hold the second prime factor of N, or NULL
446 * \param D MPI to hold the private exponent, or NULL
447 * \param E MPI to hold the public exponent, or NULL
448 *
449 * \return 0 if successful, non-zero error code otherwise.
Hanno Becker91c194d2017-09-29 12:50:12 +0100450 * In particular, if exporting the requested parameters
451 * cannot be done because of a lack of functionality
452 * or because of security policies, the error code
453 * MBEDTLS_ERR_RSA_EXPORT_UNSUPPORTED is returned.
454 * In this case, the RSA context stays intact and can
455 * be continued to be used.
456 *
457 * \note Two reasons for returning MBEDTLS_ERR_RSA_EXPORT_UNSUPPORTED
458 * would be the following: Firstly, it might be that an
459 * alternative RSA implementation is in use which stores
460 * the key externally, and which either cannot or should not
461 * export it into RAM. Alternatively, an implementation
462 * (regardless of SW or HW) might not support deducing e.g.
463 * P, Q from N, D, E if the former are not part of the
464 * implementation.
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100465 *
466 */
467int mbedtls_rsa_export( const mbedtls_rsa_context *ctx,
468 mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q,
469 mbedtls_mpi *D, mbedtls_mpi *E );
470
471/**
472 * \brief Export core parameters of an RSA key
473 * in raw big-endian binary format
474 *
475 * \param ctx Initialized RSA context
476 * \param N Byte array to store the RSA modulus, or NULL
477 * \param N_len Size of buffer for modulus
478 * \param P Byte array to hold the first prime factor of N, or NULL
479 * \param P_len Size of buffer for first prime factor
480 * \param Q Byte array to hold the second prime factor of N, or NULL
481 * \param Q_len Size of buffer for second prime factor
482 * \param D Byte array to hold the private exponent, or NULL
483 * \param D_len Size of buffer for private exponent
484 * \param E Byte array to hold the public exponent, or NULL
485 * \param E_len Size of buffer for public exponent
486 *
487 * \note The length fields are ignored if the corresponding
488 * buffer pointers are NULL.
489 *
490 * \return 0 if successful. In this case, the non-NULL buffers
491 * pointed to by N, P, Q, D, E are fully written, with
492 * additional unused space filled leading by 0-bytes.
493 *
Hanno Becker91c194d2017-09-29 12:50:12 +0100494 * \return 0 if successful, non-zero error code otherwise.
495 * In particular, if exporting the requested parameters
496 * cannot be done because of a lack of functionality
497 * or because of security policies, the error code
498 * MBEDTLS_ERR_RSA_EXPORT_UNSUPPORTED is returned.
499 * In this case, the RSA context stays intact and can
500 * be continued to be used.
501 *
502 * \note Two reasons for returning MBEDTLS_ERR_RSA_EXPORT_UNSUPPORTED
503 * would be the following: Firstly, it might be that an
504 * alternative RSA implementation is in use which stores
505 * the key externally, and which either cannot or should not
506 * export it into RAM. Alternatively, an implementation
507 * (regardless of SW or HW) might not support deducing e.g.
508 * P, Q from N, D, E if the former are not part of the
509 * implementation.
510 *
511 *
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100512 */
513int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx,
514 unsigned char *N, size_t N_len,
515 unsigned char *P, size_t P_len,
516 unsigned char *Q, size_t Q_len,
517 unsigned char *D, size_t D_len,
518 unsigned char *E, size_t E_len );
519
520/**
521 * \brief Export CRT parameters of a private RSA key
522 *
523 * \param ctx Initialized RSA context
524 * \param DP MPI to hold D modulo P-1, or NULL
525 * \param DQ MPI to hold D modulo Q-1, or NULL
526 * \param QP MPI to hold modular inverse of Q modulo P, or NULL
527 *
528 * \return 0 if successful, non-zero error code otherwise.
529 *
530 * \note Alternative RSA implementations not using CRT-parameters
531 * internally can implement this function using based on
532 * \c mbedtls_rsa_deduce_opt.
533 *
534 */
535int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx,
536 mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP );
537
Paul Bakker5121ce52009-01-03 21:22:43 +0000538/**
Manuel Pégourié-Gonnard844a4c02014-03-10 21:55:35 +0100539 * \brief Set padding for an already initialized RSA context
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200540 * See \c mbedtls_rsa_init() for details.
Manuel Pégourié-Gonnard844a4c02014-03-10 21:55:35 +0100541 *
542 * \param ctx RSA context to be set
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200543 * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
544 * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
Manuel Pégourié-Gonnard844a4c02014-03-10 21:55:35 +0100545 */
Hanno Becker8fd55482017-08-23 14:07:48 +0100546void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding,
547 int hash_id);
Manuel Pégourié-Gonnard844a4c02014-03-10 21:55:35 +0100548
549/**
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100550 * \brief Get length of RSA modulus in bytes
551 *
552 * \param ctx Initialized RSA context
553 *
554 * \return Length of RSA modulus, in bytes.
555 *
556 */
557size_t mbedtls_rsa_get_len( const mbedtls_rsa_context *ctx );
558
559/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000560 * \brief Generate an RSA keypair
561 *
562 * \param ctx RSA context that will hold the key
Paul Bakker21eb2802010-08-16 11:10:02 +0000563 * \param f_rng RNG function
564 * \param p_rng RNG parameter
Paul Bakker5121ce52009-01-03 21:22:43 +0000565 * \param nbits size of the public key in bits
566 * \param exponent public exponent (e.g., 65537)
567 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200568 * \note mbedtls_rsa_init() must be called beforehand to setup
Paul Bakker21eb2802010-08-16 11:10:02 +0000569 * the RSA context.
Paul Bakker5121ce52009-01-03 21:22:43 +0000570 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200571 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000572 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200573int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
Hanno Becker8fd55482017-08-23 14:07:48 +0100574 int (*f_rng)(void *, unsigned char *, size_t),
575 void *p_rng,
576 unsigned int nbits, int exponent );
Paul Bakker5121ce52009-01-03 21:22:43 +0000577
578/**
Hanno Becker8fd55482017-08-23 14:07:48 +0100579 * \brief Check if a context contains an RSA public key
Paul Bakker5121ce52009-01-03 21:22:43 +0000580 *
581 * \param ctx RSA context to be checked
582 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200583 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000584 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200585int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +0000586
587/**
Hanno Becker8fd55482017-08-23 14:07:48 +0100588 * \brief Check if a context contains a complete
589 * and valid RSA private key.
Paul Bakker5121ce52009-01-03 21:22:43 +0000590 *
591 * \param ctx RSA context to be checked
592 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200593 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000594 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200595int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +0000596
597/**
Manuel Pégourié-Gonnard2f8d1f92014-11-06 14:02:51 +0100598 * \brief Check a public-private RSA key pair.
599 * Check each of the contexts, and make sure they match.
600 *
601 * \param pub RSA context holding the public key
602 * \param prv RSA context holding the private key
603 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200604 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Manuel Pégourié-Gonnard2f8d1f92014-11-06 14:02:51 +0100605 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200606int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv );
Manuel Pégourié-Gonnard2f8d1f92014-11-06 14:02:51 +0100607
608/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000609 * \brief Do an RSA public key operation
610 *
611 * \param ctx RSA context
612 * \param input input buffer
613 * \param output output buffer
614 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200615 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000616 *
617 * \note This function does NOT take care of message
Brian J Murray2adecba2016-11-06 04:45:15 -0800618 * padding. Also, be sure to set input[0] = 0 or ensure that
Paul Bakker619467a2009-03-28 23:26:51 +0000619 * input is smaller than N.
Paul Bakker5121ce52009-01-03 21:22:43 +0000620 *
621 * \note The input and output buffers must be large
622 * enough (eg. 128 bytes if RSA-1024 is used).
623 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200624int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000625 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000626 unsigned char *output );
627
628/**
629 * \brief Do an RSA private key operation
630 *
631 * \param ctx RSA context
Paul Bakker548957d2013-08-30 10:30:02 +0200632 * \param f_rng RNG function (Needed for blinding)
633 * \param p_rng RNG parameter
Paul Bakker5121ce52009-01-03 21:22:43 +0000634 * \param input input buffer
635 * \param output output buffer
636 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200637 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000638 *
639 * \note The input and output buffers must be large
640 * enough (eg. 128 bytes if RSA-1024 is used).
641 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200642int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200643 int (*f_rng)(void *, unsigned char *, size_t),
644 void *p_rng,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000645 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000646 unsigned char *output );
647
648/**
Paul Bakkerb3869132013-02-28 17:21:01 +0100649 * \brief Generic wrapper to perform a PKCS#1 encryption using the
650 * mode from the context. Add the message padding, then do an
651 * RSA operation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000652 *
653 * \param ctx RSA context
Paul Bakker548957d2013-08-30 10:30:02 +0200654 * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200655 * and MBEDTLS_RSA_PRIVATE)
Paul Bakker21eb2802010-08-16 11:10:02 +0000656 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200657 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
Paul Bakker592457c2009-04-01 19:01:43 +0000658 * \param ilen contains the plaintext length
Paul Bakker5121ce52009-01-03 21:22:43 +0000659 * \param input buffer holding the data to be encrypted
660 * \param output buffer that will hold the ciphertext
661 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200662 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000663 *
664 * \note The output buffer must be as large as the size
665 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
666 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200667int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
Paul Bakkera3d195c2011-11-27 21:07:34 +0000668 int (*f_rng)(void *, unsigned char *, size_t),
Paul Bakker21eb2802010-08-16 11:10:02 +0000669 void *p_rng,
Paul Bakker23986e52011-04-24 08:57:21 +0000670 int mode, size_t ilen,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000671 const unsigned char *input,
Paul Bakker5121ce52009-01-03 21:22:43 +0000672 unsigned char *output );
673
674/**
Paul Bakkerb3869132013-02-28 17:21:01 +0100675 * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT)
676 *
677 * \param ctx RSA context
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200678 * \param f_rng RNG function (Needed for padding and MBEDTLS_RSA_PRIVATE)
Paul Bakkerb3869132013-02-28 17:21:01 +0100679 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200680 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
Paul Bakkerb3869132013-02-28 17:21:01 +0100681 * \param ilen contains the plaintext length
682 * \param input buffer holding the data to be encrypted
683 * \param output buffer that will hold the ciphertext
684 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200685 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100686 *
687 * \note The output buffer must be as large as the size
688 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
689 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200690int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
Paul Bakkerb3869132013-02-28 17:21:01 +0100691 int (*f_rng)(void *, unsigned char *, size_t),
692 void *p_rng,
693 int mode, size_t ilen,
694 const unsigned char *input,
695 unsigned char *output );
696
697/**
698 * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT)
699 *
700 * \param ctx RSA context
Paul Bakker548957d2013-08-30 10:30:02 +0200701 * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200702 * and MBEDTLS_RSA_PRIVATE)
Paul Bakkerb3869132013-02-28 17:21:01 +0100703 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200704 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
Paul Bakkera43231c2013-02-28 17:33:49 +0100705 * \param label buffer holding the custom label to use
706 * \param label_len contains the label length
Paul Bakkerb3869132013-02-28 17:21:01 +0100707 * \param ilen contains the plaintext length
708 * \param input buffer holding the data to be encrypted
709 * \param output buffer that will hold the ciphertext
710 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200711 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100712 *
713 * \note The output buffer must be as large as the size
714 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
715 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200716int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
Paul Bakkerb3869132013-02-28 17:21:01 +0100717 int (*f_rng)(void *, unsigned char *, size_t),
718 void *p_rng,
Paul Bakkera43231c2013-02-28 17:33:49 +0100719 int mode,
720 const unsigned char *label, size_t label_len,
721 size_t ilen,
Paul Bakkerb3869132013-02-28 17:21:01 +0100722 const unsigned char *input,
723 unsigned char *output );
724
725/**
726 * \brief Generic wrapper to perform a PKCS#1 decryption using the
727 * mode from the context. Do an RSA operation, then remove
728 * the message padding
Paul Bakker5121ce52009-01-03 21:22:43 +0000729 *
730 * \param ctx RSA context
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200731 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200732 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200733 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
Paul Bakker4d8ca702011-08-09 10:31:05 +0000734 * \param olen will contain the plaintext length
Paul Bakker5121ce52009-01-03 21:22:43 +0000735 * \param input buffer holding the encrypted data
736 * \param output buffer that will hold the plaintext
Paul Bakker23986e52011-04-24 08:57:21 +0000737 * \param output_max_len maximum length of the output buffer
Paul Bakker5121ce52009-01-03 21:22:43 +0000738 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200739 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000740 *
Hanno Becker248ae6d2017-05-04 11:27:39 +0100741 * \note The output buffer length \c output_max_len should be
742 * as large as the size ctx->len of ctx->N (eg. 128 bytes
743 * if RSA-1024 is used) to be able to hold an arbitrary
744 * decrypted message. If it is not large enough to hold
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100745 * the decryption of the particular ciphertext provided,
Hanno Becker248ae6d2017-05-04 11:27:39 +0100746 * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
747 *
748 * \note The input buffer must be as large as the size
749 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
Paul Bakker5121ce52009-01-03 21:22:43 +0000750 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200751int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200752 int (*f_rng)(void *, unsigned char *, size_t),
753 void *p_rng,
Paul Bakker23986e52011-04-24 08:57:21 +0000754 int mode, size_t *olen,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000755 const unsigned char *input,
Paul Bakker060c5682009-01-12 21:48:39 +0000756 unsigned char *output,
Paul Bakker23986e52011-04-24 08:57:21 +0000757 size_t output_max_len );
Paul Bakker5121ce52009-01-03 21:22:43 +0000758
759/**
Paul Bakkerb3869132013-02-28 17:21:01 +0100760 * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT)
761 *
762 * \param ctx RSA context
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200763 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200764 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200765 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
Paul Bakkerb3869132013-02-28 17:21:01 +0100766 * \param olen will contain the plaintext length
767 * \param input buffer holding the encrypted data
768 * \param output buffer that will hold the plaintext
769 * \param output_max_len maximum length of the output buffer
770 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200771 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100772 *
Hanno Becker248ae6d2017-05-04 11:27:39 +0100773 * \note The output buffer length \c output_max_len should be
774 * as large as the size ctx->len of ctx->N (eg. 128 bytes
775 * if RSA-1024 is used) to be able to hold an arbitrary
776 * decrypted message. If it is not large enough to hold
Hanno Beckercbb59bc2017-08-23 14:11:08 +0100777 * the decryption of the particular ciphertext provided,
Hanno Becker248ae6d2017-05-04 11:27:39 +0100778 * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
779 *
780 * \note The input buffer must be as large as the size
781 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
Paul Bakkerb3869132013-02-28 17:21:01 +0100782 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200783int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200784 int (*f_rng)(void *, unsigned char *, size_t),
785 void *p_rng,
Paul Bakkerb3869132013-02-28 17:21:01 +0100786 int mode, size_t *olen,
787 const unsigned char *input,
788 unsigned char *output,
789 size_t output_max_len );
790
791/**
792 * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT)
793 *
794 * \param ctx RSA context
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200795 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200796 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200797 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
Paul Bakkera43231c2013-02-28 17:33:49 +0100798 * \param label buffer holding the custom label to use
799 * \param label_len contains the label length
Paul Bakkerb3869132013-02-28 17:21:01 +0100800 * \param olen will contain the plaintext length
801 * \param input buffer holding the encrypted data
802 * \param output buffer that will hold the plaintext
803 * \param output_max_len maximum length of the output buffer
804 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200805 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100806 *
Hanno Becker248ae6d2017-05-04 11:27:39 +0100807 * \note The output buffer length \c output_max_len should be
808 * as large as the size ctx->len of ctx->N (eg. 128 bytes
809 * if RSA-1024 is used) to be able to hold an arbitrary
810 * decrypted message. If it is not large enough to hold
Hanno Becker8fd55482017-08-23 14:07:48 +0100811 * the decryption of the particular ciphertext provided,
Hanno Becker248ae6d2017-05-04 11:27:39 +0100812 * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
813 *
Hanno Becker8fd55482017-08-23 14:07:48 +0100814 * \note The input buffer must be as large as the size
Hanno Becker248ae6d2017-05-04 11:27:39 +0100815 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
Paul Bakkerb3869132013-02-28 17:21:01 +0100816 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200817int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200818 int (*f_rng)(void *, unsigned char *, size_t),
819 void *p_rng,
Paul Bakkera43231c2013-02-28 17:33:49 +0100820 int mode,
821 const unsigned char *label, size_t label_len,
822 size_t *olen,
Paul Bakkerb3869132013-02-28 17:21:01 +0100823 const unsigned char *input,
824 unsigned char *output,
825 size_t output_max_len );
826
827/**
828 * \brief Generic wrapper to perform a PKCS#1 signature using the
829 * mode from the context. Do a private RSA operation to sign
830 * a message digest
Paul Bakker5121ce52009-01-03 21:22:43 +0000831 *
832 * \param ctx RSA context
Paul Bakker548957d2013-08-30 10:30:02 +0200833 * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200834 * MBEDTLS_RSA_PRIVATE)
Paul Bakker9dcc3222011-03-08 14:16:06 +0000835 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200836 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
837 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
838 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Paul Bakker5121ce52009-01-03 21:22:43 +0000839 * \param hash buffer holding the message digest
840 * \param sig buffer that will hold the ciphertext
841 *
842 * \return 0 if the signing operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200843 * or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000844 *
845 * \note The "sig" buffer must be as large as the size
846 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
Paul Bakker9dcc3222011-03-08 14:16:06 +0000847 *
Manuel Pégourié-Gonnarde6d1d822014-06-02 16:47:02 +0200848 * \note In case of PKCS#1 v2.1 encoding, see comments on
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200849 * \note \c mbedtls_rsa_rsassa_pss_sign() for details on md_alg and hash_id.
Paul Bakker5121ce52009-01-03 21:22:43 +0000850 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200851int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
Paul Bakkera3d195c2011-11-27 21:07:34 +0000852 int (*f_rng)(void *, unsigned char *, size_t),
Paul Bakker9dcc3222011-03-08 14:16:06 +0000853 void *p_rng,
Paul Bakker5121ce52009-01-03 21:22:43 +0000854 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200855 mbedtls_md_type_t md_alg,
Paul Bakker23986e52011-04-24 08:57:21 +0000856 unsigned int hashlen,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000857 const unsigned char *hash,
Paul Bakker5121ce52009-01-03 21:22:43 +0000858 unsigned char *sig );
859
860/**
Paul Bakkerb3869132013-02-28 17:21:01 +0100861 * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN)
862 *
863 * \param ctx RSA context
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200864 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200865 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200866 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
867 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
868 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Paul Bakkerb3869132013-02-28 17:21:01 +0100869 * \param hash buffer holding the message digest
870 * \param sig buffer that will hold the ciphertext
871 *
872 * \return 0 if the signing operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200873 * or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100874 *
875 * \note The "sig" buffer must be as large as the size
876 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
877 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200878int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200879 int (*f_rng)(void *, unsigned char *, size_t),
880 void *p_rng,
Paul Bakkerb3869132013-02-28 17:21:01 +0100881 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200882 mbedtls_md_type_t md_alg,
Paul Bakkerb3869132013-02-28 17:21:01 +0100883 unsigned int hashlen,
884 const unsigned char *hash,
885 unsigned char *sig );
886
887/**
888 * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN)
889 *
890 * \param ctx RSA context
Paul Bakker548957d2013-08-30 10:30:02 +0200891 * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200892 * MBEDTLS_RSA_PRIVATE)
Paul Bakkerb3869132013-02-28 17:21:01 +0100893 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200894 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
895 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
896 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Paul Bakkerb3869132013-02-28 17:21:01 +0100897 * \param hash buffer holding the message digest
898 * \param sig buffer that will hold the ciphertext
899 *
900 * \return 0 if the signing operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200901 * or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100902 *
903 * \note The "sig" buffer must be as large as the size
904 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
905 *
Manuel Pégourié-Gonnarde6d1d822014-06-02 16:47:02 +0200906 * \note The hash_id in the RSA context is the one used for the
907 * encoding. md_alg in the function call is the type of hash
Paul Bakkerb3869132013-02-28 17:21:01 +0100908 * that is encoded. According to RFC 3447 it is advised to
909 * keep both hashes the same.
910 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200911int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
Paul Bakkerb3869132013-02-28 17:21:01 +0100912 int (*f_rng)(void *, unsigned char *, size_t),
913 void *p_rng,
914 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200915 mbedtls_md_type_t md_alg,
Paul Bakkerb3869132013-02-28 17:21:01 +0100916 unsigned int hashlen,
917 const unsigned char *hash,
918 unsigned char *sig );
919
920/**
921 * \brief Generic wrapper to perform a PKCS#1 verification using the
922 * mode from the context. Do a public RSA operation and check
923 * the message digest
Paul Bakker5121ce52009-01-03 21:22:43 +0000924 *
925 * \param ctx points to an RSA public key
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200926 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200927 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200928 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
929 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
930 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Paul Bakker5121ce52009-01-03 21:22:43 +0000931 * \param hash buffer holding the message digest
932 * \param sig buffer holding the ciphertext
933 *
934 * \return 0 if the verify operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200935 * or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000936 *
937 * \note The "sig" buffer must be as large as the size
938 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
Paul Bakker9dcc3222011-03-08 14:16:06 +0000939 *
Manuel Pégourié-Gonnarde6d1d822014-06-02 16:47:02 +0200940 * \note In case of PKCS#1 v2.1 encoding, see comments on
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200941 * \c mbedtls_rsa_rsassa_pss_verify() about md_alg and hash_id.
Paul Bakker5121ce52009-01-03 21:22:43 +0000942 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200943int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200944 int (*f_rng)(void *, unsigned char *, size_t),
945 void *p_rng,
Paul Bakker5121ce52009-01-03 21:22:43 +0000946 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200947 mbedtls_md_type_t md_alg,
Paul Bakker23986e52011-04-24 08:57:21 +0000948 unsigned int hashlen,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000949 const unsigned char *hash,
Manuel Pégourié-Gonnardcc0a9d02013-08-12 11:34:35 +0200950 const unsigned char *sig );
Paul Bakker5121ce52009-01-03 21:22:43 +0000951
952/**
Paul Bakkerb3869132013-02-28 17:21:01 +0100953 * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY)
954 *
955 * \param ctx points to an RSA public key
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200956 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200957 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200958 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
959 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
960 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Paul Bakkerb3869132013-02-28 17:21:01 +0100961 * \param hash buffer holding the message digest
962 * \param sig buffer holding the ciphertext
963 *
964 * \return 0 if the verify operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200965 * or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100966 *
967 * \note The "sig" buffer must be as large as the size
968 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
969 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200970int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +0200971 int (*f_rng)(void *, unsigned char *, size_t),
972 void *p_rng,
Paul Bakkerb3869132013-02-28 17:21:01 +0100973 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200974 mbedtls_md_type_t md_alg,
Paul Bakkerb3869132013-02-28 17:21:01 +0100975 unsigned int hashlen,
976 const unsigned char *hash,
Manuel Pégourié-Gonnardcc0a9d02013-08-12 11:34:35 +0200977 const unsigned char *sig );
Paul Bakkerb3869132013-02-28 17:21:01 +0100978
979/**
980 * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +0200981 * (This is the "simple" version.)
Paul Bakkerb3869132013-02-28 17:21:01 +0100982 *
983 * \param ctx points to an RSA public key
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200984 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Paul Bakker548957d2013-08-30 10:30:02 +0200985 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200986 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
987 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
988 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Paul Bakkerb3869132013-02-28 17:21:01 +0100989 * \param hash buffer holding the message digest
990 * \param sig buffer holding the ciphertext
991 *
992 * \return 0 if the verify operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200993 * or an MBEDTLS_ERR_RSA_XXX error code
Paul Bakkerb3869132013-02-28 17:21:01 +0100994 *
995 * \note The "sig" buffer must be as large as the size
996 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
997 *
Manuel Pégourié-Gonnarde6d1d822014-06-02 16:47:02 +0200998 * \note The hash_id in the RSA context is the one used for the
999 * verification. md_alg in the function call is the type of
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001000 * hash that is verified. According to RFC 3447 it is advised to
Manuel Pégourié-Gonnarde6d1d822014-06-02 16:47:02 +02001001 * keep both hashes the same. If hash_id in the RSA context is
1002 * unset, the md_alg from the function call is used.
Paul Bakkerb3869132013-02-28 17:21:01 +01001003 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001004int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
Paul Bakker548957d2013-08-30 10:30:02 +02001005 int (*f_rng)(void *, unsigned char *, size_t),
1006 void *p_rng,
Paul Bakkerb3869132013-02-28 17:21:01 +01001007 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001008 mbedtls_md_type_t md_alg,
Paul Bakkerb3869132013-02-28 17:21:01 +01001009 unsigned int hashlen,
1010 const unsigned char *hash,
Manuel Pégourié-Gonnardcc0a9d02013-08-12 11:34:35 +02001011 const unsigned char *sig );
Paul Bakkerb3869132013-02-28 17:21:01 +01001012
1013/**
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001014 * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
1015 * (This is the version with "full" options.)
1016 *
1017 * \param ctx points to an RSA public key
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001018 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001019 * \param p_rng RNG parameter
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001020 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
1021 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
1022 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001023 * \param hash buffer holding the message digest
1024 * \param mgf1_hash_id message digest used for mask generation
1025 * \param expected_salt_len Length of the salt used in padding, use
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001026 * MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001027 * \param sig buffer holding the ciphertext
1028 *
1029 * \return 0 if the verify operation was successful,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001030 * or an MBEDTLS_ERR_RSA_XXX error code
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001031 *
1032 * \note The "sig" buffer must be as large as the size
1033 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
1034 *
1035 * \note The hash_id in the RSA context is ignored.
1036 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001037int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001038 int (*f_rng)(void *, unsigned char *, size_t),
1039 void *p_rng,
1040 int mode,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001041 mbedtls_md_type_t md_alg,
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001042 unsigned int hashlen,
1043 const unsigned char *hash,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001044 mbedtls_md_type_t mgf1_hash_id,
Manuel Pégourié-Gonnard5ec628a2014-06-03 11:44:06 +02001045 int expected_salt_len,
1046 const unsigned char *sig );
1047
1048/**
Manuel Pégourié-Gonnard3053f5b2013-08-14 13:39:57 +02001049 * \brief Copy the components of an RSA context
1050 *
1051 * \param dst Destination context
1052 * \param src Source context
1053 *
Manuel Pégourié-Gonnard81abefd2015-05-29 12:53:47 +02001054 * \return 0 on success,
Manuel Pégourié-Gonnard6a8ca332015-05-28 09:33:39 +02001055 * MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure
Manuel Pégourié-Gonnard3053f5b2013-08-14 13:39:57 +02001056 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001057int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src );
Manuel Pégourié-Gonnard3053f5b2013-08-14 13:39:57 +02001058
1059/**
Paul Bakker5121ce52009-01-03 21:22:43 +00001060 * \brief Free the components of an RSA key
Paul Bakker13e2dfe2009-07-28 07:18:38 +00001061 *
1062 * \param ctx RSA Context to free
Paul Bakker5121ce52009-01-03 21:22:43 +00001063 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001064void mbedtls_rsa_free( mbedtls_rsa_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +00001065
1066/**
1067 * \brief Checkup routine
1068 *
1069 * \return 0 if successful, or 1 if the test failed
1070 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001071int mbedtls_rsa_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +00001072
1073#ifdef __cplusplus
1074}
1075#endif
1076
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001077#endif /* MBEDTLS_RSA_C */
Paul Bakkered27a042013-04-18 22:46:23 +02001078
Paul Bakker5121ce52009-01-03 21:22:43 +00001079#endif /* rsa.h */