mirror of
https://github.com/openssl/openssl.git
synced 2024-11-21 01:15:20 +08:00
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: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
d2ad1c9617
commit
7d711cbc33
@ -109,9 +109,9 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
|
||||
}
|
||||
ret->engine = engine;
|
||||
} else
|
||||
ret->engine = ENGINE_get_default_EC_KEY();
|
||||
ret->engine = ENGINE_get_default_EC();
|
||||
if (ret->engine) {
|
||||
ret->meth = ENGINE_get_EC_KEY(ret->engine);
|
||||
ret->meth = ENGINE_get_EC(ret->engine);
|
||||
if (!ret->meth) {
|
||||
ECerr(EC_F_EC_KEY_NEW_METHOD, ERR_R_ENGINE_LIB);
|
||||
ENGINE_finish(ret->engine);
|
||||
|
@ -80,6 +80,8 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
|
||||
return 0;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
|
||||
return 0;
|
||||
#endif
|
||||
if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
|
||||
return 0;
|
||||
@ -107,6 +109,8 @@ static int int_def_cb(const char *alg, int len, void *arg)
|
||||
*pflags |= ENGINE_METHOD_DSA;
|
||||
else if (strncmp(alg, "DH", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_DH;
|
||||
else if (strncmp(alg, "EC", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_EC;
|
||||
else if (strncmp(alg, "RAND", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_RAND;
|
||||
else if (strncmp(alg, "CIPHERS", len) == 0)
|
||||
@ -150,6 +154,7 @@ int ENGINE_register_complete(ENGINE *e)
|
||||
ENGINE_register_DH(e);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ENGINE_register_EC(e);
|
||||
#endif
|
||||
ENGINE_register_RAND(e);
|
||||
ENGINE_register_pkey_meths(e);
|
||||
|
@ -179,7 +179,7 @@ struct engine_st {
|
||||
const RSA_METHOD *rsa_meth;
|
||||
const DSA_METHOD *dsa_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 STORE_METHOD *store_meth;
|
||||
/* Cipher handling is via this callback */
|
||||
|
@ -302,7 +302,7 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src)
|
||||
dest->dh_meth = src->dh_meth;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
|
||||
dest->ec_meth = src->ec_meth;
|
||||
#endif
|
||||
dest->rand_meth = src->rand_meth;
|
||||
dest->store_meth = src->store_meth;
|
||||
|
@ -64,38 +64,38 @@
|
||||
static ENGINE_TABLE *dh_table = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
static void engine_unregister_all_EC_KEY(void)
|
||||
static void engine_unregister_all_EC(void)
|
||||
{
|
||||
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,
|
||||
engine_unregister_all_EC_KEY, e, &dummy_nid,
|
||||
engine_unregister_all_EC, e, &dummy_nid,
|
||||
1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ENGINE_register_all_EC_KEY()
|
||||
void ENGINE_register_all_EC()
|
||||
{
|
||||
ENGINE *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,
|
||||
engine_unregister_all_EC_KEY, e, &dummy_nid,
|
||||
engine_unregister_all_EC, e, &dummy_nid,
|
||||
1, 1);
|
||||
return 1;
|
||||
}
|
||||
@ -105,20 +105,20 @@ int ENGINE_set_default_EC_KEY(ENGINE *e)
|
||||
* table (ie. try to get a functional reference from the tabled structural
|
||||
* references).
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_EC_KEY(void)
|
||||
ENGINE *ENGINE_get_default_EC(void)
|
||||
{
|
||||
return engine_table_select(&dh_table, dummy_nid);
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
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;
|
||||
}
|
||||
|
@ -83,8 +83,7 @@
|
||||
# include <openssl/dh.h>
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_EC
|
||||
# include <openssl/ecdh.h>
|
||||
# include <openssl/ecdsa.h>
|
||||
# include <openssl/ec.h>
|
||||
# endif
|
||||
# include <openssl/rand.h>
|
||||
# include <openssl/ui.h>
|
||||
@ -113,7 +112,7 @@ extern "C" {
|
||||
# define ENGINE_METHOD_STORE (unsigned int)0x0100
|
||||
# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200
|
||||
# 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. */
|
||||
# define ENGINE_METHOD_ALL (unsigned int)0xFFFF
|
||||
# define ENGINE_METHOD_NONE (unsigned int)0x0000
|
||||
@ -438,9 +437,9 @@ int ENGINE_register_DSA(ENGINE *e);
|
||||
void ENGINE_unregister_DSA(ENGINE *e);
|
||||
void ENGINE_register_all_DSA(void);
|
||||
|
||||
int ENGINE_register_EC_KEY(ENGINE *e);
|
||||
void ENGINE_unregister_EC_KEY(ENGINE *e);
|
||||
void ENGINE_register_all_EC_KEY(void);
|
||||
int ENGINE_register_EC(ENGINE *e);
|
||||
void ENGINE_unregister_EC(ENGINE *e);
|
||||
void ENGINE_register_all_EC(void);
|
||||
|
||||
int ENGINE_register_DH(ENGINE *e);
|
||||
void ENGINE_unregister_DH(ENGINE *e);
|
||||
@ -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_RSA(ENGINE *e, const RSA_METHOD *rsa_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_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
|
||||
int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth);
|
||||
@ -592,7 +591,7 @@ 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 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 RAND_METHOD *ENGINE_get_RAND(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,
|
||||
ENGINE *ENGINE_get_default_RSA(void);
|
||||
/* Same for the other "methods" */
|
||||
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_RAND(void);
|
||||
/*
|
||||
@ -692,7 +691,7 @@ 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_EC_KEY(ENGINE *e);
|
||||
int ENGINE_set_default_EC(ENGINE *e);
|
||||
int ENGINE_set_default_DH(ENGINE *e);
|
||||
int ENGINE_set_default_RAND(ENGINE *e);
|
||||
int ENGINE_set_default_ciphers(ENGINE *e);
|
||||
|
Loading…
Reference in New Issue
Block a user