Commit 7d711cbc authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

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: default avatarRichard Levitte <levitte@openssl.org>
parent d2ad1c96
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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 */
+1 −1
Original line number Diff line number Diff line
@@ -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;
+15 −15
Original line number Diff line number Diff line
@@ -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;
}
Loading