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