VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1l/crypto/engine/tb_rand.c@ 91772

Last change on this file since 91772 was 91772, checked in by vboxsync, 3 years ago

openssl-1.1.1l: Applied and adjusted our OpenSSL changes to 1.1.1l. bugref:10126

File size: 1.8 KB
Line 
1/*
2 * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (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#include "eng_local.h"
11
12static ENGINE_TABLE *rand_table = NULL;
13static const int dummy_nid = 1;
14
15void ENGINE_unregister_RAND(ENGINE *e)
16{
17 engine_table_unregister(&rand_table, e);
18}
19
20static void engine_unregister_all_RAND(void)
21{
22 engine_table_cleanup(&rand_table);
23}
24
25int ENGINE_register_RAND(ENGINE *e)
26{
27 if (e->rand_meth)
28 return engine_table_register(&rand_table,
29 engine_unregister_all_RAND, e,
30 &dummy_nid, 1, 0);
31 return 1;
32}
33
34void ENGINE_register_all_RAND(void)
35{
36 ENGINE *e;
37
38 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
39 ENGINE_register_RAND(e);
40}
41
42int ENGINE_set_default_RAND(ENGINE *e)
43{
44 if (e->rand_meth)
45 return engine_table_register(&rand_table,
46 engine_unregister_all_RAND, e,
47 &dummy_nid, 1, 1);
48 return 1;
49}
50
51/*
52 * Exposed API function to get a functional reference from the implementation
53 * table (ie. try to get a functional reference from the tabled structural
54 * references).
55 */
56ENGINE *ENGINE_get_default_RAND(void)
57{
58 return engine_table_select(&rand_table, dummy_nid);
59}
60
61/* Obtains an RAND implementation from an ENGINE functional reference */
62const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e)
63{
64 return e->rand_meth;
65}
66
67/* Sets an RAND implementation in an ENGINE structure */
68int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth)
69{
70 e->rand_meth = rand_meth;
71 return 1;
72}
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