| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #include <openssl/base.h> |
| 16 |
| 17 | #include <limits.h> |
| 18 |
| 19 | #include <openssl/bn.h> |
| 20 | #include <openssl/err.h> |
| 21 | #include <openssl/evp.h> |
| 22 | #include <openssl/mem.h> |
| 23 | #include <openssl/rand.h> |
| 24 | #include <openssl/rsa.h> |
| 25 |
| 26 | #include "../fipsmodule/bn/internal.h" |
| 27 | #include "../fipsmodule/rsa/internal.h" |
| 28 | #include "../internal.h" |
| 29 | #include "internal.h" |
| 30 |
| 31 |
| 32 | static void rand_nonzero(uint8_t *out, size_t len) { |
| 33 | RAND_bytes(out, len); |
| 34 |
| 35 | for (size_t i = 0; i < len; i++) { |
| 36 | // Zero values are replaced, and the distribution of zero and non-zero bytes |
| 37 | // is public, so leaking this is safe. |
| 38 | while (constant_time_declassify_int(out[i] == 0)) { |
| 39 | RAND_bytes(out + i, 1); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 |
| 44 | int RSA_padding_add_PKCS1_OAEP_mgf1(uint8_t *to, size_t to_len, |
| 45 | const uint8_t *from, size_t from_len, |
| 46 | const uint8_t *param, size_t param_len, |
| 47 | const EVP_MD *md, const EVP_MD *mgf1md) { |
| 48 | if (md == NULL) { |
| 49 | md = EVP_sha1(); |
| 50 | } |
| 51 | if (mgf1md == NULL) { |
| 52 | mgf1md = md; |
| 53 | } |
| 54 |
| 55 | size_t mdlen = EVP_MD_size(md); |
| 56 |
| 57 | if (to_len < 2 * mdlen + 2) { |
| 58 | OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL); |
| 59 | return 0; |
| 60 | } |
| 61 |
| 62 | size_t emlen = to_len - 1; |
| 63 | if (from_len > emlen - 2 * mdlen - 1) { |
| 64 | OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); |
| 65 | return 0; |
| 66 | } |
| 67 |
| 68 | if (emlen < 2 * mdlen + 1) { |
| 69 | OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL); |
| 70 | return 0; |
| 71 | } |
| 72 |
| 73 | to[0] = 0; |
| 74 | uint8_t *seed = to + 1; |
| 75 | uint8_t *db = to + mdlen + 1; |
| 76 |
| 77 | uint8_t *dbmask = NULL; |
| 78 | int ret = 0; |
| 79 | if (!EVP_Digest(param, param_len, db, NULL, md, NULL)) { |
| 80 | goto out; |
| 81 | } |
| 82 | OPENSSL_memset(db + mdlen, 0, emlen - from_len - 2 * mdlen - 1); |
| 83 | db[emlen - from_len - mdlen - 1] = 0x01; |
| 84 | OPENSSL_memcpy(db + emlen - from_len - mdlen, from, from_len); |
| 85 | if (!RAND_bytes(seed, mdlen)) { |
| 86 | goto out; |
| 87 | } |
| 88 |
| 89 | dbmask = reinterpret_cast<uint8_t *>(OPENSSL_malloc(emlen - mdlen)); |
| 90 | if (dbmask == NULL) { |
| 91 | goto out; |
| 92 | } |
| 93 |
| 94 | if (!PKCS1_MGF1(dbmask, emlen - mdlen, seed, mdlen, mgf1md)) { |
| 95 | goto out; |
| 96 | } |
| 97 | for (size_t i = 0; i < emlen - mdlen; i++) { |
| 98 | db[i] ^= dbmask[i]; |
| 99 | } |
| 100 |
| 101 | uint8_t seedmask[EVP_MAX_MD_SIZE]; |
| 102 | if (!PKCS1_MGF1(seedmask, mdlen, db, emlen - mdlen, mgf1md)) { |
| 103 | goto out; |
| 104 | } |
| 105 | for (size_t i = 0; i < mdlen; i++) { |
| 106 | seed[i] ^= seedmask[i]; |
| 107 | } |
| 108 | ret = 1; |
| 109 |
| 110 | out: |
| 111 | OPENSSL_free(dbmask); |
| 112 | return ret; |
| 113 | } |
| 114 |
| 115 | int RSA_padding_check_PKCS1_OAEP_mgf1(uint8_t *out, size_t *out_len, |
| 116 | size_t max_out, const uint8_t *from, |
| 117 | size_t from_len, const uint8_t *param, |
| 118 | size_t param_len, const EVP_MD *md, |
| 119 | const EVP_MD *mgf1md) { |
| 120 | uint8_t *db = NULL; |
| 121 |
| 122 | { |
| 123 | if (md == NULL) { |
| 124 | md = EVP_sha1(); |
| 125 | } |
| 126 | if (mgf1md == NULL) { |
| 127 | mgf1md = md; |
| 128 | } |
| 129 |
| 130 | size_t mdlen = EVP_MD_size(md); |
| 131 |
| 132 | // The encoded message is one byte smaller than the modulus to ensure that |
| 133 | // it doesn't end up greater than the modulus. Thus there's an extra "+1" |
| 134 | // here compared to https://tools.ietf.org/html/rfc2437#section-9.1.1.2. |
| 135 | if (from_len < 1 + 2 * mdlen + 1) { |
| 136 | // 'from_len' is the length of the modulus, i.e. does not depend on the |
| 137 | // particular ciphertext. |
| 138 | goto decoding_err; |
| 139 | } |
| 140 |
| 141 | size_t dblen = from_len - mdlen - 1; |
| 142 | db = reinterpret_cast<uint8_t *>(OPENSSL_malloc(dblen)); |
| 143 | if (db == NULL) { |
| 144 | goto err; |
| 145 | } |
| 146 |
| 147 | const uint8_t *maskedseed = from + 1; |
| 148 | const uint8_t *maskeddb = from + 1 + mdlen; |
| 149 |
| 150 | uint8_t seed[EVP_MAX_MD_SIZE]; |
| 151 | if (!PKCS1_MGF1(seed, mdlen, maskeddb, dblen, mgf1md)) { |
| 152 | goto err; |
| 153 | } |
| 154 | for (size_t i = 0; i < mdlen; i++) { |
| 155 | seed[i] ^= maskedseed[i]; |
| 156 | } |
| 157 |
| 158 | if (!PKCS1_MGF1(db, dblen, seed, mdlen, mgf1md)) { |
| 159 | goto err; |
| 160 | } |
| 161 | for (size_t i = 0; i < dblen; i++) { |
| 162 | db[i] ^= maskeddb[i]; |
| 163 | } |
| 164 |
| 165 | uint8_t phash[EVP_MAX_MD_SIZE]; |
| 166 | if (!EVP_Digest(param, param_len, phash, NULL, md, NULL)) { |
| 167 | goto err; |
| 168 | } |
| 169 |
| 170 | crypto_word_t bad = |
| 171 | ~constant_time_is_zero_w(CRYPTO_memcmp(db, phash, mdlen)); |
| 172 | bad |= ~constant_time_is_zero_w(from[0]); |
| 173 |
| 174 | crypto_word_t looking_for_one_byte = CONSTTIME_TRUE_W; |
| 175 | size_t one_index = 0; |
| 176 | for (size_t i = mdlen; i < dblen; i++) { |
| 177 | crypto_word_t equals1 = constant_time_eq_w(db[i], 1); |
| 178 | crypto_word_t equals0 = constant_time_eq_w(db[i], 0); |
| 179 | one_index = |
| 180 | constant_time_select_w(looking_for_one_byte & equals1, i, one_index); |
| 181 | looking_for_one_byte = |
| 182 | constant_time_select_w(equals1, 0, looking_for_one_byte); |
| 183 | bad |= looking_for_one_byte & ~equals0; |
| 184 | } |
| 185 |
| 186 | bad |= looking_for_one_byte; |
| 187 |
| 188 | // Whether the overall padding was valid or not in OAEP is public. |
| 189 | if (constant_time_declassify_w(bad)) { |
| 190 | goto decoding_err; |
| 191 | } |
| 192 |
| 193 | // Once the padding is known to be valid, the output length is also public. |
| 194 | static_assert(sizeof(size_t) <= sizeof(crypto_word_t), |
| 195 | "size_t does not fit in crypto_word_t"); |
| 196 | one_index = constant_time_declassify_w(one_index); |
| 197 |
| 198 | one_index++; |
| 199 | size_t mlen = dblen - one_index; |
| 200 | if (max_out < mlen) { |
| 201 | OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_TOO_LARGE); |
| 202 | goto err; |
| 203 | } |
| 204 |
| 205 | OPENSSL_memcpy(out, db + one_index, mlen); |
| 206 | *out_len = mlen; |
| 207 | OPENSSL_free(db); |
| 208 | return 1; |
| 209 | } |
| 210 |
| 211 | decoding_err: |
| 212 | // To avoid chosen ciphertext attacks, the error message should not reveal |
| 213 | // which kind of decoding error happened. |
| 214 | OPENSSL_PUT_ERROR(RSA, RSA_R_OAEP_DECODING_ERROR); |
| 215 | err: |
| 216 | OPENSSL_free(db); |
| 217 | return 0; |
| 218 | } |
| 219 |
| 220 | static int rsa_padding_add_PKCS1_type_2(uint8_t *to, size_t to_len, |
| 221 | const uint8_t *from, size_t from_len) { |
| 222 | // See RFC 8017, section 7.2.1. |
| 223 | if (to_len < RSA_PKCS1_PADDING_SIZE) { |
| 224 | OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL); |
| 225 | return 0; |
| 226 | } |
| 227 |
| 228 | if (from_len > to_len - RSA_PKCS1_PADDING_SIZE) { |
| 229 | OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); |
| 230 | return 0; |
| 231 | } |
| 232 |
| 233 | to[0] = 0; |
| 234 | to[1] = 2; |
| 235 |
| 236 | size_t padding_len = to_len - 3 - from_len; |
| 237 | rand_nonzero(to + 2, padding_len); |
| 238 | to[2 + padding_len] = 0; |
| 239 | OPENSSL_memcpy(to + to_len - from_len, from, from_len); |
| 240 | return 1; |
| 241 | } |
| 242 |
| 243 | static int rsa_padding_check_PKCS1_type_2(uint8_t *out, size_t *out_len, |
| 244 | size_t max_out, const uint8_t *from, |
| 245 | size_t from_len) { |
| 246 | if (from_len == 0) { |
| 247 | OPENSSL_PUT_ERROR(RSA, RSA_R_EMPTY_PUBLIC_KEY); |
| 248 | return 0; |
| 249 | } |
| 250 |
| 251 | // PKCS#1 v1.5 decryption. See "PKCS #1 v2.2: RSA Cryptography |
| 252 | // Standard", section 7.2.2. |
| 253 | if (from_len < RSA_PKCS1_PADDING_SIZE) { |
| 254 | // |from| is zero-padded to the size of the RSA modulus, a public value, so |
| 255 | // this can be rejected in non-constant time. |
| 256 | OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL); |
| 257 | return 0; |
| 258 | } |
| 259 |
| 260 | crypto_word_t first_byte_is_zero = constant_time_eq_w(from[0], 0); |
| 261 | crypto_word_t second_byte_is_two = constant_time_eq_w(from[1], 2); |
| 262 |
| 263 | crypto_word_t zero_index = 0, looking_for_index = CONSTTIME_TRUE_W; |
| 264 | for (size_t i = 2; i < from_len; i++) { |
| 265 | crypto_word_t equals0 = constant_time_is_zero_w(from[i]); |
| 266 | zero_index = |
| 267 | constant_time_select_w(looking_for_index & equals0, i, zero_index); |
| 268 | looking_for_index = constant_time_select_w(equals0, 0, looking_for_index); |
| 269 | } |
| 270 |
| 271 | // The input must begin with 00 02. |
| 272 | crypto_word_t valid_index = first_byte_is_zero; |
| 273 | valid_index &= second_byte_is_two; |
| 274 |
| 275 | // We must have found the end of PS. |
| 276 | valid_index &= ~looking_for_index; |
| 277 |
| 278 | // PS must be at least 8 bytes long, and it starts two bytes into |from|. |
| 279 | valid_index &= constant_time_ge_w(zero_index, 2 + 8); |
| 280 |
| 281 | // Skip the zero byte. |
| 282 | zero_index++; |
| 283 |
| 284 | // NOTE: Although this logic attempts to be constant time, the API contracts |
| 285 | // of this function and |RSA_decrypt| with |RSA_PKCS1_PADDING| make it |
| 286 | // impossible to completely avoid Bleichenbacher's attack. Consumers should |
| 287 | // use |RSA_PADDING_NONE| and perform the padding check in constant-time |
| 288 | // combined with a swap to a random session key or other mitigation. |
| 289 | CONSTTIME_DECLASSIFY(&valid_index, sizeof(valid_index)); |
| 290 | CONSTTIME_DECLASSIFY(&zero_index, sizeof(zero_index)); |
| 291 |
| 292 | if (!valid_index) { |
| 293 | OPENSSL_PUT_ERROR(RSA, RSA_R_PKCS_DECODING_ERROR); |
| 294 | return 0; |
| 295 | } |
| 296 |
| 297 | const size_t msg_len = from_len - zero_index; |
| 298 | if (msg_len > max_out) { |
| 299 | // This shouldn't happen because this function is always called with |
| 300 | // |max_out| as the key size and |from_len| is bounded by the key size. |
| 301 | OPENSSL_PUT_ERROR(RSA, RSA_R_PKCS_DECODING_ERROR); |
| 302 | return 0; |
| 303 | } |
| 304 |
| 305 | OPENSSL_memcpy(out, &from[zero_index], msg_len); |
| 306 | *out_len = msg_len; |
| 307 | return 1; |
| 308 | } |
| 309 |
| 310 | int RSA_public_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, |
| 311 | int padding) { |
| 312 | size_t out_len; |
| 313 |
| 314 | if (!RSA_encrypt(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { |
| 315 | return -1; |
| 316 | } |
| 317 |
| 318 | if (out_len > INT_MAX) { |
| 319 | OPENSSL_PUT_ERROR(RSA, ERR_R_OVERFLOW); |
| 320 | return -1; |
| 321 | } |
| 322 | return (int)out_len; |
| 323 | } |
| 324 |
| 325 | int RSA_private_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, |
| 326 | int padding) { |
| 327 | size_t out_len; |
| 328 |
| 329 | if (!RSA_sign_raw(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { |
| 330 | return -1; |
| 331 | } |
| 332 |
| 333 | if (out_len > INT_MAX) { |
| 334 | OPENSSL_PUT_ERROR(RSA, ERR_R_OVERFLOW); |
| 335 | return -1; |
| 336 | } |
| 337 | return (int)out_len; |
| 338 | } |
| 339 |
| 340 | int RSA_encrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, |
| 341 | const uint8_t *in, size_t in_len, int padding) { |
| 342 | if (rsa->n == NULL || rsa->e == NULL) { |
| 343 | OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); |
| 344 | return 0; |
| 345 | } |
| 346 |
| 347 | if (!rsa_check_public_key(rsa)) { |
| 348 | return 0; |
| 349 | } |
| 350 |
| 351 | const unsigned rsa_size = RSA_size(rsa); |
| 352 | BIGNUM *f, *result; |
| 353 | uint8_t *buf = NULL; |
| 354 | BN_CTX *ctx = NULL; |
| 355 | int i, ret = 0; |
| 356 |
| 357 | if (max_out < rsa_size) { |
| 358 | OPENSSL_PUT_ERROR(RSA, RSA_R_OUTPUT_BUFFER_TOO_SMALL); |
| 359 | return 0; |
| 360 | } |
| 361 |
| 362 | ctx = BN_CTX_new(); |
| 363 | if (ctx == NULL) { |
| 364 | goto err; |
| 365 | } |
| 366 |
| 367 | BN_CTX_start(ctx); |
| 368 | f = BN_CTX_get(ctx); |
| 369 | result = BN_CTX_get(ctx); |
| 370 | buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(rsa_size)); |
| 371 | if (!f || !result || !buf) { |
| 372 | goto err; |
| 373 | } |
| 374 |
| 375 | switch (padding) { |
| 376 | case RSA_PKCS1_PADDING: |
| 377 | i = rsa_padding_add_PKCS1_type_2(buf, rsa_size, in, in_len); |
| 378 | break; |
| 379 | case RSA_PKCS1_OAEP_PADDING: |
| 380 | // Use the default parameters: SHA-1 for both hashes and no label. |
| 381 | i = RSA_padding_add_PKCS1_OAEP_mgf1(buf, rsa_size, in, in_len, NULL, 0, |
| 382 | NULL, NULL); |
| 383 | break; |
| 384 | case RSA_NO_PADDING: |
| 385 | i = RSA_padding_add_none(buf, rsa_size, in, in_len); |
| 386 | break; |
| 387 | default: |
| 388 | OPENSSL_PUT_ERROR(RSA, RSA_R_UNKNOWN_PADDING_TYPE); |
| 389 | goto err; |
| 390 | } |
| 391 |
| 392 | if (i <= 0) { |
| 393 | goto err; |
| 394 | } |
| 395 |
| 396 | if (BN_bin2bn(buf, rsa_size, f) == NULL) { |
| 397 | goto err; |
| 398 | } |
| 399 |
| 400 | if (BN_ucmp(f, rsa->n) >= 0) { |
| 401 | // usually the padding functions would catch this |
| 402 | OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_TOO_LARGE_FOR_MODULUS); |
| 403 | goto err; |
| 404 | } |
| 405 |
| 406 | if (!BN_MONT_CTX_set_locked(&rsa->mont_n, &rsa->lock, rsa->n, ctx) || |
| 407 | !BN_mod_exp_mont(result, f, rsa->e, &rsa->mont_n->N, ctx, rsa->mont_n)) { |
| 408 | goto err; |
| 409 | } |
| 410 |
| 411 | // put in leading 0 bytes if the number is less than the length of the |
| 412 | // modulus |
| 413 | if (!BN_bn2bin_padded(out, rsa_size, result)) { |
| 414 | OPENSSL_PUT_ERROR(RSA, ERR_R_INTERNAL_ERROR); |
| 415 | goto err; |
| 416 | } |
| 417 |
| 418 | *out_len = rsa_size; |
| 419 | ret = 1; |
| 420 |
| 421 | err: |
| 422 | if (ctx != NULL) { |
| 423 | BN_CTX_end(ctx); |
| 424 | BN_CTX_free(ctx); |
| 425 | } |
| 426 | OPENSSL_free(buf); |
| 427 |
| 428 | return ret; |
| 429 | } |
| 430 |
| 431 | static int rsa_default_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, |
| 432 | size_t max_out, const uint8_t *in, size_t in_len, |
| 433 | int padding) { |
| 434 | const unsigned rsa_size = RSA_size(rsa); |
| 435 | uint8_t *buf = NULL; |
| 436 | int ret = 0; |
| 437 |
| 438 | if (max_out < rsa_size) { |
| 439 | OPENSSL_PUT_ERROR(RSA, RSA_R_OUTPUT_BUFFER_TOO_SMALL); |
| 440 | return 0; |
| 441 | } |
| 442 |
| 443 | if (padding == RSA_NO_PADDING) { |
| 444 | buf = out; |
| 445 | } else { |
| 446 | // Allocate a temporary buffer to hold the padded plaintext. |
| 447 | buf = reinterpret_cast<uint8_t *>(OPENSSL_malloc(rsa_size)); |
| 448 | if (buf == NULL) { |
| 449 | goto err; |
| 450 | } |
| 451 | } |
| 452 |
| 453 | if (in_len != rsa_size) { |
| 454 | OPENSSL_PUT_ERROR(RSA, RSA_R_DATA_LEN_NOT_EQUAL_TO_MOD_LEN); |
| 455 | goto err; |
| 456 | } |
| 457 |
| 458 | if (!rsa_private_transform(rsa, buf, in, rsa_size)) { |
| 459 | goto err; |
| 460 | } |
| 461 |
| 462 | switch (padding) { |
| 463 | case RSA_PKCS1_PADDING: |
| 464 | ret = |
| 465 | rsa_padding_check_PKCS1_type_2(out, out_len, rsa_size, buf, rsa_size); |
| 466 | break; |
| 467 | case RSA_PKCS1_OAEP_PADDING: |
| 468 | // Use the default parameters: SHA-1 for both hashes and no label. |
| 469 | ret = RSA_padding_check_PKCS1_OAEP_mgf1(out, out_len, rsa_size, buf, |
| 470 | rsa_size, NULL, 0, NULL, NULL); |
| 471 | break; |
| 472 | case RSA_NO_PADDING: |
| 473 | *out_len = rsa_size; |
| 474 | ret = 1; |
| 475 | break; |
| 476 | default: |
| 477 | OPENSSL_PUT_ERROR(RSA, RSA_R_UNKNOWN_PADDING_TYPE); |
| 478 | goto err; |
| 479 | } |
| 480 |
| 481 | CONSTTIME_DECLASSIFY(&ret, sizeof(ret)); |
| 482 | if (!ret) { |
| 483 | OPENSSL_PUT_ERROR(RSA, RSA_R_PADDING_CHECK_FAILED); |
| 484 | } else { |
| 485 | CONSTTIME_DECLASSIFY(out, *out_len); |
| 486 | } |
| 487 |
| 488 | err: |
| 489 | if (padding != RSA_NO_PADDING) { |
| 490 | OPENSSL_free(buf); |
| 491 | } |
| 492 |
| 493 | return ret; |
| 494 | } |
| 495 |
| 496 | int RSA_decrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, |
| 497 | const uint8_t *in, size_t in_len, int padding) { |
| 498 | if (rsa->meth->decrypt) { |
| 499 | return rsa->meth->decrypt(rsa, out_len, out, max_out, in, in_len, padding); |
| 500 | } |
| 501 |
| 502 | return rsa_default_decrypt(rsa, out_len, out, max_out, in, in_len, padding); |
| 503 | } |
| 504 |
| 505 | int RSA_private_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, |
| 506 | int padding) { |
| 507 | size_t out_len; |
| 508 | if (!RSA_decrypt(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { |
| 509 | return -1; |
| 510 | } |
| 511 |
| 512 | if (out_len > INT_MAX) { |
| 513 | OPENSSL_PUT_ERROR(RSA, ERR_R_OVERFLOW); |
| 514 | return -1; |
| 515 | } |
| 516 | return (int)out_len; |
| 517 | } |
| 518 |
| 519 | int RSA_public_decrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, |
| 520 | int padding) { |
| 521 | size_t out_len; |
| 522 | if (!RSA_verify_raw(rsa, &out_len, to, RSA_size(rsa), from, flen, padding)) { |
| 523 | return -1; |
| 524 | } |
| 525 |
| 526 | if (out_len > INT_MAX) { |
| 527 | OPENSSL_PUT_ERROR(RSA, ERR_R_OVERFLOW); |
| 528 | return -1; |
| 529 | } |
| 530 | return (int)out_len; |
| 531 | } |
| 532 |