diff options
Diffstat (limited to 'src/lib/libcrypto/engine')
-rw-r--r-- | src/lib/libcrypto/engine/eng_fat.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_int.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_list.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/engine.h | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/tb_eckey.c | 123 |
5 files changed, 152 insertions, 4 deletions
diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c index c97695a7d3..baf1a54883 100644 --- a/src/lib/libcrypto/engine/eng_fat.c +++ b/src/lib/libcrypto/engine/eng_fat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_fat.c,v 1.16 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: eng_fat.c,v 1.17 2019/01/19 01:07:00 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -93,6 +93,10 @@ ENGINE_set_default(ENGINE *e, unsigned int flags) | |||
93 | if ((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e)) | 93 | if ((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e)) |
94 | return 0; | 94 | return 0; |
95 | #endif | 95 | #endif |
96 | #ifndef OPENSSL_NO_EC | ||
97 | if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e)) | ||
98 | return 0; | ||
99 | #endif | ||
96 | if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) | 100 | if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) |
97 | return 0; | 101 | return 0; |
98 | if ((flags & ENGINE_METHOD_PKEY_METHS) && | 102 | if ((flags & ENGINE_METHOD_PKEY_METHS) && |
@@ -123,6 +127,8 @@ int_def_cb(const char *alg, int len, void *arg) | |||
123 | *pflags |= ENGINE_METHOD_ECDSA; | 127 | *pflags |= ENGINE_METHOD_ECDSA; |
124 | else if (!strncmp(alg, "DH", len)) | 128 | else if (!strncmp(alg, "DH", len)) |
125 | *pflags |= ENGINE_METHOD_DH; | 129 | *pflags |= ENGINE_METHOD_DH; |
130 | else if (strncmp(alg, "EC", len) == 0) | ||
131 | *pflags |= ENGINE_METHOD_EC; | ||
126 | else if (!strncmp(alg, "RAND", len)) | 132 | else if (!strncmp(alg, "RAND", len)) |
127 | *pflags |= ENGINE_METHOD_RAND; | 133 | *pflags |= ENGINE_METHOD_RAND; |
128 | else if (!strncmp(alg, "CIPHERS", len)) | 134 | else if (!strncmp(alg, "CIPHERS", len)) |
@@ -174,6 +180,9 @@ ENGINE_register_complete(ENGINE *e) | |||
174 | #ifndef OPENSSL_NO_ECDSA | 180 | #ifndef OPENSSL_NO_ECDSA |
175 | ENGINE_register_ECDSA(e); | 181 | ENGINE_register_ECDSA(e); |
176 | #endif | 182 | #endif |
183 | #ifndef OPENSSL_NO_EC | ||
184 | ENGINE_register_EC(e); | ||
185 | #endif | ||
177 | ENGINE_register_RAND(e); | 186 | ENGINE_register_RAND(e); |
178 | ENGINE_register_pkey_meths(e); | 187 | ENGINE_register_pkey_meths(e); |
179 | return 1; | 188 | return 1; |
diff --git a/src/lib/libcrypto/engine/eng_int.h b/src/lib/libcrypto/engine/eng_int.h index dbb639949d..298c0e327f 100644 --- a/src/lib/libcrypto/engine/eng_int.h +++ b/src/lib/libcrypto/engine/eng_int.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_int.h,v 1.9 2016/12/21 15:49:29 jsing Exp $ */ | 1 | /* $OpenBSD: eng_int.h,v 1.10 2019/01/19 01:07:00 tb Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -159,6 +159,7 @@ struct engine_st { | |||
159 | const DH_METHOD *dh_meth; | 159 | const DH_METHOD *dh_meth; |
160 | const ECDH_METHOD *ecdh_meth; | 160 | const ECDH_METHOD *ecdh_meth; |
161 | const ECDSA_METHOD *ecdsa_meth; | 161 | const ECDSA_METHOD *ecdsa_meth; |
162 | const EC_KEY_METHOD *ec_meth; | ||
162 | const RAND_METHOD *rand_meth; | 163 | const RAND_METHOD *rand_meth; |
163 | const STORE_METHOD *store_meth; | 164 | const STORE_METHOD *store_meth; |
164 | /* Cipher handling is via this callback */ | 165 | /* Cipher handling is via this callback */ |
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c index 134866d2c6..b29b4102e4 100644 --- a/src/lib/libcrypto/engine/eng_list.c +++ b/src/lib/libcrypto/engine/eng_list.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_list.c,v 1.23 2018/08/24 19:25:31 tb Exp $ */ | 1 | /* $OpenBSD: eng_list.c,v 1.24 2019/01/19 01:07:00 tb Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -316,6 +316,9 @@ engine_cpy(ENGINE *dest, const ENGINE *src) | |||
316 | #ifndef OPENSSL_NO_ECDSA | 316 | #ifndef OPENSSL_NO_ECDSA |
317 | dest->ecdsa_meth = src->ecdsa_meth; | 317 | dest->ecdsa_meth = src->ecdsa_meth; |
318 | #endif | 318 | #endif |
319 | #ifndef OPENSSL_NO_EC | ||
320 | dest->ec_meth = src->ec_meth; | ||
321 | #endif | ||
319 | dest->rand_meth = src->rand_meth; | 322 | dest->rand_meth = src->rand_meth; |
320 | dest->store_meth = src->store_meth; | 323 | dest->store_meth = src->store_meth; |
321 | dest->ciphers = src->ciphers; | 324 | dest->ciphers = src->ciphers; |
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h index 0f603feaaf..dc14be8e38 100644 --- a/src/lib/libcrypto/engine/engine.h +++ b/src/lib/libcrypto/engine/engine.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: engine.h,v 1.32 2018/11/11 06:41:28 bcook Exp $ */ | 1 | /* $OpenBSD: engine.h,v 1.33 2019/01/19 01:07:00 tb Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -87,6 +87,9 @@ | |||
87 | #ifndef OPENSSL_NO_ECDSA | 87 | #ifndef OPENSSL_NO_ECDSA |
88 | #include <openssl/ecdsa.h> | 88 | #include <openssl/ecdsa.h> |
89 | #endif | 89 | #endif |
90 | #ifndef OPENSSL_NO_EC | ||
91 | #include <openssl/ec.h> | ||
92 | #endif | ||
90 | #include <openssl/ui.h> | 93 | #include <openssl/ui.h> |
91 | #include <openssl/err.h> | 94 | #include <openssl/err.h> |
92 | #endif | 95 | #endif |
@@ -112,6 +115,7 @@ extern "C" { | |||
112 | #define ENGINE_METHOD_STORE (unsigned int)0x0100 | 115 | #define ENGINE_METHOD_STORE (unsigned int)0x0100 |
113 | #define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 | 116 | #define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 |
114 | #define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 | 117 | #define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 |
118 | #define ENGINE_METHOD_EC (unsigned int)0x0800 | ||
115 | /* Obvious all-or-nothing cases. */ | 119 | /* Obvious all-or-nothing cases. */ |
116 | #define ENGINE_METHOD_ALL (unsigned int)0xFFFF | 120 | #define ENGINE_METHOD_ALL (unsigned int)0xFFFF |
117 | #define ENGINE_METHOD_NONE (unsigned int)0x0000 | 121 | #define ENGINE_METHOD_NONE (unsigned int)0x0000 |
@@ -353,6 +357,10 @@ int ENGINE_register_ECDSA(ENGINE *e); | |||
353 | void ENGINE_unregister_ECDSA(ENGINE *e); | 357 | void ENGINE_unregister_ECDSA(ENGINE *e); |
354 | void ENGINE_register_all_ECDSA(void); | 358 | void ENGINE_register_all_ECDSA(void); |
355 | 359 | ||
360 | int ENGINE_register_EC(ENGINE *e); | ||
361 | void ENGINE_unregister_EC(ENGINE *e); | ||
362 | void ENGINE_register_all_EC(void); | ||
363 | |||
356 | int ENGINE_register_DH(ENGINE *e); | 364 | int ENGINE_register_DH(ENGINE *e); |
357 | void ENGINE_unregister_DH(ENGINE *e); | 365 | void ENGINE_unregister_DH(ENGINE *e); |
358 | void ENGINE_register_all_DH(void); | 366 | void ENGINE_register_all_DH(void); |
@@ -447,6 +455,7 @@ int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); | |||
447 | int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); | 455 | int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); |
448 | int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); | 456 | int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); |
449 | int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); | 457 | int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); |
458 | int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth); | ||
450 | int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); | 459 | int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); |
451 | int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); | 460 | int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); |
452 | int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); | 461 | int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); |
@@ -486,6 +495,7 @@ const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); | |||
486 | const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); | 495 | const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); |
487 | const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); | 496 | const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); |
488 | const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); | 497 | const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); |
498 | const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e); | ||
489 | const DH_METHOD *ENGINE_get_DH(const ENGINE *e); | 499 | const DH_METHOD *ENGINE_get_DH(const ENGINE *e); |
490 | const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); | 500 | const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); |
491 | const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); | 501 | const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); |
@@ -553,6 +563,7 @@ ENGINE *ENGINE_get_default_RSA(void); | |||
553 | ENGINE *ENGINE_get_default_DSA(void); | 563 | ENGINE *ENGINE_get_default_DSA(void); |
554 | ENGINE *ENGINE_get_default_ECDH(void); | 564 | ENGINE *ENGINE_get_default_ECDH(void); |
555 | ENGINE *ENGINE_get_default_ECDSA(void); | 565 | ENGINE *ENGINE_get_default_ECDSA(void); |
566 | ENGINE *ENGINE_get_default_EC(void); | ||
556 | ENGINE *ENGINE_get_default_DH(void); | 567 | ENGINE *ENGINE_get_default_DH(void); |
557 | ENGINE *ENGINE_get_default_RAND(void); | 568 | ENGINE *ENGINE_get_default_RAND(void); |
558 | /* These functions can be used to get a functional reference to perform | 569 | /* These functions can be used to get a functional reference to perform |
@@ -572,6 +583,7 @@ int ENGINE_set_default_string(ENGINE *e, const char *def_list); | |||
572 | int ENGINE_set_default_DSA(ENGINE *e); | 583 | int ENGINE_set_default_DSA(ENGINE *e); |
573 | int ENGINE_set_default_ECDH(ENGINE *e); | 584 | int ENGINE_set_default_ECDH(ENGINE *e); |
574 | int ENGINE_set_default_ECDSA(ENGINE *e); | 585 | int ENGINE_set_default_ECDSA(ENGINE *e); |
586 | int ENGINE_set_default_EC(ENGINE *e); | ||
575 | int ENGINE_set_default_DH(ENGINE *e); | 587 | int ENGINE_set_default_DH(ENGINE *e); |
576 | int ENGINE_set_default_RAND(ENGINE *e); | 588 | int ENGINE_set_default_RAND(ENGINE *e); |
577 | int ENGINE_set_default_ciphers(ENGINE *e); | 589 | int ENGINE_set_default_ciphers(ENGINE *e); |
diff --git a/src/lib/libcrypto/engine/tb_eckey.c b/src/lib/libcrypto/engine/tb_eckey.c new file mode 100644 index 0000000000..dd30815788 --- /dev/null +++ b/src/lib/libcrypto/engine/tb_eckey.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* ==================================================================== | ||
2 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in | ||
13 | * the documentation and/or other materials provided with the | ||
14 | * distribution. | ||
15 | * | ||
16 | * 3. All advertising materials mentioning features or use of this | ||
17 | * software must display the following acknowledgment: | ||
18 | * "This product includes software developed by the OpenSSL Project | ||
19 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
20 | * | ||
21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
22 | * endorse or promote products derived from this software without | ||
23 | * prior written permission. For written permission, please contact | ||
24 | * licensing@OpenSSL.org. | ||
25 | * | ||
26 | * 5. Products derived from this software may not be called "OpenSSL" | ||
27 | * nor may "OpenSSL" appear in their names without prior written | ||
28 | * permission of the OpenSSL Project. | ||
29 | * | ||
30 | * 6. Redistributions of any form whatsoever must retain the following | ||
31 | * acknowledgment: | ||
32 | * "This product includes software developed by the OpenSSL Project | ||
33 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
34 | * | ||
35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
46 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
47 | * ==================================================================== | ||
48 | * | ||
49 | * This product includes cryptographic software written by Eric Young | ||
50 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
51 | * Hudson (tjh@cryptsoft.com). | ||
52 | * | ||
53 | */ | ||
54 | |||
55 | #include "eng_int.h" | ||
56 | |||
57 | static ENGINE_TABLE *ec_table = NULL; | ||
58 | static const int dummy_nid = 1; | ||
59 | |||
60 | void | ||
61 | ENGINE_unregister_EC(ENGINE *e) | ||
62 | { | ||
63 | engine_table_unregister(&ec_table, e); | ||
64 | } | ||
65 | |||
66 | static void | ||
67 | engine_unregister_all_EC(void) | ||
68 | { | ||
69 | engine_table_cleanup(&ec_table); | ||
70 | } | ||
71 | |||
72 | int | ||
73 | ENGINE_register_EC(ENGINE *e) | ||
74 | { | ||
75 | if (e->ec_meth) | ||
76 | return engine_table_register(&ec_table, | ||
77 | engine_unregister_all_EC, e, &dummy_nid, 1, 0); | ||
78 | return 1; | ||
79 | } | ||
80 | |||
81 | void | ||
82 | ENGINE_register_all_EC(void) | ||
83 | { | ||
84 | ENGINE *e; | ||
85 | |||
86 | for (e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e)) | ||
87 | ENGINE_register_EC(e); | ||
88 | } | ||
89 | |||
90 | int | ||
91 | ENGINE_set_default_EC(ENGINE *e) | ||
92 | { | ||
93 | if (e->ec_meth != NULL) | ||
94 | return engine_table_register(&ec_table, | ||
95 | engine_unregister_all_EC, e, &dummy_nid, 1, 1); | ||
96 | return 1; | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Exposed API function to get a functional reference from the implementation | ||
101 | * table (ie. try to get a functional reference from the tabled structural | ||
102 | * references). | ||
103 | */ | ||
104 | ENGINE * | ||
105 | ENGINE_get_default_EC(void) | ||
106 | { | ||
107 | return engine_table_select(&ec_table, dummy_nid); | ||
108 | } | ||
109 | |||
110 | /* Obtains an EC_KEY implementation from an ENGINE functional reference */ | ||
111 | const EC_KEY_METHOD * | ||
112 | ENGINE_get_EC(const ENGINE *e) | ||
113 | { | ||
114 | return e->ec_meth; | ||
115 | } | ||
116 | |||
117 | /* Sets an EC_KEY implementation in an ENGINE structure */ | ||
118 | int | ||
119 | ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth) | ||
120 | { | ||
121 | e->ec_meth = ec_meth; | ||
122 | return 1; | ||
123 | } | ||