From f517ffbb837ea02ac0a3a12d4094253ceb3946e8 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 22 Oct 2015 16:17:50 +0100 Subject: [PATCH] remove ECDH_METHOD from ENGINE Reviewed-by: Richard Levitte --- crypto/engine/Makefile | 4 +- crypto/engine/eng_fat.c | 5 -- crypto/engine/eng_int.h | 1 - crypto/engine/eng_list.c | 1 - crypto/engine/eng_openssl.c | 1 - crypto/engine/tb_ecdh.c | 139 ------------------------------------ include/openssl/engine.h | 9 --- 7 files changed, 2 insertions(+), 158 deletions(-) delete mode 100644 crypto/engine/tb_ecdh.c diff --git a/crypto/engine/Makefile b/crypto/engine/Makefile index 74ff4ff622..d09235752d 100644 --- a/crypto/engine/Makefile +++ b/crypto/engine/Makefile @@ -17,13 +17,13 @@ GENERAL=Makefile LIB=$(TOP)/libcrypto.a LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \ eng_table.c eng_pkey.c eng_fat.c eng_all.c \ - tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c \ + tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_rand.c tb_store.c \ tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c tb_eckey.c \ eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c \ eng_rdrand.c LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \ eng_table.o eng_pkey.o eng_fat.o eng_all.o \ - tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o \ + tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_rand.o tb_store.o \ tb_cipher.o tb_digest.o tb_pkmeth.o tb_asnmth.o tb_eckey.o \ eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o \ eng_rdrand.o diff --git a/crypto/engine/eng_fat.c b/crypto/engine/eng_fat.c index e0c8f96f69..60d62d882d 100644 --- a/crypto/engine/eng_fat.c +++ b/crypto/engine/eng_fat.c @@ -80,8 +80,6 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags) return 0; #endif #ifndef OPENSSL_NO_EC - if ((flags & ENGINE_METHOD_ECDH) && !ENGINE_set_default_ECDH(e)) - return 0; if ((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e)) return 0; #endif @@ -109,8 +107,6 @@ static int int_def_cb(const char *alg, int len, void *arg) *pflags |= ENGINE_METHOD_RSA; else if (strncmp(alg, "DSA", len) == 0) *pflags |= ENGINE_METHOD_DSA; - else if (strncmp(alg, "ECDH", len) == 0) - *pflags |= ENGINE_METHOD_ECDH; else if (strncmp(alg, "ECDSA", len) == 0) *pflags |= ENGINE_METHOD_ECDSA; else if (strncmp(alg, "DH", len) == 0) @@ -158,7 +154,6 @@ int ENGINE_register_complete(ENGINE *e) ENGINE_register_DH(e); #endif #ifndef OPENSSL_NO_EC - ENGINE_register_ECDH(e); ENGINE_register_ECDSA(e); #endif ENGINE_register_RAND(e); diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h index 91160ded48..939e59da4e 100644 --- a/crypto/engine/eng_int.h +++ b/crypto/engine/eng_int.h @@ -179,7 +179,6 @@ struct engine_st { const RSA_METHOD *rsa_meth; const DSA_METHOD *dsa_meth; const DH_METHOD *dh_meth; - const ECDH_METHOD *ecdh_meth; const ECDSA_METHOD *ecdsa_meth; const EC_KEY_METHOD *ec_key_meth; const RAND_METHOD *rand_meth; diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index cfd4f7e25c..997603363d 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -302,7 +302,6 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src) dest->dh_meth = src->dh_meth; #endif #ifndef OPENSSL_NO_EC - dest->ecdh_meth = src->ecdh_meth; dest->ecdsa_meth = src->ecdsa_meth; #endif dest->rand_meth = src->rand_meth; diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c index b81f9c6789..9b2f459f14 100644 --- a/crypto/engine/eng_openssl.c +++ b/crypto/engine/eng_openssl.c @@ -155,7 +155,6 @@ static int bind_helper(ENGINE *e) || !ENGINE_set_DSA(e, DSA_get_default_method()) # endif # ifndef OPENSSL_NO_EC - || !ENGINE_set_ECDH(e, ECDH_OpenSSL()) || !ENGINE_set_ECDSA(e, ECDSA_OpenSSL()) # endif # ifndef OPENSSL_NO_DH diff --git a/crypto/engine/tb_ecdh.c b/crypto/engine/tb_ecdh.c deleted file mode 100644 index c51441be8a..0000000000 --- a/crypto/engine/tb_ecdh.c +++ /dev/null @@ -1,139 +0,0 @@ -/* crypto/engine/tb_ecdh.c */ -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * The Elliptic Curve Public-Key Crypto Library (ECC Code) included - * herein is developed by SUN MICROSYSTEMS, INC., and is contributed - * to the OpenSSL project. - * - * The ECC Code is licensed pursuant to the OpenSSL open source - * license provided below. - * - * The ECDH engine software is originally written by Nils Gura and - * Douglas Stebila of Sun Microsystems Laboratories. - * - */ -/* ==================================================================== - * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include "eng_int.h" - -/* - * If this symbol is defined then ENGINE_get_default_ECDH(), the function - * that is used by ECDH to hook in implementation code and cache defaults - * (etc), will display brief debugging summaries to stderr with the 'nid'. - */ -/* #define ENGINE_ECDH_DEBUG */ - -static ENGINE_TABLE *ecdh_table = NULL; -static const int dummy_nid = 1; - -void ENGINE_unregister_ECDH(ENGINE *e) -{ - engine_table_unregister(&ecdh_table, e); -} - -static void engine_unregister_all_ECDH(void) -{ - engine_table_cleanup(&ecdh_table); -} - -int ENGINE_register_ECDH(ENGINE *e) -{ - if (e->ecdh_meth) - return engine_table_register(&ecdh_table, - engine_unregister_all_ECDH, e, - &dummy_nid, 1, 0); - return 1; -} - -void ENGINE_register_all_ECDH() -{ - ENGINE *e; - - for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) - ENGINE_register_ECDH(e); -} - -int ENGINE_set_default_ECDH(ENGINE *e) -{ - if (e->ecdh_meth) - return engine_table_register(&ecdh_table, - engine_unregister_all_ECDH, e, - &dummy_nid, 1, 1); - return 1; -} - -/* - * Exposed API function to get a functional reference from the implementation - * table (ie. try to get a functional reference from the tabled structural - * references). - */ -ENGINE *ENGINE_get_default_ECDH(void) -{ - return engine_table_select(&ecdh_table, dummy_nid); -} - -/* Obtains an ECDH implementation from an ENGINE functional reference */ -const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e) -{ - return e->ecdh_meth; -} - -/* Sets an ECDH implementation in an ENGINE structure */ -int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth) -{ - e->ecdh_meth = ecdh_meth; - return 1; -} diff --git a/include/openssl/engine.h b/include/openssl/engine.h index 865eef1599..d82535bb56 100644 --- a/include/openssl/engine.h +++ b/include/openssl/engine.h @@ -108,7 +108,6 @@ extern "C" { # define ENGINE_METHOD_DSA (unsigned int)0x0002 # define ENGINE_METHOD_DH (unsigned int)0x0004 # define ENGINE_METHOD_RAND (unsigned int)0x0008 -# define ENGINE_METHOD_ECDH (unsigned int)0x0010 # define ENGINE_METHOD_ECDSA (unsigned int)0x0020 # define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 # define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 @@ -440,10 +439,6 @@ int ENGINE_register_DSA(ENGINE *e); void ENGINE_unregister_DSA(ENGINE *e); void ENGINE_register_all_DSA(void); -int ENGINE_register_ECDH(ENGINE *e); -void ENGINE_unregister_ECDH(ENGINE *e); -void ENGINE_register_all_ECDH(void); - int ENGINE_register_ECDSA(ENGINE *e); void ENGINE_unregister_ECDSA(ENGINE *e); void ENGINE_register_all_ECDSA(void); @@ -558,7 +553,6 @@ int ENGINE_set_id(ENGINE *e, const char *id); int ENGINE_set_name(ENGINE *e, const char *name); int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); -int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth); int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth); int ENGINE_set_EC_KEY(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth); int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); @@ -604,7 +598,6 @@ const char *ENGINE_get_id(const ENGINE *e); const char *ENGINE_get_name(const ENGINE *e); const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); -const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); const EC_KEY_METHOD *ENGINE_get_EC_KEY(const ENGINE *e); const DH_METHOD *ENGINE_get_DH(const ENGINE *e); @@ -684,7 +677,6 @@ int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, ENGINE *ENGINE_get_default_RSA(void); /* Same for the other "methods" */ ENGINE *ENGINE_get_default_DSA(void); -ENGINE *ENGINE_get_default_ECDH(void); ENGINE *ENGINE_get_default_ECDSA(void); ENGINE *ENGINE_get_default_EC_KEY(void); ENGINE *ENGINE_get_default_DH(void); @@ -708,7 +700,6 @@ int ENGINE_set_default_RSA(ENGINE *e); int ENGINE_set_default_string(ENGINE *e, const char *def_list); /* Same for the other "methods" */ int ENGINE_set_default_DSA(ENGINE *e); -int ENGINE_set_default_ECDH(ENGINE *e); int ENGINE_set_default_ECDSA(ENGINE *e); int ENGINE_set_default_EC_KEY(ENGINE *e); int ENGINE_set_default_DH(ENGINE *e); -- 2.25.1