Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wolfssl/wolfcrypt/rsa.h@15:117db924cf7c, 2018-08-18 (annotated)
- Committer:
- wolfSSL
- Date:
- Sat Aug 18 22:20:43 2018 +0000
- Revision:
- 15:117db924cf7c
wolfSSL 3.15.3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 15:117db924cf7c | 1 | /* rsa.h |
wolfSSL | 15:117db924cf7c | 2 | * |
wolfSSL | 15:117db924cf7c | 3 | * Copyright (C) 2006-2017 wolfSSL Inc. |
wolfSSL | 15:117db924cf7c | 4 | * |
wolfSSL | 15:117db924cf7c | 5 | * This file is part of wolfSSL. |
wolfSSL | 15:117db924cf7c | 6 | * |
wolfSSL | 15:117db924cf7c | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 15:117db924cf7c | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 15:117db924cf7c | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 15:117db924cf7c | 10 | * (at your option) any later version. |
wolfSSL | 15:117db924cf7c | 11 | * |
wolfSSL | 15:117db924cf7c | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 15:117db924cf7c | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 15:117db924cf7c | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 15:117db924cf7c | 15 | * GNU General Public License for more details. |
wolfSSL | 15:117db924cf7c | 16 | * |
wolfSSL | 15:117db924cf7c | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 15:117db924cf7c | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 15:117db924cf7c | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
wolfSSL | 15:117db924cf7c | 20 | */ |
wolfSSL | 15:117db924cf7c | 21 | |
wolfSSL | 15:117db924cf7c | 22 | /*! |
wolfSSL | 15:117db924cf7c | 23 | \file wolfssl/wolfcrypt/rsa.h |
wolfSSL | 15:117db924cf7c | 24 | */ |
wolfSSL | 15:117db924cf7c | 25 | |
wolfSSL | 15:117db924cf7c | 26 | |
wolfSSL | 15:117db924cf7c | 27 | #ifndef WOLF_CRYPT_RSA_H |
wolfSSL | 15:117db924cf7c | 28 | #define WOLF_CRYPT_RSA_H |
wolfSSL | 15:117db924cf7c | 29 | |
wolfSSL | 15:117db924cf7c | 30 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 15:117db924cf7c | 31 | |
wolfSSL | 15:117db924cf7c | 32 | #ifndef NO_RSA |
wolfSSL | 15:117db924cf7c | 33 | |
wolfSSL | 15:117db924cf7c | 34 | |
wolfSSL | 15:117db924cf7c | 35 | /* RSA default exponent */ |
wolfSSL | 15:117db924cf7c | 36 | #ifndef WC_RSA_EXPONENT |
wolfSSL | 15:117db924cf7c | 37 | #define WC_RSA_EXPONENT 65537L |
wolfSSL | 15:117db924cf7c | 38 | #endif |
wolfSSL | 15:117db924cf7c | 39 | |
wolfSSL | 15:117db924cf7c | 40 | |
wolfSSL | 15:117db924cf7c | 41 | /* allow for user to plug in own crypto */ |
wolfSSL | 15:117db924cf7c | 42 | #if !defined(HAVE_FIPS) && (defined(HAVE_USER_RSA) || defined(HAVE_FAST_RSA)) |
wolfSSL | 15:117db924cf7c | 43 | #include "user_rsa.h" |
wolfSSL | 15:117db924cf7c | 44 | #else |
wolfSSL | 15:117db924cf7c | 45 | |
wolfSSL | 15:117db924cf7c | 46 | #if defined(HAVE_FIPS) && \ |
wolfSSL | 15:117db924cf7c | 47 | (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) |
wolfSSL | 15:117db924cf7c | 48 | /* for fips @wc_fips */ |
wolfSSL | 15:117db924cf7c | 49 | #include <cyassl/ctaocrypt/rsa.h> |
wolfSSL | 15:117db924cf7c | 50 | #if defined(CYASSL_KEY_GEN) && !defined(WOLFSSL_KEY_GEN) |
wolfSSL | 15:117db924cf7c | 51 | #define WOLFSSL_KEY_GEN |
wolfSSL | 15:117db924cf7c | 52 | #endif |
wolfSSL | 15:117db924cf7c | 53 | #else |
wolfSSL | 15:117db924cf7c | 54 | #include <wolfssl/wolfcrypt/integer.h> |
wolfSSL | 15:117db924cf7c | 55 | #include <wolfssl/wolfcrypt/random.h> |
wolfSSL | 15:117db924cf7c | 56 | #endif /* HAVE_FIPS && HAVE_FIPS_VERION 1 */ |
wolfSSL | 15:117db924cf7c | 57 | #if defined(HAVE_FIPS) && \ |
wolfSSL | 15:117db924cf7c | 58 | defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) |
wolfSSL | 15:117db924cf7c | 59 | #include <wolfssl/wolfcrypt/fips.h> |
wolfSSL | 15:117db924cf7c | 60 | #endif |
wolfSSL | 15:117db924cf7c | 61 | |
wolfSSL | 15:117db924cf7c | 62 | /* header file needed for OAEP padding */ |
wolfSSL | 15:117db924cf7c | 63 | #include <wolfssl/wolfcrypt/hash.h> |
wolfSSL | 15:117db924cf7c | 64 | |
wolfSSL | 15:117db924cf7c | 65 | #ifdef WOLFSSL_XILINX_CRYPT |
wolfSSL | 15:117db924cf7c | 66 | #include "xsecure_rsa.h" |
wolfSSL | 15:117db924cf7c | 67 | #endif |
wolfSSL | 15:117db924cf7c | 68 | |
wolfSSL | 15:117db924cf7c | 69 | #ifdef __cplusplus |
wolfSSL | 15:117db924cf7c | 70 | extern "C" { |
wolfSSL | 15:117db924cf7c | 71 | #endif |
wolfSSL | 15:117db924cf7c | 72 | |
wolfSSL | 15:117db924cf7c | 73 | /* avoid redefinition of structs */ |
wolfSSL | 15:117db924cf7c | 74 | #if !defined(HAVE_FIPS) || \ |
wolfSSL | 15:117db924cf7c | 75 | (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) |
wolfSSL | 15:117db924cf7c | 76 | |
wolfSSL | 15:117db924cf7c | 77 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 15:117db924cf7c | 78 | #include <wolfssl/wolfcrypt/async.h> |
wolfSSL | 15:117db924cf7c | 79 | #ifdef WOLFSSL_CERT_GEN |
wolfSSL | 15:117db924cf7c | 80 | #include <wolfssl/wolfcrypt/asn.h> |
wolfSSL | 15:117db924cf7c | 81 | #endif |
wolfSSL | 15:117db924cf7c | 82 | #endif |
wolfSSL | 15:117db924cf7c | 83 | |
wolfSSL | 15:117db924cf7c | 84 | enum { |
wolfSSL | 15:117db924cf7c | 85 | RSA_PUBLIC = 0, |
wolfSSL | 15:117db924cf7c | 86 | RSA_PRIVATE = 1, |
wolfSSL | 15:117db924cf7c | 87 | |
wolfSSL | 15:117db924cf7c | 88 | RSA_TYPE_UNKNOWN = -1, |
wolfSSL | 15:117db924cf7c | 89 | RSA_PUBLIC_ENCRYPT = 0, |
wolfSSL | 15:117db924cf7c | 90 | RSA_PUBLIC_DECRYPT = 1, |
wolfSSL | 15:117db924cf7c | 91 | RSA_PRIVATE_ENCRYPT = 2, |
wolfSSL | 15:117db924cf7c | 92 | RSA_PRIVATE_DECRYPT = 3, |
wolfSSL | 15:117db924cf7c | 93 | |
wolfSSL | 15:117db924cf7c | 94 | RSA_BLOCK_TYPE_1 = 1, |
wolfSSL | 15:117db924cf7c | 95 | RSA_BLOCK_TYPE_2 = 2, |
wolfSSL | 15:117db924cf7c | 96 | |
wolfSSL | 15:117db924cf7c | 97 | RSA_MIN_SIZE = 512, |
wolfSSL | 15:117db924cf7c | 98 | RSA_MAX_SIZE = 4096, |
wolfSSL | 15:117db924cf7c | 99 | |
wolfSSL | 15:117db924cf7c | 100 | RSA_MIN_PAD_SZ = 11, /* separator + 0 + pad value + 8 pads */ |
wolfSSL | 15:117db924cf7c | 101 | |
wolfSSL | 15:117db924cf7c | 102 | RSA_PSS_PAD_SZ = 8, |
wolfSSL | 15:117db924cf7c | 103 | RSA_PSS_SALT_MAX_SZ = 62, |
wolfSSL | 15:117db924cf7c | 104 | |
wolfSSL | 15:117db924cf7c | 105 | #ifdef OPENSSL_EXTRA |
wolfSSL | 15:117db924cf7c | 106 | RSA_PKCS1_PADDING_SIZE = 11, |
wolfSSL | 15:117db924cf7c | 107 | RSA_PKCS1_OAEP_PADDING_SIZE = 42, /* (2 * hashlen(SHA-1)) + 2 */ |
wolfSSL | 15:117db924cf7c | 108 | #endif |
wolfSSL | 15:117db924cf7c | 109 | #ifdef WC_RSA_PSS |
wolfSSL | 15:117db924cf7c | 110 | RSA_PSS_PAD_TERM = 0xBC, |
wolfSSL | 15:117db924cf7c | 111 | #endif |
wolfSSL | 15:117db924cf7c | 112 | }; |
wolfSSL | 15:117db924cf7c | 113 | |
wolfSSL | 15:117db924cf7c | 114 | /* RSA */ |
wolfSSL | 15:117db924cf7c | 115 | struct RsaKey { |
wolfSSL | 15:117db924cf7c | 116 | mp_int n, e, d, p, q; |
wolfSSL | 15:117db924cf7c | 117 | #if defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA) || !defined(RSA_LOW_MEM) |
wolfSSL | 15:117db924cf7c | 118 | mp_int dP, dQ, u; |
wolfSSL | 15:117db924cf7c | 119 | #endif |
wolfSSL | 15:117db924cf7c | 120 | void* heap; /* for user memory overrides */ |
wolfSSL | 15:117db924cf7c | 121 | byte* data; /* temp buffer for async RSA */ |
wolfSSL | 15:117db924cf7c | 122 | int type; /* public or private */ |
wolfSSL | 15:117db924cf7c | 123 | int state; |
wolfSSL | 15:117db924cf7c | 124 | word32 dataLen; |
wolfSSL | 15:117db924cf7c | 125 | #ifdef WC_RSA_BLINDING |
wolfSSL | 15:117db924cf7c | 126 | WC_RNG* rng; /* for PrivateDecrypt blinding */ |
wolfSSL | 15:117db924cf7c | 127 | #endif |
wolfSSL | 15:117db924cf7c | 128 | #ifdef WOLF_CRYPTO_DEV |
wolfSSL | 15:117db924cf7c | 129 | int devId; |
wolfSSL | 15:117db924cf7c | 130 | #endif |
wolfSSL | 15:117db924cf7c | 131 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 15:117db924cf7c | 132 | WC_ASYNC_DEV asyncDev; |
wolfSSL | 15:117db924cf7c | 133 | #ifdef WOLFSSL_CERT_GEN |
wolfSSL | 15:117db924cf7c | 134 | CertSignCtx certSignCtx; /* context info for cert sign (MakeSignature) */ |
wolfSSL | 15:117db924cf7c | 135 | #endif |
wolfSSL | 15:117db924cf7c | 136 | #endif /* WOLFSSL_ASYNC_CRYPT */ |
wolfSSL | 15:117db924cf7c | 137 | #ifdef WOLFSSL_XILINX_CRYPT |
wolfSSL | 15:117db924cf7c | 138 | word32 pubExp; /* to keep values in scope they are here in struct */ |
wolfSSL | 15:117db924cf7c | 139 | byte* mod; |
wolfSSL | 15:117db924cf7c | 140 | XSecure_Rsa xRsa; |
wolfSSL | 15:117db924cf7c | 141 | #endif |
wolfSSL | 15:117db924cf7c | 142 | byte dataIsAlloc; |
wolfSSL | 15:117db924cf7c | 143 | }; |
wolfSSL | 15:117db924cf7c | 144 | |
wolfSSL | 15:117db924cf7c | 145 | #ifndef WC_RSAKEY_TYPE_DEFINED |
wolfSSL | 15:117db924cf7c | 146 | typedef struct RsaKey RsaKey; |
wolfSSL | 15:117db924cf7c | 147 | #define WC_RSAKEY_TYPE_DEFINED |
wolfSSL | 15:117db924cf7c | 148 | #endif |
wolfSSL | 15:117db924cf7c | 149 | |
wolfSSL | 15:117db924cf7c | 150 | #endif /*HAVE_FIPS */ |
wolfSSL | 15:117db924cf7c | 151 | |
wolfSSL | 15:117db924cf7c | 152 | WOLFSSL_API int wc_InitRsaKey(RsaKey* key, void* heap); |
wolfSSL | 15:117db924cf7c | 153 | WOLFSSL_API int wc_InitRsaKey_ex(RsaKey* key, void* heap, int devId); |
wolfSSL | 15:117db924cf7c | 154 | WOLFSSL_API int wc_FreeRsaKey(RsaKey* key); |
wolfSSL | 15:117db924cf7c | 155 | WOLFSSL_API int wc_CheckRsaKey(RsaKey* key); |
wolfSSL | 15:117db924cf7c | 156 | #ifdef WOLFSSL_XILINX_CRYPT |
wolfSSL | 15:117db924cf7c | 157 | WOLFSSL_LOCAL int wc_InitRsaHw(RsaKey* key); |
wolfSSL | 15:117db924cf7c | 158 | #endif /* WOLFSSL_XILINX_CRYPT */ |
wolfSSL | 15:117db924cf7c | 159 | |
wolfSSL | 15:117db924cf7c | 160 | WOLFSSL_API int wc_RsaFunction(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 161 | word32* outLen, int type, RsaKey* key, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 162 | |
wolfSSL | 15:117db924cf7c | 163 | WOLFSSL_API int wc_RsaPublicEncrypt(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 164 | word32 outLen, RsaKey* key, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 165 | WOLFSSL_API int wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, |
wolfSSL | 15:117db924cf7c | 166 | RsaKey* key); |
wolfSSL | 15:117db924cf7c | 167 | WOLFSSL_API int wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 168 | word32 outLen, RsaKey* key); |
wolfSSL | 15:117db924cf7c | 169 | WOLFSSL_API int wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 170 | word32 outLen, RsaKey* key, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 171 | WOLFSSL_API int wc_RsaPSS_Sign(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 172 | word32 outLen, enum wc_HashType hash, int mgf, |
wolfSSL | 15:117db924cf7c | 173 | RsaKey* key, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 174 | WOLFSSL_API int wc_RsaPSS_Sign_ex(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 175 | word32 outLen, enum wc_HashType hash, |
wolfSSL | 15:117db924cf7c | 176 | int mgf, int saltLen, RsaKey* key, |
wolfSSL | 15:117db924cf7c | 177 | WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 178 | WOLFSSL_API int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, |
wolfSSL | 15:117db924cf7c | 179 | RsaKey* key); |
wolfSSL | 15:117db924cf7c | 180 | WOLFSSL_API int wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 181 | word32 outLen, RsaKey* key); |
wolfSSL | 15:117db924cf7c | 182 | WOLFSSL_API int wc_RsaPSS_VerifyInline(byte* in, word32 inLen, byte** out, |
wolfSSL | 15:117db924cf7c | 183 | enum wc_HashType hash, int mgf, |
wolfSSL | 15:117db924cf7c | 184 | RsaKey* key); |
wolfSSL | 15:117db924cf7c | 185 | WOLFSSL_API int wc_RsaPSS_VerifyInline_ex(byte* in, word32 inLen, byte** out, |
wolfSSL | 15:117db924cf7c | 186 | enum wc_HashType hash, int mgf, |
wolfSSL | 15:117db924cf7c | 187 | int saltLen, RsaKey* key); |
wolfSSL | 15:117db924cf7c | 188 | WOLFSSL_API int wc_RsaPSS_Verify(byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 189 | word32 outLen, enum wc_HashType hash, int mgf, |
wolfSSL | 15:117db924cf7c | 190 | RsaKey* key); |
wolfSSL | 15:117db924cf7c | 191 | WOLFSSL_API int wc_RsaPSS_Verify_ex(byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 192 | word32 outLen, enum wc_HashType hash, |
wolfSSL | 15:117db924cf7c | 193 | int mgf, int saltLen, RsaKey* key); |
wolfSSL | 15:117db924cf7c | 194 | WOLFSSL_API int wc_RsaPSS_CheckPadding(const byte* in, word32 inLen, byte* sig, |
wolfSSL | 15:117db924cf7c | 195 | word32 sigSz, |
wolfSSL | 15:117db924cf7c | 196 | enum wc_HashType hashType); |
wolfSSL | 15:117db924cf7c | 197 | WOLFSSL_API int wc_RsaPSS_CheckPadding_ex(const byte* in, word32 inLen, |
wolfSSL | 15:117db924cf7c | 198 | byte* sig, word32 sigSz, |
wolfSSL | 15:117db924cf7c | 199 | enum wc_HashType hashType, |
wolfSSL | 15:117db924cf7c | 200 | int saltLen, int bits); |
wolfSSL | 15:117db924cf7c | 201 | WOLFSSL_API int wc_RsaPSS_VerifyCheckInline(byte* in, word32 inLen, byte** out, |
wolfSSL | 15:117db924cf7c | 202 | const byte* digest, word32 digentLen, |
wolfSSL | 15:117db924cf7c | 203 | enum wc_HashType hash, int mgf, |
wolfSSL | 15:117db924cf7c | 204 | RsaKey* key); |
wolfSSL | 15:117db924cf7c | 205 | WOLFSSL_API int wc_RsaPSS_VerifyCheck(byte* in, word32 inLen, |
wolfSSL | 15:117db924cf7c | 206 | byte* out, word32 outLen, |
wolfSSL | 15:117db924cf7c | 207 | const byte* digest, word32 digestLen, |
wolfSSL | 15:117db924cf7c | 208 | enum wc_HashType hash, int mgf, |
wolfSSL | 15:117db924cf7c | 209 | RsaKey* key); |
wolfSSL | 15:117db924cf7c | 210 | |
wolfSSL | 15:117db924cf7c | 211 | WOLFSSL_API int wc_RsaEncryptSize(RsaKey* key); |
wolfSSL | 15:117db924cf7c | 212 | |
wolfSSL | 15:117db924cf7c | 213 | #if !defined(HAVE_FIPS) || \ |
wolfSSL | 15:117db924cf7c | 214 | (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) |
wolfSSL | 15:117db924cf7c | 215 | /* to avoid asn duplicate symbols @wc_fips */ |
wolfSSL | 15:117db924cf7c | 216 | WOLFSSL_API int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, |
wolfSSL | 15:117db924cf7c | 217 | RsaKey*, word32); |
wolfSSL | 15:117db924cf7c | 218 | WOLFSSL_API int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, |
wolfSSL | 15:117db924cf7c | 219 | RsaKey*, word32); |
wolfSSL | 15:117db924cf7c | 220 | WOLFSSL_API int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, |
wolfSSL | 15:117db924cf7c | 221 | const byte* e, word32 eSz, RsaKey* key); |
wolfSSL | 15:117db924cf7c | 222 | #ifdef WOLFSSL_KEY_GEN |
wolfSSL | 15:117db924cf7c | 223 | WOLFSSL_API int wc_RsaKeyToDer(RsaKey*, byte* output, word32 inLen); |
wolfSSL | 15:117db924cf7c | 224 | #endif |
wolfSSL | 15:117db924cf7c | 225 | |
wolfSSL | 15:117db924cf7c | 226 | WOLFSSL_API int wc_RsaSetRNG(RsaKey* key, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 227 | |
wolfSSL | 15:117db924cf7c | 228 | /* |
wolfSSL | 15:117db924cf7c | 229 | choice of padding added after fips, so not available when using fips RSA |
wolfSSL | 15:117db924cf7c | 230 | */ |
wolfSSL | 15:117db924cf7c | 231 | |
wolfSSL | 15:117db924cf7c | 232 | /* Mask Generation Function Identifiers */ |
wolfSSL | 15:117db924cf7c | 233 | #define WC_MGF1NONE 0 |
wolfSSL | 15:117db924cf7c | 234 | #define WC_MGF1SHA1 26 |
wolfSSL | 15:117db924cf7c | 235 | #define WC_MGF1SHA224 4 |
wolfSSL | 15:117db924cf7c | 236 | #define WC_MGF1SHA256 1 |
wolfSSL | 15:117db924cf7c | 237 | #define WC_MGF1SHA384 2 |
wolfSSL | 15:117db924cf7c | 238 | #define WC_MGF1SHA512 3 |
wolfSSL | 15:117db924cf7c | 239 | |
wolfSSL | 15:117db924cf7c | 240 | /* Padding types */ |
wolfSSL | 15:117db924cf7c | 241 | #define WC_RSA_PKCSV15_PAD 0 |
wolfSSL | 15:117db924cf7c | 242 | #define WC_RSA_OAEP_PAD 1 |
wolfSSL | 15:117db924cf7c | 243 | #define WC_RSA_PSS_PAD 2 |
wolfSSL | 15:117db924cf7c | 244 | #define WC_RSA_NO_PAD 3 |
wolfSSL | 15:117db924cf7c | 245 | |
wolfSSL | 15:117db924cf7c | 246 | WOLFSSL_API int wc_RsaPublicEncrypt_ex(const byte* in, word32 inLen, byte* out, |
wolfSSL | 15:117db924cf7c | 247 | word32 outLen, RsaKey* key, WC_RNG* rng, int type, |
wolfSSL | 15:117db924cf7c | 248 | enum wc_HashType hash, int mgf, byte* label, word32 lableSz); |
wolfSSL | 15:117db924cf7c | 249 | WOLFSSL_API int wc_RsaPrivateDecrypt_ex(const byte* in, word32 inLen, |
wolfSSL | 15:117db924cf7c | 250 | byte* out, word32 outLen, RsaKey* key, int type, |
wolfSSL | 15:117db924cf7c | 251 | enum wc_HashType hash, int mgf, byte* label, word32 lableSz); |
wolfSSL | 15:117db924cf7c | 252 | WOLFSSL_API int wc_RsaPrivateDecryptInline_ex(byte* in, word32 inLen, |
wolfSSL | 15:117db924cf7c | 253 | byte** out, RsaKey* key, int type, enum wc_HashType hash, |
wolfSSL | 15:117db924cf7c | 254 | int mgf, byte* label, word32 lableSz); |
wolfSSL | 15:117db924cf7c | 255 | #if defined(WC_RSA_DIRECT) || defined(WC_RSA_NO_PADDING) |
wolfSSL | 15:117db924cf7c | 256 | WOLFSSL_API int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz, |
wolfSSL | 15:117db924cf7c | 257 | RsaKey* key, int type, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 258 | #endif |
wolfSSL | 15:117db924cf7c | 259 | |
wolfSSL | 15:117db924cf7c | 260 | #endif /* HAVE_FIPS*/ |
wolfSSL | 15:117db924cf7c | 261 | |
wolfSSL | 15:117db924cf7c | 262 | WOLFSSL_API int wc_RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*, |
wolfSSL | 15:117db924cf7c | 263 | word32*); |
wolfSSL | 15:117db924cf7c | 264 | WOLFSSL_API int wc_RsaExportKey(RsaKey* key, |
wolfSSL | 15:117db924cf7c | 265 | byte* e, word32* eSz, |
wolfSSL | 15:117db924cf7c | 266 | byte* n, word32* nSz, |
wolfSSL | 15:117db924cf7c | 267 | byte* d, word32* dSz, |
wolfSSL | 15:117db924cf7c | 268 | byte* p, word32* pSz, |
wolfSSL | 15:117db924cf7c | 269 | byte* q, word32* qSz); |
wolfSSL | 15:117db924cf7c | 270 | |
wolfSSL | 15:117db924cf7c | 271 | WOLFSSL_API int wc_RsaKeyToPublicDer(RsaKey*, byte* output, word32 inLen); |
wolfSSL | 15:117db924cf7c | 272 | |
wolfSSL | 15:117db924cf7c | 273 | #ifdef WOLFSSL_KEY_GEN |
wolfSSL | 15:117db924cf7c | 274 | WOLFSSL_API int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng); |
wolfSSL | 15:117db924cf7c | 275 | WOLFSSL_API int wc_CheckProbablePrime(const byte* p, word32 pSz, |
wolfSSL | 15:117db924cf7c | 276 | const byte* q, word32 qSz, |
wolfSSL | 15:117db924cf7c | 277 | const byte* e, word32 eSz, |
wolfSSL | 15:117db924cf7c | 278 | int nlen, int* isPrime); |
wolfSSL | 15:117db924cf7c | 279 | #endif |
wolfSSL | 15:117db924cf7c | 280 | |
wolfSSL | 15:117db924cf7c | 281 | #endif /* HAVE_USER_RSA */ |
wolfSSL | 15:117db924cf7c | 282 | |
wolfSSL | 15:117db924cf7c | 283 | #ifdef __cplusplus |
wolfSSL | 15:117db924cf7c | 284 | } /* extern "C" */ |
wolfSSL | 15:117db924cf7c | 285 | #endif |
wolfSSL | 15:117db924cf7c | 286 | |
wolfSSL | 15:117db924cf7c | 287 | #endif /* NO_RSA */ |
wolfSSL | 15:117db924cf7c | 288 | #endif /* WOLF_CRYPT_RSA_H */ |
wolfSSL | 15:117db924cf7c | 289 | |
wolfSSL | 15:117db924cf7c | 290 |