sl@0
|
1 |
/* crypto/store/str_meth.c -*- mode:C; c-file-style: "eay" -*- */
|
sl@0
|
2 |
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
|
sl@0
|
3 |
* project 2003.
|
sl@0
|
4 |
*/
|
sl@0
|
5 |
/* ====================================================================
|
sl@0
|
6 |
* Copyright (c) 2003 The OpenSSL Project. All rights reserved.
|
sl@0
|
7 |
*
|
sl@0
|
8 |
* Redistribution and use in source and binary forms, with or without
|
sl@0
|
9 |
* modification, are permitted provided that the following conditions
|
sl@0
|
10 |
* are met:
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* 1. Redistributions of source code must retain the above copyright
|
sl@0
|
13 |
* notice, this list of conditions and the following disclaimer.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* 2. Redistributions in binary form must reproduce the above copyright
|
sl@0
|
16 |
* notice, this list of conditions and the following disclaimer in
|
sl@0
|
17 |
* the documentation and/or other materials provided with the
|
sl@0
|
18 |
* distribution.
|
sl@0
|
19 |
*
|
sl@0
|
20 |
* 3. All advertising materials mentioning features or use of this
|
sl@0
|
21 |
* software must display the following acknowledgment:
|
sl@0
|
22 |
* "This product includes software developed by the OpenSSL Project
|
sl@0
|
23 |
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
sl@0
|
24 |
*
|
sl@0
|
25 |
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
sl@0
|
26 |
* endorse or promote products derived from this software without
|
sl@0
|
27 |
* prior written permission. For written permission, please contact
|
sl@0
|
28 |
* openssl-core@openssl.org.
|
sl@0
|
29 |
*
|
sl@0
|
30 |
* 5. Products derived from this software may not be called "OpenSSL"
|
sl@0
|
31 |
* nor may "OpenSSL" appear in their names without prior written
|
sl@0
|
32 |
* permission of the OpenSSL Project.
|
sl@0
|
33 |
*
|
sl@0
|
34 |
* 6. Redistributions of any form whatsoever must retain the following
|
sl@0
|
35 |
* acknowledgment:
|
sl@0
|
36 |
* "This product includes software developed by the OpenSSL Project
|
sl@0
|
37 |
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
sl@0
|
38 |
*
|
sl@0
|
39 |
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
sl@0
|
40 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
sl@0
|
41 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
sl@0
|
42 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
sl@0
|
43 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
sl@0
|
44 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
sl@0
|
45 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
sl@0
|
46 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
sl@0
|
47 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
sl@0
|
48 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
sl@0
|
49 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
sl@0
|
50 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
sl@0
|
51 |
* ====================================================================
|
sl@0
|
52 |
*
|
sl@0
|
53 |
* This product includes cryptographic software written by Eric Young
|
sl@0
|
54 |
* (eay@cryptsoft.com). This product includes software written by Tim
|
sl@0
|
55 |
* Hudson (tjh@cryptsoft.com).
|
sl@0
|
56 |
*
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
|
sl@0
|
59 |
#include <string.h>
|
sl@0
|
60 |
#include <openssl/buffer.h>
|
sl@0
|
61 |
#include "str_locl.h"
|
sl@0
|
62 |
|
sl@0
|
63 |
EXPORT_C STORE_METHOD *STORE_create_method(char *name)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
STORE_METHOD *store_method = (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD));
|
sl@0
|
66 |
|
sl@0
|
67 |
if (store_method)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
memset(store_method, 0, sizeof(*store_method));
|
sl@0
|
70 |
store_method->name = BUF_strdup(name);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
return store_method;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
|
sl@0
|
76 |
(that is, it hasn't been allocated using STORE_create_method(), you deserve
|
sl@0
|
77 |
anything Murphy can throw at you and more! You have been warned. */
|
sl@0
|
78 |
EXPORT_C void STORE_destroy_method(STORE_METHOD *store_method)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
if (!store_method) return;
|
sl@0
|
81 |
OPENSSL_free(store_method->name);
|
sl@0
|
82 |
store_method->name = NULL;
|
sl@0
|
83 |
OPENSSL_free(store_method);
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
EXPORT_C int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
sm->init = init_f;
|
sl@0
|
89 |
return 1;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
EXPORT_C int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
sm->clean = clean_f;
|
sl@0
|
95 |
return 1;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
EXPORT_C int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
sm->generate_object = generate_f;
|
sl@0
|
101 |
return 1;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
EXPORT_C int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
sm->get_object = get_f;
|
sl@0
|
107 |
return 1;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
EXPORT_C int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
sm->store_object = store_f;
|
sl@0
|
113 |
return 1;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
EXPORT_C int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
sm->modify_object = modify_f;
|
sl@0
|
119 |
return 1;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
EXPORT_C int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
sm->revoke_object = revoke_f;
|
sl@0
|
125 |
return 1;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
EXPORT_C int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
sm->delete_object = delete_f;
|
sl@0
|
131 |
return 1;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
EXPORT_C int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
sm->list_object_start = list_start_f;
|
sl@0
|
137 |
return 1;
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
EXPORT_C int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
sm->list_object_next = list_next_f;
|
sl@0
|
143 |
return 1;
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
EXPORT_C int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
sm->list_object_end = list_end_f;
|
sl@0
|
149 |
return 1;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
EXPORT_C int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
sm->update_store = update_f;
|
sl@0
|
155 |
return 1;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
|
sl@0
|
158 |
EXPORT_C int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
sm->lock_store = lock_f;
|
sl@0
|
161 |
return 1;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
EXPORT_C int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
sm->unlock_store = unlock_f;
|
sl@0
|
167 |
return 1;
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
EXPORT_C int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
sm->ctrl = ctrl_f;
|
sl@0
|
173 |
return 1;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
EXPORT_C STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm)
|
sl@0
|
177 |
{
|
sl@0
|
178 |
return sm->init;
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
EXPORT_C STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
return sm->clean;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
EXPORT_C STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
return sm->generate_object;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
EXPORT_C STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm)
|
sl@0
|
192 |
{
|
sl@0
|
193 |
return sm->get_object;
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
EXPORT_C STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
return sm->store_object;
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
EXPORT_C STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
return sm->modify_object;
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
EXPORT_C STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
return sm->revoke_object;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
EXPORT_C STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
return sm->delete_object;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
EXPORT_C STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
return sm->list_object_start;
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
EXPORT_C STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm)
|
sl@0
|
222 |
{
|
sl@0
|
223 |
return sm->list_object_next;
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
EXPORT_C STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
return sm->list_object_end;
|
sl@0
|
229 |
}
|
sl@0
|
230 |
|
sl@0
|
231 |
EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
return sm->update_store;
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
return sm->lock_store;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
return sm->unlock_store;
|
sl@0
|
244 |
}
|
sl@0
|
245 |
|
sl@0
|
246 |
EXPORT_C STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
return sm->ctrl;
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|