summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine/tb_rand.c
diff options
context:
space:
mode:
authorjsing <>2014-06-10 14:56:02 +0000
committerjsing <>2014-06-10 14:56:02 +0000
commit3d34b57814cfdc90c98c015ae0dbd3c1862c83cd (patch)
treed8941695c82ed288c91b99b76a5a19ac06596dd7 /src/lib/libcrypto/engine/tb_rand.c
parent4ddb3c431a24f55e2e20d36bbcefaf3ab168082d (diff)
downloadopenbsd-3d34b57814cfdc90c98c015ae0dbd3c1862c83cd.tar.gz
openbsd-3d34b57814cfdc90c98c015ae0dbd3c1862c83cd.tar.bz2
openbsd-3d34b57814cfdc90c98c015ae0dbd3c1862c83cd.zip
KNF.
Diffstat (limited to 'src/lib/libcrypto/engine/tb_rand.c')
-rw-r--r--src/lib/libcrypto/engine/tb_rand.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/src/lib/libcrypto/engine/tb_rand.c b/src/lib/libcrypto/engine/tb_rand.c
index 3745ae7abd..b99f3baba3 100644
--- a/src/lib/libcrypto/engine/tb_rand.c
+++ b/src/lib/libcrypto/engine/tb_rand.c
@@ -6,7 +6,7 @@
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in 12 * notice, this list of conditions and the following disclaimer in
@@ -62,57 +62,65 @@
62static ENGINE_TABLE *rand_table = NULL; 62static ENGINE_TABLE *rand_table = NULL;
63static const int dummy_nid = 1; 63static const int dummy_nid = 1;
64 64
65void ENGINE_unregister_RAND(ENGINE *e) 65void
66 { 66ENGINE_unregister_RAND(ENGINE *e)
67{
67 engine_table_unregister(&rand_table, e); 68 engine_table_unregister(&rand_table, e);
68 } 69}
69 70
70static void engine_unregister_all_RAND(void) 71static void
71 { 72engine_unregister_all_RAND(void)
73{
72 engine_table_cleanup(&rand_table); 74 engine_table_cleanup(&rand_table);
73 } 75}
74 76
75int ENGINE_register_RAND(ENGINE *e) 77int
76 { 78ENGINE_register_RAND(ENGINE *e)
77 if(e->rand_meth) 79{
80 if (e->rand_meth)
78 return engine_table_register(&rand_table, 81 return engine_table_register(&rand_table,
79 engine_unregister_all_RAND, e, &dummy_nid, 1, 0); 82 engine_unregister_all_RAND, e, &dummy_nid, 1, 0);
80 return 1; 83 return 1;
81 } 84}
82 85
83void ENGINE_register_all_RAND(void) 86void
84 { 87ENGINE_register_all_RAND(void)
88{
85 ENGINE *e; 89 ENGINE *e;
86 90
87 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) 91 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
88 ENGINE_register_RAND(e); 92 ENGINE_register_RAND(e);
89 } 93}
90 94
91int ENGINE_set_default_RAND(ENGINE *e) 95int
92 { 96ENGINE_set_default_RAND(ENGINE *e)
93 if(e->rand_meth) 97{
98 if (e->rand_meth)
94 return engine_table_register(&rand_table, 99 return engine_table_register(&rand_table,
95 engine_unregister_all_RAND, e, &dummy_nid, 1, 1); 100 engine_unregister_all_RAND, e, &dummy_nid, 1, 1);
96 return 1; 101 return 1;
97 } 102}
98 103
99/* Exposed API function to get a functional reference from the implementation 104/* Exposed API function to get a functional reference from the implementation
100 * table (ie. try to get a functional reference from the tabled structural 105 * table (ie. try to get a functional reference from the tabled structural
101 * references). */ 106 * references). */
102ENGINE *ENGINE_get_default_RAND(void) 107ENGINE *
103 { 108ENGINE_get_default_RAND(void)
109{
104 return engine_table_select(&rand_table, dummy_nid); 110 return engine_table_select(&rand_table, dummy_nid);
105 } 111}
106 112
107/* Obtains an RAND implementation from an ENGINE functional reference */ 113/* Obtains an RAND implementation from an ENGINE functional reference */
108const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e) 114const RAND_METHOD *
109 { 115ENGINE_get_RAND(const ENGINE *e)
116{
110 return e->rand_meth; 117 return e->rand_meth;
111 } 118}
112 119
113/* Sets an RAND implementation in an ENGINE structure */ 120/* Sets an RAND implementation in an ENGINE structure */
114int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth) 121int
115 { 122ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth)
123{
116 e->rand_meth = rand_meth; 124 e->rand_meth = rand_meth;
117 return 1; 125 return 1;
118 } 126}