提交 7d711cbc 编写于 作者: D Dr. Stephen Henson

Engine EC_KEY_METHOD functionality.

Rename ENGINE _EC_KEY functions to _EC.
Add support for EC_KEY_METHOD in ENGINE_set_default et al. Copy
ec_meth.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 d2ad1c96
...@@ -109,9 +109,9 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine) ...@@ -109,9 +109,9 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
} }
ret->engine = engine; ret->engine = engine;
} else } else
ret->engine = ENGINE_get_default_EC_KEY(); ret->engine = ENGINE_get_default_EC();
if (ret->engine) { if (ret->engine) {
ret->meth = ENGINE_get_EC_KEY(ret->engine); ret->meth = ENGINE_get_EC(ret->engine);
if (!ret->meth) { if (!ret->meth) {
ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB); ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);
ENGINE_finish(ret->engine); ENGINE_finish(ret->engine);
......
...@@ -80,6 +80,8 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags) ...@@ -80,6 +80,8 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
return 0; return 0;
#endif #endif
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
return 0;
#endif #endif
if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e)) if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
return 0; return 0;
...@@ -107,6 +109,8 @@ static int int_def_cb(const char *alg, int len, void *arg) ...@@ -107,6 +109,8 @@ static int int_def_cb(const char *alg, int len, void *arg)
*pflags |= ENGINE_METHOD_DSA; *pflags |= ENGINE_METHOD_DSA;
else if (strncmp(alg, "DH", len) == 0) else if (strncmp(alg, "DH", len) == 0)
*pflags |= ENGINE_METHOD_DH; *pflags |= ENGINE_METHOD_DH;
else if (strncmp(alg, "EC", len) == 0)
*pflags |= ENGINE_METHOD_EC;
else if (strncmp(alg, "RAND", len) == 0) else if (strncmp(alg, "RAND", len) == 0)
*pflags |= ENGINE_METHOD_RAND; *pflags |= ENGINE_METHOD_RAND;
else if (strncmp(alg, "CIPHERS", len) == 0) else if (strncmp(alg, "CIPHERS", len) == 0)
...@@ -150,6 +154,7 @@ int ENGINE_register_complete(ENGINE *e) ...@@ -150,6 +154,7 @@ int ENGINE_register_complete(ENGINE *e)
ENGINE_register_DH(e); ENGINE_register_DH(e);
#endif #endif
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
ENGINE_register_EC(e);
#endif #endif
ENGINE_register_RAND(e); ENGINE_register_RAND(e);
ENGINE_register_pkey_meths(e); ENGINE_register_pkey_meths(e);
......
...@@ -179,7 +179,7 @@ struct engine_st { ...@@ -179,7 +179,7 @@ struct engine_st {
const RSA_METHOD *rsa_meth; const RSA_METHOD *rsa_meth;
const DSA_METHOD *dsa_meth; const DSA_METHOD *dsa_meth;
const DH_METHOD *dh_meth; const DH_METHOD *dh_meth;
const EC_KEY_METHOD *ec_key_meth; const EC_KEY_METHOD *ec_meth;
const RAND_METHOD *rand_meth; const RAND_METHOD *rand_meth;
const STORE_METHOD *store_meth; const STORE_METHOD *store_meth;
/* Cipher handling is via this callback */ /* Cipher handling is via this callback */
......
...@@ -302,7 +302,7 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src) ...@@ -302,7 +302,7 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src)
dest->dh_meth = src->dh_meth; dest->dh_meth = src->dh_meth;
#endif #endif
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
dest->ec_meth = src->ec_meth;
#endif #endif
dest->rand_meth = src->rand_meth; dest->rand_meth = src->rand_meth;
dest->store_meth = src->store_meth; dest->store_meth = src->store_meth;
......
...@@ -64,38 +64,38 @@ ...@@ -64,38 +64,38 @@
static ENGINE_TABLE *dh_table = NULL; static ENGINE_TABLE *dh_table = NULL;
static const int dummy_nid = 1; static const int dummy_nid = 1;
void ENGINE_unregister_EC_KEY(ENGINE *e) void ENGINE_unregister_EC(ENGINE *e)
{ {
engine_table_unregister(&dh_table, e); engine_table_unregister(&dh_table, e);
} }
static void engine_unregister_all_EC_KEY(void) static void engine_unregister_all_EC(void)
{ {
engine_table_cleanup(&dh_table); engine_table_cleanup(&dh_table);
} }
int ENGINE_register_EC_KEY(ENGINE *e) int ENGINE_register_EC(ENGINE *e)
{ {
if (e->ec_key_meth) if (e->ec_meth)
return engine_table_register(&dh_table, return engine_table_register(&dh_table,
engine_unregister_all_EC_KEY, e, &dummy_nid, engine_unregister_all_EC, e, &dummy_nid,
1, 0); 1, 0);
return 1; return 1;
} }
void ENGINE_register_all_EC_KEY() void ENGINE_register_all_EC()
{ {
ENGINE *e; ENGINE *e;
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
ENGINE_register_EC_KEY(e); ENGINE_register_EC(e);
} }
int ENGINE_set_default_EC_KEY(ENGINE *e) int ENGINE_set_default_EC(ENGINE *e)
{ {
if (e->ec_key_meth) if (e->ec_meth)
return engine_table_register(&dh_table, return engine_table_register(&dh_table,
engine_unregister_all_EC_KEY, e, &dummy_nid, engine_unregister_all_EC, e, &dummy_nid,
1, 1); 1, 1);
return 1; return 1;
} }
...@@ -105,20 +105,20 @@ int ENGINE_set_default_EC_KEY(ENGINE *e) ...@@ -105,20 +105,20 @@ int ENGINE_set_default_EC_KEY(ENGINE *e)
* table (ie. try to get a functional reference from the tabled structural * table (ie. try to get a functional reference from the tabled structural
* references). * references).
*/ */
ENGINE *ENGINE_get_default_EC_KEY(void) ENGINE *ENGINE_get_default_EC(void)
{ {
return engine_table_select(&dh_table, dummy_nid); return engine_table_select(&dh_table, dummy_nid);
} }
/* Obtains an EC_KEY implementation from an ENGINE functional reference */ /* Obtains an EC_KEY implementation from an ENGINE functional reference */
const EC_KEY_METHOD *ENGINE_get_EC_KEY(const ENGINE *e) const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e)
{ {
return e->ec_key_meth; return e->ec_meth;
} }
/* Sets an EC_KEY implementation in an ENGINE structure */ /* Sets an EC_KEY implementation in an ENGINE structure */
int ENGINE_set_EC_KEY(ENGINE *e, const EC_KEY_METHOD *ec_key_meth) int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth)
{ {
e->ec_key_meth = ec_key_meth; e->ec_meth = ec_meth;
return 1; return 1;
} }
...@@ -83,8 +83,7 @@ ...@@ -83,8 +83,7 @@
# include <openssl/dh.h> # include <openssl/dh.h>
# endif # endif
# ifndef OPENSSL_NO_EC # ifndef OPENSSL_NO_EC
# include <openssl/ecdh.h> # include <openssl/ec.h>
# include <openssl/ecdsa.h>
# endif # endif
# include <openssl/rand.h> # include <openssl/rand.h>
# include <openssl/ui.h> # include <openssl/ui.h>
...@@ -113,7 +112,7 @@ extern "C" { ...@@ -113,7 +112,7 @@ extern "C" {
# define ENGINE_METHOD_STORE (unsigned int)0x0100 # define ENGINE_METHOD_STORE (unsigned int)0x0100
# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 # define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200
# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 # define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400
# define ENGINE_METHOD_EC_KEY (unsigned int)0x0800 # define ENGINE_METHOD_EC (unsigned int)0x0800
/* Obvious all-or-nothing cases. */ /* Obvious all-or-nothing cases. */
# define ENGINE_METHOD_ALL (unsigned int)0xFFFF # define ENGINE_METHOD_ALL (unsigned int)0xFFFF
# define ENGINE_METHOD_NONE (unsigned int)0x0000 # define ENGINE_METHOD_NONE (unsigned int)0x0000
...@@ -438,9 +437,9 @@ int ENGINE_register_DSA(ENGINE *e); ...@@ -438,9 +437,9 @@ int ENGINE_register_DSA(ENGINE *e);
void ENGINE_unregister_DSA(ENGINE *e); void ENGINE_unregister_DSA(ENGINE *e);
void ENGINE_register_all_DSA(void); void ENGINE_register_all_DSA(void);
int ENGINE_register_EC_KEY(ENGINE *e); int ENGINE_register_EC(ENGINE *e);
void ENGINE_unregister_EC_KEY(ENGINE *e); void ENGINE_unregister_EC(ENGINE *e);
void ENGINE_register_all_EC_KEY(void); void ENGINE_register_all_EC(void);
int ENGINE_register_DH(ENGINE *e); int ENGINE_register_DH(ENGINE *e);
void ENGINE_unregister_DH(ENGINE *e); void ENGINE_unregister_DH(ENGINE *e);
...@@ -548,7 +547,7 @@ int ENGINE_set_id(ENGINE *e, const char *id); ...@@ -548,7 +547,7 @@ int ENGINE_set_id(ENGINE *e, const char *id);
int ENGINE_set_name(ENGINE *e, const char *name); int ENGINE_set_name(ENGINE *e, const char *name);
int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); 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_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
int ENGINE_set_EC_KEY(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth); int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth);
int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth); int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth);
...@@ -592,7 +591,7 @@ const char *ENGINE_get_id(const ENGINE *e); ...@@ -592,7 +591,7 @@ const char *ENGINE_get_id(const ENGINE *e);
const char *ENGINE_get_name(const ENGINE *e); const char *ENGINE_get_name(const ENGINE *e);
const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
const EC_KEY_METHOD *ENGINE_get_EC_KEY(const ENGINE *e); const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);
const DH_METHOD *ENGINE_get_DH(const ENGINE *e); const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
...@@ -670,7 +669,7 @@ int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, ...@@ -670,7 +669,7 @@ int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
ENGINE *ENGINE_get_default_RSA(void); ENGINE *ENGINE_get_default_RSA(void);
/* Same for the other "methods" */ /* Same for the other "methods" */
ENGINE *ENGINE_get_default_DSA(void); ENGINE *ENGINE_get_default_DSA(void);
ENGINE *ENGINE_get_default_EC_KEY(void); ENGINE *ENGINE_get_default_EC(void);
ENGINE *ENGINE_get_default_DH(void); ENGINE *ENGINE_get_default_DH(void);
ENGINE *ENGINE_get_default_RAND(void); ENGINE *ENGINE_get_default_RAND(void);
/* /*
...@@ -692,7 +691,7 @@ int ENGINE_set_default_RSA(ENGINE *e); ...@@ -692,7 +691,7 @@ int ENGINE_set_default_RSA(ENGINE *e);
int ENGINE_set_default_string(ENGINE *e, const char *def_list); int ENGINE_set_default_string(ENGINE *e, const char *def_list);
/* Same for the other "methods" */ /* Same for the other "methods" */
int ENGINE_set_default_DSA(ENGINE *e); int ENGINE_set_default_DSA(ENGINE *e);
int ENGINE_set_default_EC_KEY(ENGINE *e); int ENGINE_set_default_EC(ENGINE *e);
int ENGINE_set_default_DH(ENGINE *e); int ENGINE_set_default_DH(ENGINE *e);
int ENGINE_set_default_RAND(ENGINE *e); int ENGINE_set_default_RAND(ENGINE *e);
int ENGINE_set_default_ciphers(ENGINE *e); int ENGINE_set_default_ciphers(ENGINE *e);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册