2016-05-17 18:52:22 +00:00
|
|
|
/*
|
2018-05-29 12:07:08 +00:00
|
|
|
* Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2015-10-19 13:38:43 +00:00
|
|
|
*
|
2016-05-17 18:52:22 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2015-10-19 13:38:43 +00:00
|
|
|
*/
|
|
|
|
|
2019-09-27 21:58:06 +00:00
|
|
|
#include "eng_local.h"
|
2015-10-19 13:38:43 +00:00
|
|
|
|
|
|
|
static ENGINE_TABLE *dh_table = NULL;
|
|
|
|
static const int dummy_nid = 1;
|
|
|
|
|
2015-10-28 12:29:43 +00:00
|
|
|
void ENGINE_unregister_EC(ENGINE *e)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
|
|
|
engine_table_unregister(&dh_table, e);
|
|
|
|
}
|
|
|
|
|
2015-10-28 12:29:43 +00:00
|
|
|
static void engine_unregister_all_EC(void)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
|
|
|
engine_table_cleanup(&dh_table);
|
|
|
|
}
|
|
|
|
|
2015-10-28 12:29:43 +00:00
|
|
|
int ENGINE_register_EC(ENGINE *e)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
2015-12-09 13:10:36 +00:00
|
|
|
if (e->ec_meth != NULL)
|
2015-10-19 13:38:43 +00:00
|
|
|
return engine_table_register(&dh_table,
|
2015-10-28 12:29:43 +00:00
|
|
|
engine_unregister_all_EC, e, &dummy_nid,
|
2015-10-19 13:38:43 +00:00
|
|
|
1, 0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-05-09 15:09:50 +00:00
|
|
|
void ENGINE_register_all_EC(void)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
|
|
|
ENGINE *e;
|
|
|
|
|
|
|
|
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
2015-10-28 12:29:43 +00:00
|
|
|
ENGINE_register_EC(e);
|
2015-10-19 13:38:43 +00:00
|
|
|
}
|
|
|
|
|
2015-10-28 12:29:43 +00:00
|
|
|
int ENGINE_set_default_EC(ENGINE *e)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
2015-12-09 13:10:36 +00:00
|
|
|
if (e->ec_meth != NULL)
|
2015-10-19 13:38:43 +00:00
|
|
|
return engine_table_register(&dh_table,
|
2015-10-28 12:29:43 +00:00
|
|
|
engine_unregister_all_EC, e, &dummy_nid,
|
2015-10-19 13:38:43 +00:00
|
|
|
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).
|
|
|
|
*/
|
2015-10-28 12:29:43 +00:00
|
|
|
ENGINE *ENGINE_get_default_EC(void)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
|
|
|
return engine_table_select(&dh_table, dummy_nid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Obtains an EC_KEY implementation from an ENGINE functional reference */
|
2015-10-28 12:29:43 +00:00
|
|
|
const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
2015-10-28 12:29:43 +00:00
|
|
|
return e->ec_meth;
|
2015-10-19 13:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sets an EC_KEY implementation in an ENGINE structure */
|
2015-10-28 12:29:43 +00:00
|
|
|
int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth)
|
2015-10-19 13:38:43 +00:00
|
|
|
{
|
2015-10-28 12:29:43 +00:00
|
|
|
e->ec_meth = ec_meth;
|
2015-10-19 13:38:43 +00:00
|
|
|
return 1;
|
|
|
|
}
|