summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine/tb_digest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/engine/tb_digest.c')
-rw-r--r--src/lib/libcrypto/engine/tb_digest.c97
1 files changed, 52 insertions, 45 deletions
diff --git a/src/lib/libcrypto/engine/tb_digest.c b/src/lib/libcrypto/engine/tb_digest.c
index d1bb90aedd..6a7167e071 100644
--- a/src/lib/libcrypto/engine/tb_digest.c
+++ b/src/lib/libcrypto/engine/tb_digest.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
@@ -61,83 +61,90 @@
61 61
62static ENGINE_TABLE *digest_table = NULL; 62static ENGINE_TABLE *digest_table = NULL;
63 63
64void ENGINE_unregister_digests(ENGINE *e) 64void
65 { 65ENGINE_unregister_digests(ENGINE *e)
66{
66 engine_table_unregister(&digest_table, e); 67 engine_table_unregister(&digest_table, e);
67 } 68}
68 69
69static void engine_unregister_all_digests(void) 70static void
70 { 71engine_unregister_all_digests(void)
72{
71 engine_table_cleanup(&digest_table); 73 engine_table_cleanup(&digest_table);
72 } 74}
73 75
74int ENGINE_register_digests(ENGINE *e) 76int
75 { 77ENGINE_register_digests(ENGINE *e)
76 if(e->digests) 78{
77 { 79 if (e->digests) {
78 const int *nids; 80 const int *nids;
79 int num_nids = e->digests(e, NULL, &nids, 0); 81 int num_nids = e->digests(e, NULL, &nids, 0);
80 if(num_nids > 0) 82 if (num_nids > 0)
81 return engine_table_register(&digest_table, 83 return engine_table_register(&digest_table,
82 engine_unregister_all_digests, e, nids, 84 engine_unregister_all_digests, e, nids,
83 num_nids, 0); 85 num_nids, 0);
84 }
85 return 1;
86 } 86 }
87 return 1;
88}
87 89
88void ENGINE_register_all_digests(void) 90void
89 { 91ENGINE_register_all_digests(void)
92{
90 ENGINE *e; 93 ENGINE *e;
91 94
92 for(e=ENGINE_get_first() ; e ; e=ENGINE_get_next(e)) 95 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
93 ENGINE_register_digests(e); 96 ENGINE_register_digests(e);
94 } 97}
95 98
96int ENGINE_set_default_digests(ENGINE *e) 99int
97 { 100ENGINE_set_default_digests(ENGINE *e)
98 if(e->digests) 101{
99 { 102 if (e->digests) {
100 const int *nids; 103 const int *nids;
101 int num_nids = e->digests(e, NULL, &nids, 0); 104 int num_nids = e->digests(e, NULL, &nids, 0);
102 if(num_nids > 0) 105 if (num_nids > 0)
103 return engine_table_register(&digest_table, 106 return engine_table_register(&digest_table,
104 engine_unregister_all_digests, e, nids, 107 engine_unregister_all_digests, e, nids,
105 num_nids, 1); 108 num_nids, 1);
106 }
107 return 1;
108 } 109 }
110 return 1;
111}
109 112
110/* Exposed API function to get a functional reference from the implementation 113/* Exposed API function to get a functional reference from the implementation
111 * table (ie. try to get a functional reference from the tabled structural 114 * table (ie. try to get a functional reference from the tabled structural
112 * references) for a given digest 'nid' */ 115 * references) for a given digest 'nid' */
113ENGINE *ENGINE_get_digest_engine(int nid) 116ENGINE *
114 { 117ENGINE_get_digest_engine(int nid)
118{
115 return engine_table_select(&digest_table, nid); 119 return engine_table_select(&digest_table, nid);
116 } 120}
117 121
118/* Obtains a digest implementation from an ENGINE functional reference */ 122/* Obtains a digest implementation from an ENGINE functional reference */
119const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid) 123const EVP_MD *
120 { 124ENGINE_get_digest(ENGINE *e, int nid)
125{
121 const EVP_MD *ret; 126 const EVP_MD *ret;
122 ENGINE_DIGESTS_PTR fn = ENGINE_get_digests(e); 127 ENGINE_DIGESTS_PTR fn = ENGINE_get_digests(e);
123 if(!fn || !fn(e, &ret, NULL, nid)) 128
124 { 129 if (!fn || !fn(e, &ret, NULL, nid)) {
125 ENGINEerr(ENGINE_F_ENGINE_GET_DIGEST, 130 ENGINEerr(ENGINE_F_ENGINE_GET_DIGEST,
126 ENGINE_R_UNIMPLEMENTED_DIGEST); 131 ENGINE_R_UNIMPLEMENTED_DIGEST);
127 return NULL; 132 return NULL;
128 }
129 return ret;
130 } 133 }
134 return ret;
135}
131 136
132/* Gets the digest callback from an ENGINE structure */ 137/* Gets the digest callback from an ENGINE structure */
133ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e) 138ENGINE_DIGESTS_PTR
134 { 139ENGINE_get_digests(const ENGINE *e)
140{
135 return e->digests; 141 return e->digests;
136 } 142}
137 143
138/* Sets the digest callback in an ENGINE structure */ 144/* Sets the digest callback in an ENGINE structure */
139int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f) 145int
140 { 146ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f)
147{
141 e->digests = f; 148 e->digests = f;
142 return 1; 149 return 1;
143 } 150}