mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 /**
markrad 0:cdf462088d13 2 * \file rsa.h
markrad 0:cdf462088d13 3 *
markrad 0:cdf462088d13 4 * \brief The RSA public-key cryptosystem
markrad 0:cdf462088d13 5 *
markrad 0:cdf462088d13 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 7 * SPDX-License-Identifier: Apache-2.0
markrad 0:cdf462088d13 8 *
markrad 0:cdf462088d13 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
markrad 0:cdf462088d13 10 * not use this file except in compliance with the License.
markrad 0:cdf462088d13 11 * You may obtain a copy of the License at
markrad 0:cdf462088d13 12 *
markrad 0:cdf462088d13 13 * http://www.apache.org/licenses/LICENSE-2.0
markrad 0:cdf462088d13 14 *
markrad 0:cdf462088d13 15 * Unless required by applicable law or agreed to in writing, software
markrad 0:cdf462088d13 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
markrad 0:cdf462088d13 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
markrad 0:cdf462088d13 18 * See the License for the specific language governing permissions and
markrad 0:cdf462088d13 19 * limitations under the License.
markrad 0:cdf462088d13 20 *
markrad 0:cdf462088d13 21 * This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 22 */
markrad 0:cdf462088d13 23 #ifndef MBEDTLS_RSA_H
markrad 0:cdf462088d13 24 #define MBEDTLS_RSA_H
markrad 0:cdf462088d13 25
markrad 0:cdf462088d13 26 #if !defined(MBEDTLS_CONFIG_FILE)
markrad 0:cdf462088d13 27 #include "config.h"
markrad 0:cdf462088d13 28 #else
markrad 0:cdf462088d13 29 #include MBEDTLS_CONFIG_FILE
markrad 0:cdf462088d13 30 #endif
markrad 0:cdf462088d13 31
markrad 0:cdf462088d13 32 #include "bignum.h"
markrad 0:cdf462088d13 33 #include "md.h"
markrad 0:cdf462088d13 34
markrad 0:cdf462088d13 35 #if defined(MBEDTLS_THREADING_C)
markrad 0:cdf462088d13 36 #include "threading.h"
markrad 0:cdf462088d13 37 #endif
markrad 0:cdf462088d13 38
markrad 0:cdf462088d13 39 /*
markrad 0:cdf462088d13 40 * RSA Error codes
markrad 0:cdf462088d13 41 */
markrad 0:cdf462088d13 42 #define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */
markrad 0:cdf462088d13 43 #define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */
markrad 0:cdf462088d13 44 #define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */
markrad 0:cdf462088d13 45 #define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the library's validity check. */
markrad 0:cdf462088d13 46 #define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */
markrad 0:cdf462088d13 47 #define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */
markrad 0:cdf462088d13 48 #define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */
markrad 0:cdf462088d13 49 #define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */
markrad 0:cdf462088d13 50 #define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */
markrad 0:cdf462088d13 51
markrad 0:cdf462088d13 52 /*
markrad 0:cdf462088d13 53 * RSA constants
markrad 0:cdf462088d13 54 */
markrad 0:cdf462088d13 55 #define MBEDTLS_RSA_PUBLIC 0
markrad 0:cdf462088d13 56 #define MBEDTLS_RSA_PRIVATE 1
markrad 0:cdf462088d13 57
markrad 0:cdf462088d13 58 #define MBEDTLS_RSA_PKCS_V15 0
markrad 0:cdf462088d13 59 #define MBEDTLS_RSA_PKCS_V21 1
markrad 0:cdf462088d13 60
markrad 0:cdf462088d13 61 #define MBEDTLS_RSA_SIGN 1
markrad 0:cdf462088d13 62 #define MBEDTLS_RSA_CRYPT 2
markrad 0:cdf462088d13 63
markrad 0:cdf462088d13 64 #define MBEDTLS_RSA_SALT_LEN_ANY -1
markrad 0:cdf462088d13 65
markrad 0:cdf462088d13 66 /*
markrad 0:cdf462088d13 67 * The above constants may be used even if the RSA module is compile out,
markrad 0:cdf462088d13 68 * eg for alternative (PKCS#11) RSA implemenations in the PK layers.
markrad 0:cdf462088d13 69 */
markrad 0:cdf462088d13 70 #if defined(MBEDTLS_RSA_C)
markrad 0:cdf462088d13 71
markrad 0:cdf462088d13 72 #ifdef __cplusplus
markrad 0:cdf462088d13 73 extern "C" {
markrad 0:cdf462088d13 74 #endif
markrad 0:cdf462088d13 75
markrad 0:cdf462088d13 76 /**
markrad 0:cdf462088d13 77 * \brief RSA context structure
markrad 0:cdf462088d13 78 */
markrad 0:cdf462088d13 79 typedef struct
markrad 0:cdf462088d13 80 {
markrad 0:cdf462088d13 81 int ver; /*!< always 0 */
markrad 0:cdf462088d13 82 size_t len; /*!< size(N) in chars */
markrad 0:cdf462088d13 83
markrad 0:cdf462088d13 84 mbedtls_mpi N; /*!< public modulus */
markrad 0:cdf462088d13 85 mbedtls_mpi E; /*!< public exponent */
markrad 0:cdf462088d13 86
markrad 0:cdf462088d13 87 mbedtls_mpi D; /*!< private exponent */
markrad 0:cdf462088d13 88 mbedtls_mpi P; /*!< 1st prime factor */
markrad 0:cdf462088d13 89 mbedtls_mpi Q; /*!< 2nd prime factor */
markrad 0:cdf462088d13 90 mbedtls_mpi DP; /*!< D % (P - 1) */
markrad 0:cdf462088d13 91 mbedtls_mpi DQ; /*!< D % (Q - 1) */
markrad 0:cdf462088d13 92 mbedtls_mpi QP; /*!< 1 / (Q % P) */
markrad 0:cdf462088d13 93
markrad 0:cdf462088d13 94 mbedtls_mpi RN; /*!< cached R^2 mod N */
markrad 0:cdf462088d13 95 mbedtls_mpi RP; /*!< cached R^2 mod P */
markrad 0:cdf462088d13 96 mbedtls_mpi RQ; /*!< cached R^2 mod Q */
markrad 0:cdf462088d13 97
markrad 0:cdf462088d13 98 mbedtls_mpi Vi; /*!< cached blinding value */
markrad 0:cdf462088d13 99 mbedtls_mpi Vf; /*!< cached un-blinding value */
markrad 0:cdf462088d13 100
markrad 0:cdf462088d13 101 int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
markrad 0:cdf462088d13 102 MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */
markrad 0:cdf462088d13 103 int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
markrad 0:cdf462088d13 104 specified in the mbedtls_md.h header file
markrad 0:cdf462088d13 105 for the EME-OAEP and EMSA-PSS
markrad 0:cdf462088d13 106 encoding */
markrad 0:cdf462088d13 107 #if defined(MBEDTLS_THREADING_C)
markrad 0:cdf462088d13 108 mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex */
markrad 0:cdf462088d13 109 #endif
markrad 0:cdf462088d13 110 }
markrad 0:cdf462088d13 111 mbedtls_rsa_context;
markrad 0:cdf462088d13 112
markrad 0:cdf462088d13 113 /**
markrad 0:cdf462088d13 114 * \brief Initialize an RSA context
markrad 0:cdf462088d13 115 *
markrad 0:cdf462088d13 116 * Note: Set padding to MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP
markrad 0:cdf462088d13 117 * encryption scheme and the RSASSA-PSS signature scheme.
markrad 0:cdf462088d13 118 *
markrad 0:cdf462088d13 119 * \param ctx RSA context to be initialized
markrad 0:cdf462088d13 120 * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
markrad 0:cdf462088d13 121 * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
markrad 0:cdf462088d13 122 *
markrad 0:cdf462088d13 123 * \note The hash_id parameter is actually ignored
markrad 0:cdf462088d13 124 * when using MBEDTLS_RSA_PKCS_V15 padding.
markrad 0:cdf462088d13 125 *
markrad 0:cdf462088d13 126 * \note Choice of padding mode is strictly enforced for private key
markrad 0:cdf462088d13 127 * operations, since there might be security concerns in
markrad 0:cdf462088d13 128 * mixing padding modes. For public key operations it's merely
markrad 0:cdf462088d13 129 * a default value, which can be overriden by calling specific
markrad 0:cdf462088d13 130 * rsa_rsaes_xxx or rsa_rsassa_xxx functions.
markrad 0:cdf462088d13 131 *
markrad 0:cdf462088d13 132 * \note The chosen hash is always used for OEAP encryption.
markrad 0:cdf462088d13 133 * For PSS signatures, it's always used for making signatures,
markrad 0:cdf462088d13 134 * but can be overriden (and always is, if set to
markrad 0:cdf462088d13 135 * MBEDTLS_MD_NONE) for verifying them.
markrad 0:cdf462088d13 136 */
markrad 0:cdf462088d13 137 void mbedtls_rsa_init( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 138 int padding,
markrad 0:cdf462088d13 139 int hash_id);
markrad 0:cdf462088d13 140
markrad 0:cdf462088d13 141 /**
markrad 0:cdf462088d13 142 * \brief Set padding for an already initialized RSA context
markrad 0:cdf462088d13 143 * See \c mbedtls_rsa_init() for details.
markrad 0:cdf462088d13 144 *
markrad 0:cdf462088d13 145 * \param ctx RSA context to be set
markrad 0:cdf462088d13 146 * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
markrad 0:cdf462088d13 147 * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
markrad 0:cdf462088d13 148 */
markrad 0:cdf462088d13 149 void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id);
markrad 0:cdf462088d13 150
markrad 0:cdf462088d13 151 /**
markrad 0:cdf462088d13 152 * \brief Generate an RSA keypair
markrad 0:cdf462088d13 153 *
markrad 0:cdf462088d13 154 * \param ctx RSA context that will hold the key
markrad 0:cdf462088d13 155 * \param f_rng RNG function
markrad 0:cdf462088d13 156 * \param p_rng RNG parameter
markrad 0:cdf462088d13 157 * \param nbits size of the public key in bits
markrad 0:cdf462088d13 158 * \param exponent public exponent (e.g., 65537)
markrad 0:cdf462088d13 159 *
markrad 0:cdf462088d13 160 * \note mbedtls_rsa_init() must be called beforehand to setup
markrad 0:cdf462088d13 161 * the RSA context.
markrad 0:cdf462088d13 162 *
markrad 0:cdf462088d13 163 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 164 */
markrad 0:cdf462088d13 165 int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 166 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 167 void *p_rng,
markrad 0:cdf462088d13 168 unsigned int nbits, int exponent );
markrad 0:cdf462088d13 169
markrad 0:cdf462088d13 170 /**
markrad 0:cdf462088d13 171 * \brief Check a public RSA key
markrad 0:cdf462088d13 172 *
markrad 0:cdf462088d13 173 * \param ctx RSA context to be checked
markrad 0:cdf462088d13 174 *
markrad 0:cdf462088d13 175 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 176 */
markrad 0:cdf462088d13 177 int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx );
markrad 0:cdf462088d13 178
markrad 0:cdf462088d13 179 /**
markrad 0:cdf462088d13 180 * \brief Check a private RSA key
markrad 0:cdf462088d13 181 *
markrad 0:cdf462088d13 182 * \param ctx RSA context to be checked
markrad 0:cdf462088d13 183 *
markrad 0:cdf462088d13 184 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 185 */
markrad 0:cdf462088d13 186 int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx );
markrad 0:cdf462088d13 187
markrad 0:cdf462088d13 188 /**
markrad 0:cdf462088d13 189 * \brief Check a public-private RSA key pair.
markrad 0:cdf462088d13 190 * Check each of the contexts, and make sure they match.
markrad 0:cdf462088d13 191 *
markrad 0:cdf462088d13 192 * \param pub RSA context holding the public key
markrad 0:cdf462088d13 193 * \param prv RSA context holding the private key
markrad 0:cdf462088d13 194 *
markrad 0:cdf462088d13 195 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 196 */
markrad 0:cdf462088d13 197 int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv );
markrad 0:cdf462088d13 198
markrad 0:cdf462088d13 199 /**
markrad 0:cdf462088d13 200 * \brief Do an RSA public key operation
markrad 0:cdf462088d13 201 *
markrad 0:cdf462088d13 202 * \param ctx RSA context
markrad 0:cdf462088d13 203 * \param input input buffer
markrad 0:cdf462088d13 204 * \param output output buffer
markrad 0:cdf462088d13 205 *
markrad 0:cdf462088d13 206 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 207 *
markrad 0:cdf462088d13 208 * \note This function does NOT take care of message
markrad 0:cdf462088d13 209 * padding. Also, be sure to set input[0] = 0 or ensure that
markrad 0:cdf462088d13 210 * input is smaller than N.
markrad 0:cdf462088d13 211 *
markrad 0:cdf462088d13 212 * \note The input and output buffers must be large
markrad 0:cdf462088d13 213 * enough (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 214 */
markrad 0:cdf462088d13 215 int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 216 const unsigned char *input,
markrad 0:cdf462088d13 217 unsigned char *output );
markrad 0:cdf462088d13 218
markrad 0:cdf462088d13 219 /**
markrad 0:cdf462088d13 220 * \brief Do an RSA private key operation
markrad 0:cdf462088d13 221 *
markrad 0:cdf462088d13 222 * \param ctx RSA context
markrad 0:cdf462088d13 223 * \param f_rng RNG function (Needed for blinding)
markrad 0:cdf462088d13 224 * \param p_rng RNG parameter
markrad 0:cdf462088d13 225 * \param input input buffer
markrad 0:cdf462088d13 226 * \param output output buffer
markrad 0:cdf462088d13 227 *
markrad 0:cdf462088d13 228 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 229 *
markrad 0:cdf462088d13 230 * \note The input and output buffers must be large
markrad 0:cdf462088d13 231 * enough (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 232 */
markrad 0:cdf462088d13 233 int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 234 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 235 void *p_rng,
markrad 0:cdf462088d13 236 const unsigned char *input,
markrad 0:cdf462088d13 237 unsigned char *output );
markrad 0:cdf462088d13 238
markrad 0:cdf462088d13 239 /**
markrad 0:cdf462088d13 240 * \brief Generic wrapper to perform a PKCS#1 encryption using the
markrad 0:cdf462088d13 241 * mode from the context. Add the message padding, then do an
markrad 0:cdf462088d13 242 * RSA operation.
markrad 0:cdf462088d13 243 *
markrad 0:cdf462088d13 244 * \param ctx RSA context
markrad 0:cdf462088d13 245 * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
markrad 0:cdf462088d13 246 * and MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 247 * \param p_rng RNG parameter
markrad 0:cdf462088d13 248 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 249 * \param ilen contains the plaintext length
markrad 0:cdf462088d13 250 * \param input buffer holding the data to be encrypted
markrad 0:cdf462088d13 251 * \param output buffer that will hold the ciphertext
markrad 0:cdf462088d13 252 *
markrad 0:cdf462088d13 253 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 254 *
markrad 0:cdf462088d13 255 * \note The output buffer must be as large as the size
markrad 0:cdf462088d13 256 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 257 */
markrad 0:cdf462088d13 258 int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 259 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 260 void *p_rng,
markrad 0:cdf462088d13 261 int mode, size_t ilen,
markrad 0:cdf462088d13 262 const unsigned char *input,
markrad 0:cdf462088d13 263 unsigned char *output );
markrad 0:cdf462088d13 264
markrad 0:cdf462088d13 265 /**
markrad 0:cdf462088d13 266 * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT)
markrad 0:cdf462088d13 267 *
markrad 0:cdf462088d13 268 * \param ctx RSA context
markrad 0:cdf462088d13 269 * \param f_rng RNG function (Needed for padding and MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 270 * \param p_rng RNG parameter
markrad 0:cdf462088d13 271 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 272 * \param ilen contains the plaintext length
markrad 0:cdf462088d13 273 * \param input buffer holding the data to be encrypted
markrad 0:cdf462088d13 274 * \param output buffer that will hold the ciphertext
markrad 0:cdf462088d13 275 *
markrad 0:cdf462088d13 276 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 277 *
markrad 0:cdf462088d13 278 * \note The output buffer must be as large as the size
markrad 0:cdf462088d13 279 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 280 */
markrad 0:cdf462088d13 281 int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 282 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 283 void *p_rng,
markrad 0:cdf462088d13 284 int mode, size_t ilen,
markrad 0:cdf462088d13 285 const unsigned char *input,
markrad 0:cdf462088d13 286 unsigned char *output );
markrad 0:cdf462088d13 287
markrad 0:cdf462088d13 288 /**
markrad 0:cdf462088d13 289 * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT)
markrad 0:cdf462088d13 290 *
markrad 0:cdf462088d13 291 * \param ctx RSA context
markrad 0:cdf462088d13 292 * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
markrad 0:cdf462088d13 293 * and MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 294 * \param p_rng RNG parameter
markrad 0:cdf462088d13 295 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 296 * \param label buffer holding the custom label to use
markrad 0:cdf462088d13 297 * \param label_len contains the label length
markrad 0:cdf462088d13 298 * \param ilen contains the plaintext length
markrad 0:cdf462088d13 299 * \param input buffer holding the data to be encrypted
markrad 0:cdf462088d13 300 * \param output buffer that will hold the ciphertext
markrad 0:cdf462088d13 301 *
markrad 0:cdf462088d13 302 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 303 *
markrad 0:cdf462088d13 304 * \note The output buffer must be as large as the size
markrad 0:cdf462088d13 305 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 306 */
markrad 0:cdf462088d13 307 int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 308 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 309 void *p_rng,
markrad 0:cdf462088d13 310 int mode,
markrad 0:cdf462088d13 311 const unsigned char *label, size_t label_len,
markrad 0:cdf462088d13 312 size_t ilen,
markrad 0:cdf462088d13 313 const unsigned char *input,
markrad 0:cdf462088d13 314 unsigned char *output );
markrad 0:cdf462088d13 315
markrad 0:cdf462088d13 316 /**
markrad 0:cdf462088d13 317 * \brief Generic wrapper to perform a PKCS#1 decryption using the
markrad 0:cdf462088d13 318 * mode from the context. Do an RSA operation, then remove
markrad 0:cdf462088d13 319 * the message padding
markrad 0:cdf462088d13 320 *
markrad 0:cdf462088d13 321 * \param ctx RSA context
markrad 0:cdf462088d13 322 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 323 * \param p_rng RNG parameter
markrad 0:cdf462088d13 324 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 325 * \param olen will contain the plaintext length
markrad 0:cdf462088d13 326 * \param input buffer holding the encrypted data
markrad 0:cdf462088d13 327 * \param output buffer that will hold the plaintext
markrad 0:cdf462088d13 328 * \param output_max_len maximum length of the output buffer
markrad 0:cdf462088d13 329 *
markrad 0:cdf462088d13 330 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 331 *
markrad 0:cdf462088d13 332 * \note The output buffer must be as large as the size
markrad 0:cdf462088d13 333 * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
markrad 0:cdf462088d13 334 * an error is thrown.
markrad 0:cdf462088d13 335 */
markrad 0:cdf462088d13 336 int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 337 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 338 void *p_rng,
markrad 0:cdf462088d13 339 int mode, size_t *olen,
markrad 0:cdf462088d13 340 const unsigned char *input,
markrad 0:cdf462088d13 341 unsigned char *output,
markrad 0:cdf462088d13 342 size_t output_max_len );
markrad 0:cdf462088d13 343
markrad 0:cdf462088d13 344 /**
markrad 0:cdf462088d13 345 * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT)
markrad 0:cdf462088d13 346 *
markrad 0:cdf462088d13 347 * \param ctx RSA context
markrad 0:cdf462088d13 348 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 349 * \param p_rng RNG parameter
markrad 0:cdf462088d13 350 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 351 * \param olen will contain the plaintext length
markrad 0:cdf462088d13 352 * \param input buffer holding the encrypted data
markrad 0:cdf462088d13 353 * \param output buffer that will hold the plaintext
markrad 0:cdf462088d13 354 * \param output_max_len maximum length of the output buffer
markrad 0:cdf462088d13 355 *
markrad 0:cdf462088d13 356 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 357 *
markrad 0:cdf462088d13 358 * \note The output buffer must be as large as the size
markrad 0:cdf462088d13 359 * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
markrad 0:cdf462088d13 360 * an error is thrown.
markrad 0:cdf462088d13 361 */
markrad 0:cdf462088d13 362 int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 363 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 364 void *p_rng,
markrad 0:cdf462088d13 365 int mode, size_t *olen,
markrad 0:cdf462088d13 366 const unsigned char *input,
markrad 0:cdf462088d13 367 unsigned char *output,
markrad 0:cdf462088d13 368 size_t output_max_len );
markrad 0:cdf462088d13 369
markrad 0:cdf462088d13 370 /**
markrad 0:cdf462088d13 371 * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT)
markrad 0:cdf462088d13 372 *
markrad 0:cdf462088d13 373 * \param ctx RSA context
markrad 0:cdf462088d13 374 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 375 * \param p_rng RNG parameter
markrad 0:cdf462088d13 376 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 377 * \param label buffer holding the custom label to use
markrad 0:cdf462088d13 378 * \param label_len contains the label length
markrad 0:cdf462088d13 379 * \param olen will contain the plaintext length
markrad 0:cdf462088d13 380 * \param input buffer holding the encrypted data
markrad 0:cdf462088d13 381 * \param output buffer that will hold the plaintext
markrad 0:cdf462088d13 382 * \param output_max_len maximum length of the output buffer
markrad 0:cdf462088d13 383 *
markrad 0:cdf462088d13 384 * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 385 *
markrad 0:cdf462088d13 386 * \note The output buffer must be as large as the size
markrad 0:cdf462088d13 387 * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
markrad 0:cdf462088d13 388 * an error is thrown.
markrad 0:cdf462088d13 389 */
markrad 0:cdf462088d13 390 int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 391 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 392 void *p_rng,
markrad 0:cdf462088d13 393 int mode,
markrad 0:cdf462088d13 394 const unsigned char *label, size_t label_len,
markrad 0:cdf462088d13 395 size_t *olen,
markrad 0:cdf462088d13 396 const unsigned char *input,
markrad 0:cdf462088d13 397 unsigned char *output,
markrad 0:cdf462088d13 398 size_t output_max_len );
markrad 0:cdf462088d13 399
markrad 0:cdf462088d13 400 /**
markrad 0:cdf462088d13 401 * \brief Generic wrapper to perform a PKCS#1 signature using the
markrad 0:cdf462088d13 402 * mode from the context. Do a private RSA operation to sign
markrad 0:cdf462088d13 403 * a message digest
markrad 0:cdf462088d13 404 *
markrad 0:cdf462088d13 405 * \param ctx RSA context
markrad 0:cdf462088d13 406 * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
markrad 0:cdf462088d13 407 * MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 408 * \param p_rng RNG parameter
markrad 0:cdf462088d13 409 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 410 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 411 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 412 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 413 * \param sig buffer that will hold the ciphertext
markrad 0:cdf462088d13 414 *
markrad 0:cdf462088d13 415 * \return 0 if the signing operation was successful,
markrad 0:cdf462088d13 416 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 417 *
markrad 0:cdf462088d13 418 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 419 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 420 *
markrad 0:cdf462088d13 421 * \note In case of PKCS#1 v2.1 encoding, see comments on
markrad 0:cdf462088d13 422 * \note \c mbedtls_rsa_rsassa_pss_sign() for details on md_alg and hash_id.
markrad 0:cdf462088d13 423 */
markrad 0:cdf462088d13 424 int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 425 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 426 void *p_rng,
markrad 0:cdf462088d13 427 int mode,
markrad 0:cdf462088d13 428 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 429 unsigned int hashlen,
markrad 0:cdf462088d13 430 const unsigned char *hash,
markrad 0:cdf462088d13 431 unsigned char *sig );
markrad 0:cdf462088d13 432
markrad 0:cdf462088d13 433 /**
markrad 0:cdf462088d13 434 * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN)
markrad 0:cdf462088d13 435 *
markrad 0:cdf462088d13 436 * \param ctx RSA context
markrad 0:cdf462088d13 437 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 438 * \param p_rng RNG parameter
markrad 0:cdf462088d13 439 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 440 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 441 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 442 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 443 * \param sig buffer that will hold the ciphertext
markrad 0:cdf462088d13 444 *
markrad 0:cdf462088d13 445 * \return 0 if the signing operation was successful,
markrad 0:cdf462088d13 446 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 447 *
markrad 0:cdf462088d13 448 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 449 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 450 */
markrad 0:cdf462088d13 451 int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 452 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 453 void *p_rng,
markrad 0:cdf462088d13 454 int mode,
markrad 0:cdf462088d13 455 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 456 unsigned int hashlen,
markrad 0:cdf462088d13 457 const unsigned char *hash,
markrad 0:cdf462088d13 458 unsigned char *sig );
markrad 0:cdf462088d13 459
markrad 0:cdf462088d13 460 /**
markrad 0:cdf462088d13 461 * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN)
markrad 0:cdf462088d13 462 *
markrad 0:cdf462088d13 463 * \param ctx RSA context
markrad 0:cdf462088d13 464 * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
markrad 0:cdf462088d13 465 * MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 466 * \param p_rng RNG parameter
markrad 0:cdf462088d13 467 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 468 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 469 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 470 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 471 * \param sig buffer that will hold the ciphertext
markrad 0:cdf462088d13 472 *
markrad 0:cdf462088d13 473 * \return 0 if the signing operation was successful,
markrad 0:cdf462088d13 474 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 475 *
markrad 0:cdf462088d13 476 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 477 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 478 *
markrad 0:cdf462088d13 479 * \note The hash_id in the RSA context is the one used for the
markrad 0:cdf462088d13 480 * encoding. md_alg in the function call is the type of hash
markrad 0:cdf462088d13 481 * that is encoded. According to RFC 3447 it is advised to
markrad 0:cdf462088d13 482 * keep both hashes the same.
markrad 0:cdf462088d13 483 */
markrad 0:cdf462088d13 484 int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 485 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 486 void *p_rng,
markrad 0:cdf462088d13 487 int mode,
markrad 0:cdf462088d13 488 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 489 unsigned int hashlen,
markrad 0:cdf462088d13 490 const unsigned char *hash,
markrad 0:cdf462088d13 491 unsigned char *sig );
markrad 0:cdf462088d13 492
markrad 0:cdf462088d13 493 /**
markrad 0:cdf462088d13 494 * \brief Generic wrapper to perform a PKCS#1 verification using the
markrad 0:cdf462088d13 495 * mode from the context. Do a public RSA operation and check
markrad 0:cdf462088d13 496 * the message digest
markrad 0:cdf462088d13 497 *
markrad 0:cdf462088d13 498 * \param ctx points to an RSA public key
markrad 0:cdf462088d13 499 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 500 * \param p_rng RNG parameter
markrad 0:cdf462088d13 501 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 502 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 503 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 504 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 505 * \param sig buffer holding the ciphertext
markrad 0:cdf462088d13 506 *
markrad 0:cdf462088d13 507 * \return 0 if the verify operation was successful,
markrad 0:cdf462088d13 508 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 509 *
markrad 0:cdf462088d13 510 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 511 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 512 *
markrad 0:cdf462088d13 513 * \note In case of PKCS#1 v2.1 encoding, see comments on
markrad 0:cdf462088d13 514 * \c mbedtls_rsa_rsassa_pss_verify() about md_alg and hash_id.
markrad 0:cdf462088d13 515 */
markrad 0:cdf462088d13 516 int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 517 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 518 void *p_rng,
markrad 0:cdf462088d13 519 int mode,
markrad 0:cdf462088d13 520 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 521 unsigned int hashlen,
markrad 0:cdf462088d13 522 const unsigned char *hash,
markrad 0:cdf462088d13 523 const unsigned char *sig );
markrad 0:cdf462088d13 524
markrad 0:cdf462088d13 525 /**
markrad 0:cdf462088d13 526 * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY)
markrad 0:cdf462088d13 527 *
markrad 0:cdf462088d13 528 * \param ctx points to an RSA public key
markrad 0:cdf462088d13 529 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 530 * \param p_rng RNG parameter
markrad 0:cdf462088d13 531 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 532 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 533 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 534 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 535 * \param sig buffer holding the ciphertext
markrad 0:cdf462088d13 536 *
markrad 0:cdf462088d13 537 * \return 0 if the verify operation was successful,
markrad 0:cdf462088d13 538 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 539 *
markrad 0:cdf462088d13 540 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 541 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 542 */
markrad 0:cdf462088d13 543 int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 544 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 545 void *p_rng,
markrad 0:cdf462088d13 546 int mode,
markrad 0:cdf462088d13 547 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 548 unsigned int hashlen,
markrad 0:cdf462088d13 549 const unsigned char *hash,
markrad 0:cdf462088d13 550 const unsigned char *sig );
markrad 0:cdf462088d13 551
markrad 0:cdf462088d13 552 /**
markrad 0:cdf462088d13 553 * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
markrad 0:cdf462088d13 554 * (This is the "simple" version.)
markrad 0:cdf462088d13 555 *
markrad 0:cdf462088d13 556 * \param ctx points to an RSA public key
markrad 0:cdf462088d13 557 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 558 * \param p_rng RNG parameter
markrad 0:cdf462088d13 559 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 560 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 561 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 562 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 563 * \param sig buffer holding the ciphertext
markrad 0:cdf462088d13 564 *
markrad 0:cdf462088d13 565 * \return 0 if the verify operation was successful,
markrad 0:cdf462088d13 566 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 567 *
markrad 0:cdf462088d13 568 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 569 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 570 *
markrad 0:cdf462088d13 571 * \note The hash_id in the RSA context is the one used for the
markrad 0:cdf462088d13 572 * verification. md_alg in the function call is the type of
markrad 0:cdf462088d13 573 * hash that is verified. According to RFC 3447 it is advised to
markrad 0:cdf462088d13 574 * keep both hashes the same. If hash_id in the RSA context is
markrad 0:cdf462088d13 575 * unset, the md_alg from the function call is used.
markrad 0:cdf462088d13 576 */
markrad 0:cdf462088d13 577 int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 578 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 579 void *p_rng,
markrad 0:cdf462088d13 580 int mode,
markrad 0:cdf462088d13 581 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 582 unsigned int hashlen,
markrad 0:cdf462088d13 583 const unsigned char *hash,
markrad 0:cdf462088d13 584 const unsigned char *sig );
markrad 0:cdf462088d13 585
markrad 0:cdf462088d13 586 /**
markrad 0:cdf462088d13 587 * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
markrad 0:cdf462088d13 588 * (This is the version with "full" options.)
markrad 0:cdf462088d13 589 *
markrad 0:cdf462088d13 590 * \param ctx points to an RSA public key
markrad 0:cdf462088d13 591 * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
markrad 0:cdf462088d13 592 * \param p_rng RNG parameter
markrad 0:cdf462088d13 593 * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
markrad 0:cdf462088d13 594 * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
markrad 0:cdf462088d13 595 * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
markrad 0:cdf462088d13 596 * \param hash buffer holding the message digest
markrad 0:cdf462088d13 597 * \param mgf1_hash_id message digest used for mask generation
markrad 0:cdf462088d13 598 * \param expected_salt_len Length of the salt used in padding, use
markrad 0:cdf462088d13 599 * MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length
markrad 0:cdf462088d13 600 * \param sig buffer holding the ciphertext
markrad 0:cdf462088d13 601 *
markrad 0:cdf462088d13 602 * \return 0 if the verify operation was successful,
markrad 0:cdf462088d13 603 * or an MBEDTLS_ERR_RSA_XXX error code
markrad 0:cdf462088d13 604 *
markrad 0:cdf462088d13 605 * \note The "sig" buffer must be as large as the size
markrad 0:cdf462088d13 606 * of ctx->N (eg. 128 bytes if RSA-1024 is used).
markrad 0:cdf462088d13 607 *
markrad 0:cdf462088d13 608 * \note The hash_id in the RSA context is ignored.
markrad 0:cdf462088d13 609 */
markrad 0:cdf462088d13 610 int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
markrad 0:cdf462088d13 611 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 612 void *p_rng,
markrad 0:cdf462088d13 613 int mode,
markrad 0:cdf462088d13 614 mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 615 unsigned int hashlen,
markrad 0:cdf462088d13 616 const unsigned char *hash,
markrad 0:cdf462088d13 617 mbedtls_md_type_t mgf1_hash_id,
markrad 0:cdf462088d13 618 int expected_salt_len,
markrad 0:cdf462088d13 619 const unsigned char *sig );
markrad 0:cdf462088d13 620
markrad 0:cdf462088d13 621 /**
markrad 0:cdf462088d13 622 * \brief Copy the components of an RSA context
markrad 0:cdf462088d13 623 *
markrad 0:cdf462088d13 624 * \param dst Destination context
markrad 0:cdf462088d13 625 * \param src Source context
markrad 0:cdf462088d13 626 *
markrad 0:cdf462088d13 627 * \return 0 on success,
markrad 0:cdf462088d13 628 * MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure
markrad 0:cdf462088d13 629 */
markrad 0:cdf462088d13 630 int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src );
markrad 0:cdf462088d13 631
markrad 0:cdf462088d13 632 /**
markrad 0:cdf462088d13 633 * \brief Free the components of an RSA key
markrad 0:cdf462088d13 634 *
markrad 0:cdf462088d13 635 * \param ctx RSA Context to free
markrad 0:cdf462088d13 636 */
markrad 0:cdf462088d13 637 void mbedtls_rsa_free( mbedtls_rsa_context *ctx );
markrad 0:cdf462088d13 638
markrad 0:cdf462088d13 639 /**
markrad 0:cdf462088d13 640 * \brief Checkup routine
markrad 0:cdf462088d13 641 *
markrad 0:cdf462088d13 642 * \return 0 if successful, or 1 if the test failed
markrad 0:cdf462088d13 643 */
markrad 0:cdf462088d13 644 int mbedtls_rsa_self_test( int verbose );
markrad 0:cdf462088d13 645
markrad 0:cdf462088d13 646 #ifdef __cplusplus
markrad 0:cdf462088d13 647 }
markrad 0:cdf462088d13 648 #endif
markrad 0:cdf462088d13 649
markrad 0:cdf462088d13 650 #endif /* MBEDTLS_RSA_C */
markrad 0:cdf462088d13 651
markrad 0:cdf462088d13 652 #endif /* rsa.h */