diff options
Diffstat (limited to 'src/lib/libcrypto/rsa')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa.h | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_pmeth.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_ssl.c | 147 |
4 files changed, 3 insertions, 166 deletions
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h index febeb297d0..777f2fed9e 100644 --- a/src/lib/libcrypto/rsa/rsa.h +++ b/src/lib/libcrypto/rsa/rsa.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa.h,v 1.29 2016/09/04 17:25:27 jsing Exp $ */ | 1 | /* $OpenBSD: rsa.h,v 1.30 2017/08/28 17:41:59 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -242,7 +242,6 @@ struct rsa_st { | |||
| 242 | #define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8) | 242 | #define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8) |
| 243 | 243 | ||
| 244 | #define RSA_PKCS1_PADDING 1 | 244 | #define RSA_PKCS1_PADDING 1 |
| 245 | #define RSA_SSLV23_PADDING 2 | ||
| 246 | #define RSA_NO_PADDING 3 | 245 | #define RSA_NO_PADDING 3 |
| 247 | #define RSA_PKCS1_OAEP_PADDING 4 | 246 | #define RSA_PKCS1_OAEP_PADDING 4 |
| 248 | #define RSA_X931_PADDING 5 | 247 | #define RSA_X931_PADDING 5 |
| @@ -367,10 +366,6 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, | |||
| 367 | int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, | 366 | int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, |
| 368 | const unsigned char *f, int fl, int rsa_len, | 367 | const unsigned char *f, int fl, int rsa_len, |
| 369 | const unsigned char *p, int pl); | 368 | const unsigned char *p, int pl); |
| 370 | int RSA_padding_add_SSLv23(unsigned char *to, int tlen, | ||
| 371 | const unsigned char *f, int fl); | ||
| 372 | int RSA_padding_check_SSLv23(unsigned char *to, int tlen, | ||
| 373 | const unsigned char *f, int fl, int rsa_len); | ||
| 374 | int RSA_padding_add_none(unsigned char *to, int tlen, | 369 | int RSA_padding_add_none(unsigned char *to, int tlen, |
| 375 | const unsigned char *f, int fl); | 370 | const unsigned char *f, int fl); |
| 376 | int RSA_padding_check_none(unsigned char *to, int tlen, | 371 | int RSA_padding_check_none(unsigned char *to, int tlen, |
| @@ -464,13 +459,11 @@ void ERR_load_RSA_strings(void); | |||
| 464 | #define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 148 | 459 | #define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 148 |
| 465 | #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 | 460 | #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 |
| 466 | #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 | 461 | #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 |
| 467 | #define RSA_F_RSA_PADDING_ADD_SSLV23 110 | ||
| 468 | #define RSA_F_RSA_PADDING_ADD_X931 127 | 462 | #define RSA_F_RSA_PADDING_ADD_X931 127 |
| 469 | #define RSA_F_RSA_PADDING_CHECK_NONE 111 | 463 | #define RSA_F_RSA_PADDING_CHECK_NONE 111 |
| 470 | #define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 | 464 | #define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 |
| 471 | #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 | 465 | #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 |
| 472 | #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 | 466 | #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 |
| 473 | #define RSA_F_RSA_PADDING_CHECK_SSLV23 114 | ||
| 474 | #define RSA_F_RSA_PADDING_CHECK_X931 128 | 467 | #define RSA_F_RSA_PADDING_CHECK_X931 128 |
| 475 | #define RSA_F_RSA_PRINT 115 | 468 | #define RSA_F_RSA_PRINT 115 |
| 476 | #define RSA_F_RSA_PRINT_FP 116 | 469 | #define RSA_F_RSA_PRINT_FP 116 |
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index 6c3da0d656..8e8c6d520d 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_eay.c,v 1.49 2017/05/02 03:59:45 deraadt Exp $ */ | 1 | /* $OpenBSD: rsa_eay.c,v 1.50 2017/08/28 17:41:59 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -200,9 +200,6 @@ RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, | |||
| 200 | i = RSA_padding_add_PKCS1_OAEP(buf, num, from, flen, NULL, 0); | 200 | i = RSA_padding_add_PKCS1_OAEP(buf, num, from, flen, NULL, 0); |
| 201 | break; | 201 | break; |
| 202 | #endif | 202 | #endif |
| 203 | case RSA_SSLV23_PADDING: | ||
| 204 | i = RSA_padding_add_SSLv23(buf, num, from, flen); | ||
| 205 | break; | ||
| 206 | case RSA_NO_PADDING: | 203 | case RSA_NO_PADDING: |
| 207 | i = RSA_padding_add_none(buf, num, from, flen); | 204 | i = RSA_padding_add_none(buf, num, from, flen); |
| 208 | break; | 205 | break; |
| @@ -383,7 +380,6 @@ RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to, | |||
| 383 | case RSA_NO_PADDING: | 380 | case RSA_NO_PADDING: |
| 384 | i = RSA_padding_add_none(buf, num, from, flen); | 381 | i = RSA_padding_add_none(buf, num, from, flen); |
| 385 | break; | 382 | break; |
| 386 | case RSA_SSLV23_PADDING: | ||
| 387 | default: | 383 | default: |
| 388 | RSAerror(RSA_R_UNKNOWN_PADDING_TYPE); | 384 | RSAerror(RSA_R_UNKNOWN_PADDING_TYPE); |
| 389 | goto err; | 385 | goto err; |
| @@ -573,9 +569,6 @@ RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to, | |||
| 573 | r = RSA_padding_check_PKCS1_OAEP(to, num, buf, j, num, NULL, 0); | 569 | r = RSA_padding_check_PKCS1_OAEP(to, num, buf, j, num, NULL, 0); |
| 574 | break; | 570 | break; |
| 575 | #endif | 571 | #endif |
| 576 | case RSA_SSLV23_PADDING: | ||
| 577 | r = RSA_padding_check_SSLv23(to, num, buf, j, num); | ||
| 578 | break; | ||
| 579 | case RSA_NO_PADDING: | 572 | case RSA_NO_PADDING: |
| 580 | r = RSA_padding_check_none(to, num, buf, j, num); | 573 | r = RSA_padding_check_none(to, num, buf, j, num); |
| 581 | break; | 574 | break; |
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c index 2ef1f3c64a..b4a4e730c0 100644 --- a/src/lib/libcrypto/rsa/rsa_pmeth.c +++ b/src/lib/libcrypto/rsa/rsa_pmeth.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_pmeth.c,v 1.19 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: rsa_pmeth.c,v 1.20 2017/08/28 17:41:59 jsing Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -466,8 +466,6 @@ pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) | |||
| 466 | int pm; | 466 | int pm; |
| 467 | if (!strcmp(value, "pkcs1")) | 467 | if (!strcmp(value, "pkcs1")) |
| 468 | pm = RSA_PKCS1_PADDING; | 468 | pm = RSA_PKCS1_PADDING; |
| 469 | else if (!strcmp(value, "sslv23")) | ||
| 470 | pm = RSA_SSLV23_PADDING; | ||
| 471 | else if (!strcmp(value, "none")) | 469 | else if (!strcmp(value, "none")) |
| 472 | pm = RSA_NO_PADDING; | 470 | pm = RSA_NO_PADDING; |
| 473 | else if (!strcmp(value, "oeap")) | 471 | else if (!strcmp(value, "oeap")) |
diff --git a/src/lib/libcrypto/rsa/rsa_ssl.c b/src/lib/libcrypto/rsa/rsa_ssl.c deleted file mode 100644 index 60fc8ec94f..0000000000 --- a/src/lib/libcrypto/rsa/rsa_ssl.c +++ /dev/null | |||
| @@ -1,147 +0,0 @@ | |||
| 1 | /* $OpenBSD: rsa_ssl.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <stdlib.h> | ||
| 61 | #include <string.h> | ||
| 62 | |||
| 63 | #include <openssl/bn.h> | ||
| 64 | #include <openssl/err.h> | ||
| 65 | #include <openssl/rsa.h> | ||
| 66 | |||
| 67 | int | ||
| 68 | RSA_padding_add_SSLv23(unsigned char *to, int tlen, const unsigned char *from, | ||
| 69 | int flen) | ||
| 70 | { | ||
| 71 | int i, j; | ||
| 72 | unsigned char *p; | ||
| 73 | |||
| 74 | if (flen > tlen - 11) { | ||
| 75 | RSAerror(RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); | ||
| 76 | return 0; | ||
| 77 | } | ||
| 78 | |||
| 79 | p = (unsigned char *)to; | ||
| 80 | |||
| 81 | *(p++) = 0; | ||
| 82 | *(p++) = 2; /* Public Key BT (Block Type) */ | ||
| 83 | |||
| 84 | /* pad out with non-zero random data */ | ||
| 85 | j = tlen - 3 - 8 - flen; | ||
| 86 | |||
| 87 | arc4random_buf(p, j); | ||
| 88 | for (i = 0; i < j; i++) { | ||
| 89 | while (*p == '\0') | ||
| 90 | arc4random_buf(p, 1); | ||
| 91 | p++; | ||
| 92 | } | ||
| 93 | |||
| 94 | memset(p, 3, 8); | ||
| 95 | p += 8; | ||
| 96 | *(p++) = '\0'; | ||
| 97 | |||
| 98 | memcpy(p, from, flen); | ||
| 99 | return 1; | ||
| 100 | } | ||
| 101 | |||
| 102 | int | ||
| 103 | RSA_padding_check_SSLv23(unsigned char *to, int tlen, const unsigned char *from, | ||
| 104 | int flen, int num) | ||
| 105 | { | ||
| 106 | int i, j, k; | ||
| 107 | const unsigned char *p; | ||
| 108 | |||
| 109 | p = from; | ||
| 110 | if (flen < 10) { | ||
| 111 | RSAerror(RSA_R_DATA_TOO_SMALL); | ||
| 112 | return -1; | ||
| 113 | } | ||
| 114 | if (num != flen + 1 || *(p++) != 02) { | ||
| 115 | RSAerror(RSA_R_BLOCK_TYPE_IS_NOT_02); | ||
| 116 | return -1; | ||
| 117 | } | ||
| 118 | |||
| 119 | /* scan over padding data */ | ||
| 120 | j = flen - 1; /* one for type */ | ||
| 121 | for (i = 0; i < j; i++) | ||
| 122 | if (*(p++) == 0) | ||
| 123 | break; | ||
| 124 | |||
| 125 | if (i == j || i < 8) { | ||
| 126 | RSAerror(RSA_R_NULL_BEFORE_BLOCK_MISSING); | ||
| 127 | return -1; | ||
| 128 | } | ||
| 129 | for (k = -9; k < -1; k++) { | ||
| 130 | if (p[k] != 0x03) | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | if (k == -1) { | ||
| 134 | RSAerror(RSA_R_SSLV3_ROLLBACK_ATTACK); | ||
| 135 | return -1; | ||
| 136 | } | ||
| 137 | |||
| 138 | i++; /* Skip over the '\0' */ | ||
| 139 | j -= i; | ||
| 140 | if (j > tlen) { | ||
| 141 | RSAerror(RSA_R_DATA_TOO_LARGE); | ||
| 142 | return -1; | ||
| 143 | } | ||
| 144 | memcpy(to, p, j); | ||
| 145 | |||
| 146 | return j; | ||
| 147 | } | ||
