Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file rsa.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 4 | * \brief The RSA public-key cryptosystem |
| 5 | * |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 6 | * Copyright (C) 2006-2013, Brainspark B.V. |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
Paul Bakker | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 10 | * |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 11 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 12 | * |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 26 | */ |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 27 | #ifndef POLARSSL_RSA_H |
| 28 | #define POLARSSL_RSA_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 30 | #include "config.h" |
| 31 | |
Paul Bakker | 314052f | 2011-08-15 09:07:52 +0000 | [diff] [blame] | 32 | #include "bignum.h" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 33 | #include "md.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 34 | |
Paul Bakker | 13e2dfe | 2009-07-28 07:18:38 +0000 | [diff] [blame] | 35 | /* |
| 36 | * RSA Error codes |
| 37 | */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 38 | #define POLARSSL_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */ |
| 39 | #define POLARSSL_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */ |
| 40 | #define POLARSSL_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */ |
| 41 | #define POLARSSL_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the libraries validity check. */ |
| 42 | #define POLARSSL_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */ |
| 43 | #define POLARSSL_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */ |
| 44 | #define POLARSSL_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */ |
| 45 | #define POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */ |
| 46 | #define POLARSSL_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 47 | |
| 48 | /* |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 49 | * RSA constants |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 50 | */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 51 | #define RSA_PUBLIC 0 |
| 52 | #define RSA_PRIVATE 1 |
| 53 | |
| 54 | #define RSA_PKCS_V15 0 |
| 55 | #define RSA_PKCS_V21 1 |
| 56 | |
| 57 | #define RSA_SIGN 1 |
| 58 | #define RSA_CRYPT 2 |
| 59 | |
Manuel Pégourié-Gonnard | e511ffc | 2013-08-22 17:33:21 +0200 | [diff] [blame] | 60 | /* |
| 61 | * The above constants may be used even if the RSA module is compile out, |
| 62 | * eg for alternative (PKCS#11) RSA implemenations in the PK layers. |
| 63 | */ |
| 64 | #if defined(POLARSSL_RSA_C) |
| 65 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 66 | #ifdef __cplusplus |
| 67 | extern "C" { |
| 68 | #endif |
| 69 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 70 | /** |
| 71 | * \brief RSA context structure |
| 72 | */ |
| 73 | typedef struct |
| 74 | { |
| 75 | int ver; /*!< always 0 */ |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 76 | size_t len; /*!< size(N) in chars */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 77 | |
| 78 | mpi N; /*!< public modulus */ |
| 79 | mpi E; /*!< public exponent */ |
| 80 | |
| 81 | mpi D; /*!< private exponent */ |
| 82 | mpi P; /*!< 1st prime factor */ |
| 83 | mpi Q; /*!< 2nd prime factor */ |
| 84 | mpi DP; /*!< D % (P - 1) */ |
| 85 | mpi DQ; /*!< D % (Q - 1) */ |
| 86 | mpi QP; /*!< 1 / (Q % P) */ |
| 87 | |
| 88 | mpi RN; /*!< cached R^2 mod N */ |
| 89 | mpi RP; /*!< cached R^2 mod P */ |
| 90 | mpi RQ; /*!< cached R^2 mod Q */ |
| 91 | |
Manuel Pégourié-Gonnard | ea53a55 | 2013-09-10 13:29:30 +0200 | [diff] [blame^] | 92 | #if !defined(POLARSSL_RSA_NO_CRT) |
| 93 | mpi Vi; /*!< cached blinding value */ |
| 94 | mpi Vf; /*!< cached un-blinding value */ |
| 95 | #endif |
| 96 | |
Paul Bakker | 9dcc322 | 2011-03-08 14:16:06 +0000 | [diff] [blame] | 97 | int padding; /*!< RSA_PKCS_V15 for 1.5 padding and |
| 98 | RSA_PKCS_v21 for OAEP/PSS */ |
| 99 | int hash_id; /*!< Hash identifier of md_type_t as |
| 100 | specified in the md.h header file |
| 101 | for the EME-OAEP and EMSA-PSS |
| 102 | encoding */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 103 | } |
| 104 | rsa_context; |
| 105 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 106 | /** |
| 107 | * \brief Initialize an RSA context |
| 108 | * |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 109 | * Note: Set padding to RSA_PKCS_V21 for the RSAES-OAEP |
| 110 | * encryption scheme and the RSASSA-PSS signature scheme. |
| 111 | * |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 112 | * \param ctx RSA context to be initialized |
| 113 | * \param padding RSA_PKCS_V15 or RSA_PKCS_V21 |
| 114 | * \param hash_id RSA_PKCS_V21 hash identifier |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 115 | * |
| 116 | * \note The hash_id parameter is actually ignored |
| 117 | * when using RSA_PKCS_V15 padding. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 118 | */ |
| 119 | void rsa_init( rsa_context *ctx, |
| 120 | int padding, |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 121 | int hash_id); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * \brief Generate an RSA keypair |
| 125 | * |
| 126 | * \param ctx RSA context that will hold the key |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 127 | * \param f_rng RNG function |
| 128 | * \param p_rng RNG parameter |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 129 | * \param nbits size of the public key in bits |
| 130 | * \param exponent public exponent (e.g., 65537) |
| 131 | * |
| 132 | * \note rsa_init() must be called beforehand to setup |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 133 | * the RSA context. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 134 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 135 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 136 | */ |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 137 | int rsa_gen_key( rsa_context *ctx, |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 138 | int (*f_rng)(void *, unsigned char *, size_t), |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 139 | void *p_rng, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 140 | unsigned int nbits, int exponent ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * \brief Check a public RSA key |
| 144 | * |
| 145 | * \param ctx RSA context to be checked |
| 146 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 147 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 148 | */ |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 149 | int rsa_check_pubkey( const rsa_context *ctx ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 150 | |
| 151 | /** |
| 152 | * \brief Check a private RSA key |
| 153 | * |
| 154 | * \param ctx RSA context to be checked |
| 155 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 156 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 157 | */ |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 158 | int rsa_check_privkey( const rsa_context *ctx ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * \brief Do an RSA public key operation |
| 162 | * |
| 163 | * \param ctx RSA context |
| 164 | * \param input input buffer |
| 165 | * \param output output buffer |
| 166 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 167 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 168 | * |
| 169 | * \note This function does NOT take care of message |
Paul Bakker | 619467a | 2009-03-28 23:26:51 +0000 | [diff] [blame] | 170 | * padding. Also, be sure to set input[0] = 0 or assure that |
| 171 | * input is smaller than N. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 172 | * |
| 173 | * \note The input and output buffers must be large |
| 174 | * enough (eg. 128 bytes if RSA-1024 is used). |
| 175 | */ |
| 176 | int rsa_public( rsa_context *ctx, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 177 | const unsigned char *input, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 178 | unsigned char *output ); |
| 179 | |
| 180 | /** |
| 181 | * \brief Do an RSA private key operation |
| 182 | * |
| 183 | * \param ctx RSA context |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 184 | * \param f_rng RNG function (Needed for blinding) |
| 185 | * \param p_rng RNG parameter |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 186 | * \param input input buffer |
| 187 | * \param output output buffer |
| 188 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 189 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 190 | * |
| 191 | * \note The input and output buffers must be large |
| 192 | * enough (eg. 128 bytes if RSA-1024 is used). |
| 193 | */ |
| 194 | int rsa_private( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 195 | int (*f_rng)(void *, unsigned char *, size_t), |
| 196 | void *p_rng, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 197 | const unsigned char *input, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 198 | unsigned char *output ); |
| 199 | |
| 200 | /** |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 201 | * \brief Generic wrapper to perform a PKCS#1 encryption using the |
| 202 | * mode from the context. Add the message padding, then do an |
| 203 | * RSA operation. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 204 | * |
| 205 | * \param ctx RSA context |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 206 | * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding |
| 207 | * and RSA_PRIVATE) |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 208 | * \param p_rng RNG parameter |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 209 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | 592457c | 2009-04-01 19:01:43 +0000 | [diff] [blame] | 210 | * \param ilen contains the plaintext length |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 211 | * \param input buffer holding the data to be encrypted |
| 212 | * \param output buffer that will hold the ciphertext |
| 213 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 214 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 215 | * |
| 216 | * \note The output buffer must be as large as the size |
| 217 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 218 | */ |
| 219 | int rsa_pkcs1_encrypt( rsa_context *ctx, |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 220 | int (*f_rng)(void *, unsigned char *, size_t), |
Paul Bakker | 21eb280 | 2010-08-16 11:10:02 +0000 | [diff] [blame] | 221 | void *p_rng, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 222 | int mode, size_t ilen, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 223 | const unsigned char *input, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 224 | unsigned char *output ); |
| 225 | |
| 226 | /** |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 227 | * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT) |
| 228 | * |
| 229 | * \param ctx RSA context |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 230 | * \param f_rng RNG function (Needed for padding and RSA_PRIVATE) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 231 | * \param p_rng RNG parameter |
| 232 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
| 233 | * \param ilen contains the plaintext length |
| 234 | * \param input buffer holding the data to be encrypted |
| 235 | * \param output buffer that will hold the ciphertext |
| 236 | * |
| 237 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
| 238 | * |
| 239 | * \note The output buffer must be as large as the size |
| 240 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 241 | */ |
| 242 | int rsa_rsaes_pkcs1_v15_encrypt( rsa_context *ctx, |
| 243 | int (*f_rng)(void *, unsigned char *, size_t), |
| 244 | void *p_rng, |
| 245 | int mode, size_t ilen, |
| 246 | const unsigned char *input, |
| 247 | unsigned char *output ); |
| 248 | |
| 249 | /** |
| 250 | * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT) |
| 251 | * |
| 252 | * \param ctx RSA context |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 253 | * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding |
| 254 | * and RSA_PRIVATE) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 255 | * \param p_rng RNG parameter |
| 256 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | a43231c | 2013-02-28 17:33:49 +0100 | [diff] [blame] | 257 | * \param label buffer holding the custom label to use |
| 258 | * \param label_len contains the label length |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 259 | * \param ilen contains the plaintext length |
| 260 | * \param input buffer holding the data to be encrypted |
| 261 | * \param output buffer that will hold the ciphertext |
| 262 | * |
| 263 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
| 264 | * |
| 265 | * \note The output buffer must be as large as the size |
| 266 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 267 | */ |
| 268 | int rsa_rsaes_oaep_encrypt( rsa_context *ctx, |
| 269 | int (*f_rng)(void *, unsigned char *, size_t), |
| 270 | void *p_rng, |
Paul Bakker | a43231c | 2013-02-28 17:33:49 +0100 | [diff] [blame] | 271 | int mode, |
| 272 | const unsigned char *label, size_t label_len, |
| 273 | size_t ilen, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 274 | const unsigned char *input, |
| 275 | unsigned char *output ); |
| 276 | |
| 277 | /** |
| 278 | * \brief Generic wrapper to perform a PKCS#1 decryption using the |
| 279 | * mode from the context. Do an RSA operation, then remove |
| 280 | * the message padding |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 281 | * |
| 282 | * \param ctx RSA context |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 283 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 284 | * \param p_rng RNG parameter |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 285 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | 4d8ca70 | 2011-08-09 10:31:05 +0000 | [diff] [blame] | 286 | * \param olen will contain the plaintext length |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 287 | * \param input buffer holding the encrypted data |
| 288 | * \param output buffer that will hold the plaintext |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 289 | * \param output_max_len maximum length of the output buffer |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 290 | * |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 291 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 292 | * |
| 293 | * \note The output buffer must be as large as the size |
Paul Bakker | 060c568 | 2009-01-12 21:48:39 +0000 | [diff] [blame] | 294 | * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise |
| 295 | * an error is thrown. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 296 | */ |
| 297 | int rsa_pkcs1_decrypt( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 298 | int (*f_rng)(void *, unsigned char *, size_t), |
| 299 | void *p_rng, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 300 | int mode, size_t *olen, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 301 | const unsigned char *input, |
Paul Bakker | 060c568 | 2009-01-12 21:48:39 +0000 | [diff] [blame] | 302 | unsigned char *output, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 303 | size_t output_max_len ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 304 | |
| 305 | /** |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 306 | * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT) |
| 307 | * |
| 308 | * \param ctx RSA context |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 309 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 310 | * \param p_rng RNG parameter |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 311 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
| 312 | * \param olen will contain the plaintext length |
| 313 | * \param input buffer holding the encrypted data |
| 314 | * \param output buffer that will hold the plaintext |
| 315 | * \param output_max_len maximum length of the output buffer |
| 316 | * |
| 317 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
| 318 | * |
| 319 | * \note The output buffer must be as large as the size |
| 320 | * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise |
| 321 | * an error is thrown. |
| 322 | */ |
| 323 | int rsa_rsaes_pkcs1_v15_decrypt( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 324 | int (*f_rng)(void *, unsigned char *, size_t), |
| 325 | void *p_rng, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 326 | int mode, size_t *olen, |
| 327 | const unsigned char *input, |
| 328 | unsigned char *output, |
| 329 | size_t output_max_len ); |
| 330 | |
| 331 | /** |
| 332 | * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT) |
| 333 | * |
| 334 | * \param ctx RSA context |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 335 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 336 | * \param p_rng RNG parameter |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 337 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | a43231c | 2013-02-28 17:33:49 +0100 | [diff] [blame] | 338 | * \param label buffer holding the custom label to use |
| 339 | * \param label_len contains the label length |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 340 | * \param olen will contain the plaintext length |
| 341 | * \param input buffer holding the encrypted data |
| 342 | * \param output buffer that will hold the plaintext |
| 343 | * \param output_max_len maximum length of the output buffer |
| 344 | * |
| 345 | * \return 0 if successful, or an POLARSSL_ERR_RSA_XXX error code |
| 346 | * |
| 347 | * \note The output buffer must be as large as the size |
| 348 | * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise |
| 349 | * an error is thrown. |
| 350 | */ |
| 351 | int rsa_rsaes_oaep_decrypt( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 352 | int (*f_rng)(void *, unsigned char *, size_t), |
| 353 | void *p_rng, |
Paul Bakker | a43231c | 2013-02-28 17:33:49 +0100 | [diff] [blame] | 354 | int mode, |
| 355 | const unsigned char *label, size_t label_len, |
| 356 | size_t *olen, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 357 | const unsigned char *input, |
| 358 | unsigned char *output, |
| 359 | size_t output_max_len ); |
| 360 | |
| 361 | /** |
| 362 | * \brief Generic wrapper to perform a PKCS#1 signature using the |
| 363 | * mode from the context. Do a private RSA operation to sign |
| 364 | * a message digest |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 365 | * |
| 366 | * \param ctx RSA context |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 367 | * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for |
| 368 | * RSA_PRIVATE) |
Paul Bakker | 9dcc322 | 2011-03-08 14:16:06 +0000 | [diff] [blame] | 369 | * \param p_rng RNG parameter |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 370 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 371 | * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) |
| 372 | * \param hashlen message digest length (for POLARSSL_MD_NONE only) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 373 | * \param hash buffer holding the message digest |
| 374 | * \param sig buffer that will hold the ciphertext |
| 375 | * |
| 376 | * \return 0 if the signing operation was successful, |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 377 | * or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 378 | * |
| 379 | * \note The "sig" buffer must be as large as the size |
| 380 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
Paul Bakker | 9dcc322 | 2011-03-08 14:16:06 +0000 | [diff] [blame] | 381 | * |
| 382 | * \note In case of PKCS#1 v2.1 encoding keep in mind that |
| 383 | * the hash_id in the RSA context is the one used for the |
| 384 | * encoding. hash_id in the function call is the type of hash |
| 385 | * that is encoded. According to RFC 3447 it is advised to |
| 386 | * keep both hashes the same. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 387 | */ |
| 388 | int rsa_pkcs1_sign( rsa_context *ctx, |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 389 | int (*f_rng)(void *, unsigned char *, size_t), |
Paul Bakker | 9dcc322 | 2011-03-08 14:16:06 +0000 | [diff] [blame] | 390 | void *p_rng, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 391 | int mode, |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 392 | md_type_t md_alg, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 393 | unsigned int hashlen, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 394 | const unsigned char *hash, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 395 | unsigned char *sig ); |
| 396 | |
| 397 | /** |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 398 | * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN) |
| 399 | * |
| 400 | * \param ctx RSA context |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 401 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 402 | * \param p_rng RNG parameter |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 403 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 404 | * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) |
| 405 | * \param hashlen message digest length (for POLARSSL_MD_NONE only) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 406 | * \param hash buffer holding the message digest |
| 407 | * \param sig buffer that will hold the ciphertext |
| 408 | * |
| 409 | * \return 0 if the signing operation was successful, |
| 410 | * or an POLARSSL_ERR_RSA_XXX error code |
| 411 | * |
| 412 | * \note The "sig" buffer must be as large as the size |
| 413 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 414 | */ |
| 415 | int rsa_rsassa_pkcs1_v15_sign( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 416 | int (*f_rng)(void *, unsigned char *, size_t), |
| 417 | void *p_rng, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 418 | int mode, |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 419 | md_type_t md_alg, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 420 | unsigned int hashlen, |
| 421 | const unsigned char *hash, |
| 422 | unsigned char *sig ); |
| 423 | |
| 424 | /** |
| 425 | * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN) |
| 426 | * |
| 427 | * \param ctx RSA context |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 428 | * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for |
| 429 | * RSA_PRIVATE) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 430 | * \param p_rng RNG parameter |
| 431 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 432 | * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) |
| 433 | * \param hashlen message digest length (for POLARSSL_MD_NONE only) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 434 | * \param hash buffer holding the message digest |
| 435 | * \param sig buffer that will hold the ciphertext |
| 436 | * |
| 437 | * \return 0 if the signing operation was successful, |
| 438 | * or an POLARSSL_ERR_RSA_XXX error code |
| 439 | * |
| 440 | * \note The "sig" buffer must be as large as the size |
| 441 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 442 | * |
| 443 | * \note In case of PKCS#1 v2.1 encoding keep in mind that |
| 444 | * the hash_id in the RSA context is the one used for the |
| 445 | * encoding. hash_id in the function call is the type of hash |
| 446 | * that is encoded. According to RFC 3447 it is advised to |
| 447 | * keep both hashes the same. |
| 448 | */ |
| 449 | int rsa_rsassa_pss_sign( rsa_context *ctx, |
| 450 | int (*f_rng)(void *, unsigned char *, size_t), |
| 451 | void *p_rng, |
| 452 | int mode, |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 453 | md_type_t md_alg, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 454 | unsigned int hashlen, |
| 455 | const unsigned char *hash, |
| 456 | unsigned char *sig ); |
| 457 | |
| 458 | /** |
| 459 | * \brief Generic wrapper to perform a PKCS#1 verification using the |
| 460 | * mode from the context. Do a public RSA operation and check |
| 461 | * the message digest |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 462 | * |
| 463 | * \param ctx points to an RSA public key |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 464 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 465 | * \param p_rng RNG parameter |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 466 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 467 | * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) |
| 468 | * \param hashlen message digest length (for POLARSSL_MD_NONE only) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 469 | * \param hash buffer holding the message digest |
| 470 | * \param sig buffer holding the ciphertext |
| 471 | * |
| 472 | * \return 0 if the verify operation was successful, |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 473 | * or an POLARSSL_ERR_RSA_XXX error code |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 474 | * |
| 475 | * \note The "sig" buffer must be as large as the size |
| 476 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
Paul Bakker | 9dcc322 | 2011-03-08 14:16:06 +0000 | [diff] [blame] | 477 | * |
| 478 | * \note In case of PKCS#1 v2.1 encoding keep in mind that |
| 479 | * the hash_id in the RSA context is the one used for the |
| 480 | * verification. hash_id in the function call is the type of hash |
| 481 | * that is verified. According to RFC 3447 it is advised to |
| 482 | * keep both hashes the same. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 483 | */ |
| 484 | int rsa_pkcs1_verify( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 485 | int (*f_rng)(void *, unsigned char *, size_t), |
| 486 | void *p_rng, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 487 | int mode, |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 488 | md_type_t md_alg, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 489 | unsigned int hashlen, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 490 | const unsigned char *hash, |
Manuel Pégourié-Gonnard | cc0a9d0 | 2013-08-12 11:34:35 +0200 | [diff] [blame] | 491 | const unsigned char *sig ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 492 | |
| 493 | /** |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 494 | * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY) |
| 495 | * |
| 496 | * \param ctx points to an RSA public key |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 497 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 498 | * \param p_rng RNG parameter |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 499 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 500 | * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) |
| 501 | * \param hashlen message digest length (for POLARSSL_MD_NONE only) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 502 | * \param hash buffer holding the message digest |
| 503 | * \param sig buffer holding the ciphertext |
| 504 | * |
| 505 | * \return 0 if the verify operation was successful, |
| 506 | * or an POLARSSL_ERR_RSA_XXX error code |
| 507 | * |
| 508 | * \note The "sig" buffer must be as large as the size |
| 509 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 510 | */ |
| 511 | int rsa_rsassa_pkcs1_v15_verify( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 512 | int (*f_rng)(void *, unsigned char *, size_t), |
| 513 | void *p_rng, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 514 | int mode, |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 515 | md_type_t md_alg, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 516 | unsigned int hashlen, |
| 517 | const unsigned char *hash, |
Manuel Pégourié-Gonnard | cc0a9d0 | 2013-08-12 11:34:35 +0200 | [diff] [blame] | 518 | const unsigned char *sig ); |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 519 | |
| 520 | /** |
| 521 | * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY) |
| 522 | * \brief Do a public RSA and check the message digest |
| 523 | * |
| 524 | * \param ctx points to an RSA public key |
Paul Bakker | f451bac | 2013-08-30 15:37:02 +0200 | [diff] [blame] | 525 | * \param f_rng RNG function (Only needed for RSA_PRIVATE) |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 526 | * \param p_rng RNG parameter |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 527 | * \param mode RSA_PUBLIC or RSA_PRIVATE |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 528 | * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) |
| 529 | * \param hashlen message digest length (for POLARSSL_MD_NONE only) |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 530 | * \param hash buffer holding the message digest |
| 531 | * \param sig buffer holding the ciphertext |
| 532 | * |
| 533 | * \return 0 if the verify operation was successful, |
| 534 | * or an POLARSSL_ERR_RSA_XXX error code |
| 535 | * |
| 536 | * \note The "sig" buffer must be as large as the size |
| 537 | * of ctx->N (eg. 128 bytes if RSA-1024 is used). |
| 538 | * |
| 539 | * \note In case of PKCS#1 v2.1 encoding keep in mind that |
| 540 | * the hash_id in the RSA context is the one used for the |
| 541 | * verification. hash_id in the function call is the type of hash |
| 542 | * that is verified. According to RFC 3447 it is advised to |
| 543 | * keep both hashes the same. |
| 544 | */ |
| 545 | int rsa_rsassa_pss_verify( rsa_context *ctx, |
Paul Bakker | 548957d | 2013-08-30 10:30:02 +0200 | [diff] [blame] | 546 | int (*f_rng)(void *, unsigned char *, size_t), |
| 547 | void *p_rng, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 548 | int mode, |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 549 | md_type_t md_alg, |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 550 | unsigned int hashlen, |
| 551 | const unsigned char *hash, |
Manuel Pégourié-Gonnard | cc0a9d0 | 2013-08-12 11:34:35 +0200 | [diff] [blame] | 552 | const unsigned char *sig ); |
Paul Bakker | b386913 | 2013-02-28 17:21:01 +0100 | [diff] [blame] | 553 | |
| 554 | /** |
Manuel Pégourié-Gonnard | 3053f5b | 2013-08-14 13:39:57 +0200 | [diff] [blame] | 555 | * \brief Copy the components of an RSA context |
| 556 | * |
| 557 | * \param dst Destination context |
| 558 | * \param src Source context |
| 559 | * |
| 560 | * \return O on success, |
| 561 | * POLARSSL_ERR_MPI_MALLOC_FAILED on memory allocation failure |
| 562 | */ |
| 563 | int rsa_copy( rsa_context *dst, const rsa_context *src ); |
| 564 | |
| 565 | /** |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 566 | * \brief Free the components of an RSA key |
Paul Bakker | 13e2dfe | 2009-07-28 07:18:38 +0000 | [diff] [blame] | 567 | * |
| 568 | * \param ctx RSA Context to free |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 569 | */ |
| 570 | void rsa_free( rsa_context *ctx ); |
| 571 | |
| 572 | /** |
| 573 | * \brief Checkup routine |
| 574 | * |
| 575 | * \return 0 if successful, or 1 if the test failed |
| 576 | */ |
| 577 | int rsa_self_test( int verbose ); |
| 578 | |
| 579 | #ifdef __cplusplus |
| 580 | } |
| 581 | #endif |
| 582 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 583 | #endif /* POLARSSL_RSA_C */ |
| 584 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 585 | #endif /* rsa.h */ |