VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.2/crypto/engine/tb_rsa.c@ 101021

Last change on this file since 101021 was 101021, checked in by vboxsync, 15 months ago

openssl-3.1.2: Applied and adjusted our OpenSSL changes to 3.1.0. bugref:10519

File size: 1.9 KB
Line 
1/*
2 * Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
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
8 */
9
10/* We need to use some engine deprecated APIs */
11#define OPENSSL_SUPPRESS_DEPRECATED
12
13#include "eng_local.h"
14
15static ENGINE_TABLE *rsa_table = NULL;
16static const int dummy_nid = 1;
17
18void ENGINE_unregister_RSA(ENGINE *e)
19{
20 engine_table_unregister(&rsa_table, e);
21}
22
23static void engine_unregister_all_RSA(void)
24{
25 engine_table_cleanup(&rsa_table);
26}
27
28int ENGINE_register_RSA(ENGINE *e)
29{
30 if (e->rsa_meth)
31 return engine_table_register(&rsa_table,
32 engine_unregister_all_RSA, e, &dummy_nid,
33 1, 0);
34 return 1;
35}
36
37void ENGINE_register_all_RSA(void)
38{
39 ENGINE *e;
40
41 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
42 ENGINE_register_RSA(e);
43}
44
45int ENGINE_set_default_RSA(ENGINE *e)
46{
47 if (e->rsa_meth)
48 return engine_table_register(&rsa_table,
49 engine_unregister_all_RSA, e, &dummy_nid,
50 1, 1);
51 return 1;
52}
53
54/*
55 * Exposed API function to get a functional reference from the implementation
56 * table (ie. try to get a functional reference from the tabled structural
57 * references).
58 */
59ENGINE *ENGINE_get_default_RSA(void)
60{
61 return ossl_engine_table_select(&rsa_table, dummy_nid,
62 OPENSSL_FILE, OPENSSL_LINE);
63}
64
65/* Obtains an RSA implementation from an ENGINE functional reference */
66const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e)
67{
68 return e->rsa_meth;
69}
70
71/* Sets an RSA implementation in an ENGINE structure */
72int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth)
73{
74 e->rsa_meth = rsa_meth;
75 return 1;
76}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette