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