1e71b7053SJung-uk Kim /*
2*b077aed3SPierre Pronchery * Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved.
35c87c606SMark Murray *
4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use
5e71b7053SJung-uk Kim * this file except in compliance with the License. You can obtain a copy
6e71b7053SJung-uk Kim * in the file LICENSE in the source distribution or at
7e71b7053SJung-uk Kim * https://www.openssl.org/source/license.html
85c87c606SMark Murray */
95c87c606SMark Murray
10*b077aed3SPierre Pronchery /* We need to use some engine deprecated APIs */
11*b077aed3SPierre Pronchery #define OPENSSL_SUPPRESS_DEPRECATED
12*b077aed3SPierre Pronchery
1317f01e99SJung-uk Kim #include "eng_local.h"
145c87c606SMark Murray
155c87c606SMark Murray static ENGINE_TABLE *dsa_table = NULL;
165c87c606SMark Murray static const int dummy_nid = 1;
175c87c606SMark Murray
ENGINE_unregister_DSA(ENGINE * e)185c87c606SMark Murray void ENGINE_unregister_DSA(ENGINE *e)
195c87c606SMark Murray {
205c87c606SMark Murray engine_table_unregister(&dsa_table, e);
215c87c606SMark Murray }
225c87c606SMark Murray
engine_unregister_all_DSA(void)235c87c606SMark Murray static void engine_unregister_all_DSA(void)
245c87c606SMark Murray {
255c87c606SMark Murray engine_table_cleanup(&dsa_table);
265c87c606SMark Murray }
275c87c606SMark Murray
ENGINE_register_DSA(ENGINE * e)285c87c606SMark Murray int ENGINE_register_DSA(ENGINE *e)
295c87c606SMark Murray {
305c87c606SMark Murray if (e->dsa_meth)
315c87c606SMark Murray return engine_table_register(&dsa_table,
326f9291ceSJung-uk Kim engine_unregister_all_DSA, e, &dummy_nid,
336f9291ceSJung-uk Kim 1, 0);
345c87c606SMark Murray return 1;
355c87c606SMark Murray }
365c87c606SMark Murray
ENGINE_register_all_DSA(void)37e71b7053SJung-uk Kim void ENGINE_register_all_DSA(void)
385c87c606SMark Murray {
395c87c606SMark Murray ENGINE *e;
405c87c606SMark Murray
415c87c606SMark Murray for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
425c87c606SMark Murray ENGINE_register_DSA(e);
435c87c606SMark Murray }
445c87c606SMark Murray
ENGINE_set_default_DSA(ENGINE * e)455c87c606SMark Murray int ENGINE_set_default_DSA(ENGINE *e)
465c87c606SMark Murray {
475c87c606SMark Murray if (e->dsa_meth)
485c87c606SMark Murray return engine_table_register(&dsa_table,
496f9291ceSJung-uk Kim engine_unregister_all_DSA, e, &dummy_nid,
506f9291ceSJung-uk Kim 1, 1);
515c87c606SMark Murray return 1;
525c87c606SMark Murray }
535c87c606SMark Murray
546f9291ceSJung-uk Kim /*
556f9291ceSJung-uk Kim * Exposed API function to get a functional reference from the implementation
565c87c606SMark Murray * table (ie. try to get a functional reference from the tabled structural
576f9291ceSJung-uk Kim * references).
586f9291ceSJung-uk Kim */
ENGINE_get_default_DSA(void)595c87c606SMark Murray ENGINE *ENGINE_get_default_DSA(void)
605c87c606SMark Murray {
61*b077aed3SPierre Pronchery return ossl_engine_table_select(&dsa_table, dummy_nid,
62*b077aed3SPierre Pronchery OPENSSL_FILE, OPENSSL_LINE);
635c87c606SMark Murray }
645c87c606SMark Murray
655c87c606SMark Murray /* Obtains an DSA implementation from an ENGINE functional reference */
ENGINE_get_DSA(const ENGINE * e)665c87c606SMark Murray const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e)
675c87c606SMark Murray {
685c87c606SMark Murray return e->dsa_meth;
695c87c606SMark Murray }
705c87c606SMark Murray
715c87c606SMark Murray /* Sets an DSA implementation in an ENGINE structure */
ENGINE_set_DSA(ENGINE * e,const DSA_METHOD * dsa_meth)725c87c606SMark Murray int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth)
735c87c606SMark Murray {
745c87c606SMark Murray e->dsa_meth = dsa_meth;
755c87c606SMark Murray return 1;
765c87c606SMark Murray }
77