]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/engine/tb_rsa.c
Reorganize local header files
[thirdparty/openssl.git] / crypto / engine / tb_rsa.c
CommitLineData
b1322259 1/*
83cf7abf 2 * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
354c3ace 3 *
3c120f91 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
b1322259
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
354c3ace
BL
8 */
9
706457b7 10#include "eng_local.h"
354c3ace 11
b6d1e52d
GT
12static ENGINE_TABLE *rsa_table = NULL;
13static const int dummy_nid = 1;
354c3ace 14
b6d1e52d 15void ENGINE_unregister_RSA(ENGINE *e)
0f113f3e
MC
16{
17 engine_table_unregister(&rsa_table, e);
18}
354c3ace 19
6d52f260 20static void engine_unregister_all_RSA(void)
0f113f3e
MC
21{
22 engine_table_cleanup(&rsa_table);
23}
354c3ace 24
b6d1e52d 25int ENGINE_register_RSA(ENGINE *e)
0f113f3e
MC
26{
27 if (e->rsa_meth)
28 return engine_table_register(&rsa_table,
29 engine_unregister_all_RSA, e, &dummy_nid,
30 1, 0);
31 return 1;
32}
354c3ace 33
3cb7c5cf 34void ENGINE_register_all_RSA(void)
0f113f3e
MC
35{
36 ENGINE *e;
354c3ace 37
0f113f3e
MC
38 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
39 ENGINE_register_RSA(e);
40}
354c3ace 41
b6d1e52d 42int ENGINE_set_default_RSA(ENGINE *e)
0f113f3e
MC
43{
44 if (e->rsa_meth)
45 return engine_table_register(&rsa_table,
46 engine_unregister_all_RSA, e, &dummy_nid,
47 1, 1);
48 return 1;
49}
0e360199 50
0f113f3e
MC
51/*
52 * Exposed API function to get a functional reference from the implementation
b6d1e52d 53 * table (ie. try to get a functional reference from the tabled structural
0f113f3e
MC
54 * references).
55 */
b6d1e52d 56ENGINE *ENGINE_get_default_RSA(void)
0f113f3e
MC
57{
58 return engine_table_select(&rsa_table, dummy_nid);
59}
0e360199 60
b6d1e52d
GT
61/* Obtains an RSA implementation from an ENGINE functional reference */
62const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e)
0f113f3e
MC
63{
64 return e->rsa_meth;
65}
0e360199 66
b6d1e52d
GT
67/* Sets an RSA implementation in an ENGINE structure */
68int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth)
0f113f3e
MC
69{
70 e->rsa_meth = rsa_meth;
71 return 1;
72}