diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/Makefile | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/Symbols.list | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa.h | 11 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_meth.c | 86 |
4 files changed, 104 insertions, 3 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index 85e6b0ee8d..18c7c0608a 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.24 2018/02/17 13:57:14 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.25 2018/03/17 15:12:56 tb Exp $ |
| 2 | 2 | ||
| 3 | LIB= crypto | 3 | LIB= crypto |
| 4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
| @@ -227,7 +227,7 @@ SRCS+= rmd_dgst.c rmd_one.c | |||
| 227 | SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c | 227 | SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c |
| 228 | SRCS+= rsa_pk1.c rsa_none.c rsa_oaep.c rsa_chk.c | 228 | SRCS+= rsa_pk1.c rsa_none.c rsa_oaep.c rsa_chk.c |
| 229 | SRCS+= rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c | 229 | SRCS+= rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c |
| 230 | SRCS+= rsa_pmeth.c rsa_crpt.c | 230 | SRCS+= rsa_pmeth.c rsa_crpt.c rsa_meth.c |
| 231 | 231 | ||
| 232 | # sha/ | 232 | # sha/ |
| 233 | SRCS+= sha1dgst.c sha1_one.c sha256.c sha512.c | 233 | SRCS+= sha1dgst.c sha1_one.c sha256.c sha512.c |
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 07f938f6be..7cb78c4daf 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
| @@ -2263,6 +2263,12 @@ RSA_get_default_method | |||
| 2263 | RSA_get_ex_data | 2263 | RSA_get_ex_data |
| 2264 | RSA_get_ex_new_index | 2264 | RSA_get_ex_new_index |
| 2265 | RSA_get_method | 2265 | RSA_get_method |
| 2266 | RSA_meth_dup | ||
| 2267 | RSA_meth_free | ||
| 2268 | RSA_meth_new | ||
| 2269 | RSA_meth_set_finish | ||
| 2270 | RSA_meth_set_priv_dec | ||
| 2271 | RSA_meth_set_priv_enc | ||
| 2266 | RSA_new | 2272 | RSA_new |
| 2267 | RSA_new_method | 2273 | RSA_new_method |
| 2268 | RSA_padding_add_PKCS1_OAEP | 2274 | RSA_padding_add_PKCS1_OAEP |
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h index 65a643f4c6..23929aafb9 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.37 2018/02/20 17:42:32 tb Exp $ */ | 1 | /* $OpenBSD: rsa.h,v 1.38 2018/03/17 15:12:56 tb 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 | * |
| @@ -430,6 +430,15 @@ RSA *RSAPrivateKey_dup(RSA *rsa); | |||
| 430 | */ | 430 | */ |
| 431 | #define RSA_FLAG_CHECKED 0x0800 | 431 | #define RSA_FLAG_CHECKED 0x0800 |
| 432 | 432 | ||
| 433 | RSA_METHOD *RSA_meth_new(const char *name, int flags); | ||
| 434 | void RSA_meth_free(RSA_METHOD *meth); | ||
| 435 | RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); | ||
| 436 | int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen, | ||
| 437 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); | ||
| 438 | int RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen, | ||
| 439 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); | ||
| 440 | int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa)); | ||
| 441 | |||
| 433 | /* BEGIN ERROR CODES */ | 442 | /* BEGIN ERROR CODES */ |
| 434 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 443 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 435 | * made after this point may be overwritten when the script is next run. | 444 | * made after this point may be overwritten when the script is next run. |
diff --git a/src/lib/libcrypto/rsa/rsa_meth.c b/src/lib/libcrypto/rsa/rsa_meth.c new file mode 100644 index 0000000000..0e52799a38 --- /dev/null +++ b/src/lib/libcrypto/rsa/rsa_meth.c | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* $OpenBSD: rsa_meth.c,v 1.1 2018/03/17 15:12:56 tb Exp $ */ | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | ||
| 4 | * | ||
| 5 | * Permission to use, copy, modify, and distribute this software for any | ||
| 6 | * purpose with or without fee is hereby granted, provided that the above | ||
| 7 | * copyright notice and this permission notice appear in all copies. | ||
| 8 | * | ||
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <stdlib.h> | ||
| 19 | #include <string.h> | ||
| 20 | |||
| 21 | #include <openssl/err.h> | ||
| 22 | #include <openssl/rsa.h> | ||
| 23 | |||
| 24 | RSA_METHOD * | ||
| 25 | RSA_meth_new(const char *name, int flags) | ||
| 26 | { | ||
| 27 | RSA_METHOD *meth; | ||
| 28 | |||
| 29 | if ((meth = calloc(1, sizeof(*meth))) == NULL) | ||
| 30 | return NULL; | ||
| 31 | if ((meth->name = strdup(name)) == NULL) { | ||
| 32 | free(meth); | ||
| 33 | return NULL; | ||
| 34 | } | ||
| 35 | meth->flags = flags; | ||
| 36 | |||
| 37 | return meth; | ||
| 38 | } | ||
| 39 | |||
| 40 | void | ||
| 41 | RSA_meth_free(RSA_METHOD *meth) | ||
| 42 | { | ||
| 43 | if (meth != NULL) { | ||
| 44 | free((char *)meth->name); | ||
| 45 | free(meth); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | RSA_METHOD * | ||
| 50 | RSA_meth_dup(const RSA_METHOD *meth) | ||
| 51 | { | ||
| 52 | RSA_METHOD *copy; | ||
| 53 | |||
| 54 | if ((copy = calloc(1, sizeof(*copy))) == NULL) | ||
| 55 | return NULL; | ||
| 56 | memcpy(copy, meth, sizeof(*copy)); | ||
| 57 | if ((copy->name = strdup(meth->name)) == NULL) { | ||
| 58 | free(copy); | ||
| 59 | return NULL; | ||
| 60 | } | ||
| 61 | |||
| 62 | return copy; | ||
| 63 | } | ||
| 64 | |||
| 65 | int | ||
| 66 | RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen, | ||
| 67 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding)) | ||
| 68 | { | ||
| 69 | meth->rsa_priv_enc = priv_enc; | ||
| 70 | return 1; | ||
| 71 | } | ||
| 72 | |||
| 73 | int | ||
| 74 | RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen, | ||
| 75 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding)) | ||
| 76 | { | ||
| 77 | meth->rsa_priv_dec = priv_dec; | ||
| 78 | return 1; | ||
| 79 | } | ||
| 80 | |||
| 81 | int | ||
| 82 | RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa)) | ||
| 83 | { | ||
| 84 | meth->finish = finish; | ||
| 85 | return 1; | ||
| 86 | } | ||
