dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / pkcs11 / libpkcs11 / common / pkcs11Object.c
blob8347f7c3623ffa68e2a9011e3ea936d4f8f8792f
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <security/cryptoki.h>
30 #include "pkcs11Global.h"
31 #include "pkcs11Session.h"
32 #include "pkcs11Slot.h"
35 * C_CreateObject is a pure wrapper to the underlying provider.
36 * The only argument checked is whether or not hSession is valid.
38 CK_RV
39 C_CreateObject(CK_SESSION_HANDLE hSession,
40 CK_ATTRIBUTE_PTR pTemplate,
41 CK_ULONG ulCount,
42 CK_OBJECT_HANDLE_PTR phObject)
45 CK_RV rv;
46 pkcs11_session_t *sessp;
48 /* Check for a fastpath */
49 if (purefastpath || policyfastpath) {
50 return (fast_funcs->C_CreateObject(hSession, pTemplate,
51 ulCount, phObject));
54 if (!pkcs11_initialized) {
55 return (CKR_CRYPTOKI_NOT_INITIALIZED);
58 /* Obtain the session pointer */
59 HANDLE2SESSION(hSession, sessp, rv);
61 if (rv != CKR_OK) {
62 return (rv);
65 /* Pass data to the provider */
66 rv = FUNCLIST(sessp->se_slotid)->C_CreateObject(sessp->se_handle,
67 pTemplate, ulCount, phObject);
69 /* Present consistent interface to the application */
70 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
71 return (CKR_FUNCTION_FAILED);
74 return (rv);
78 * C_CopyObject is a pure wrapper to the underlying provider.
79 * The only argument checked is whether or not hSession is valid.
81 CK_RV
82 C_CopyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
83 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
84 CK_OBJECT_HANDLE_PTR phNewObject)
86 CK_RV rv;
87 pkcs11_session_t *sessp;
89 /* Check for a fastpath */
90 if (purefastpath || policyfastpath) {
91 return (fast_funcs->C_CopyObject(hSession, hObject,
92 pTemplate, ulCount, phNewObject));
95 if (!pkcs11_initialized) {
96 return (CKR_CRYPTOKI_NOT_INITIALIZED);
99 /* Obtain the session pointer */
100 HANDLE2SESSION(hSession, sessp, rv);
102 if (rv != CKR_OK) {
103 return (rv);
106 /* Pass data to the provider */
107 rv = FUNCLIST(sessp->se_slotid)->C_CopyObject(sessp->se_handle,
108 hObject, pTemplate, ulCount, phNewObject);
110 /* Present consistent interface to the application */
111 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
112 return (CKR_FUNCTION_FAILED);
115 return (rv);
119 * C_DestroyObject is a pure wrapper to the underlying provider.
120 * The only argument checked is whether or not hSession is valid.
122 CK_RV
123 C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
125 CK_RV rv;
126 pkcs11_session_t *sessp;
128 /* Check for a fastpath */
129 if (purefastpath || policyfastpath) {
130 return (fast_funcs->C_DestroyObject(hSession, hObject));
133 if (!pkcs11_initialized) {
134 return (CKR_CRYPTOKI_NOT_INITIALIZED);
137 /* Obtain the session pointer */
138 HANDLE2SESSION(hSession, sessp, rv);
140 if (rv != CKR_OK) {
141 return (rv);
144 /* Pass data to the provider */
145 rv = FUNCLIST(sessp->se_slotid)->C_DestroyObject(sessp->se_handle,
146 hObject);
148 /* Present consistent interface to the application */
149 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
150 return (CKR_FUNCTION_FAILED);
153 return (rv);
157 * C_GetAttributeValue is a pure wrapper to the underlying provider.
158 * The only argument checked is whether or not hSession is valid.
160 CK_RV
161 C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
162 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
164 CK_RV rv;
165 pkcs11_session_t *sessp;
167 /* Check for a fastpath */
168 if (purefastpath || policyfastpath) {
169 return (fast_funcs->C_GetAttributeValue(hSession, hObject,
170 pTemplate, ulCount));
173 if (!pkcs11_initialized) {
174 return (CKR_CRYPTOKI_NOT_INITIALIZED);
177 /* Obtain the session pointer */
178 HANDLE2SESSION(hSession, sessp, rv);
180 if (rv != CKR_OK) {
181 return (rv);
184 /* Pass data to the provider */
185 rv = FUNCLIST(sessp->se_slotid)->C_GetAttributeValue(sessp->se_handle,
186 hObject, pTemplate, ulCount);
188 /* Present consistent interface to the application */
189 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
190 return (CKR_FUNCTION_FAILED);
193 return (rv);
198 * C_SetAttributeValue is a pure wrapper to the underlying provider.
199 * The only argument checked is whether or not hSession is valid.
201 CK_RV
202 C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
203 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
205 CK_RV rv;
206 pkcs11_session_t *sessp;
208 /* Check for a fastpath */
209 if (purefastpath || policyfastpath) {
210 return (fast_funcs->C_SetAttributeValue(hSession, hObject,
211 pTemplate, ulCount));
214 if (!pkcs11_initialized) {
215 return (CKR_CRYPTOKI_NOT_INITIALIZED);
218 /* Obtain the session pointer */
219 HANDLE2SESSION(hSession, sessp, rv);
221 if (rv != CKR_OK) {
222 return (rv);
225 /* Pass data to the provider */
226 rv = FUNCLIST(sessp->se_slotid)->C_SetAttributeValue(sessp->se_handle,
227 hObject, pTemplate, ulCount);
229 /* Present consistent interface to the application */
230 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
231 return (CKR_FUNCTION_FAILED);
234 return (rv);
238 * C_GetObjectSize is a pure wrapper to the underlying provider.
239 * The only argument checked is whether or not hSession is valid.
241 CK_RV
242 C_GetObjectSize(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
243 CK_ULONG_PTR pulSize)
245 CK_RV rv;
246 pkcs11_session_t *sessp;
248 /* Check for a fastpath */
249 if (purefastpath || policyfastpath) {
250 return (fast_funcs->C_GetObjectSize(hSession, hObject,
251 pulSize));
254 if (!pkcs11_initialized) {
255 return (CKR_CRYPTOKI_NOT_INITIALIZED);
258 /* Obtain the session pointer */
259 HANDLE2SESSION(hSession, sessp, rv);
261 if (rv != CKR_OK) {
262 return (rv);
265 /* Pass data to the provider */
266 rv = FUNCLIST(sessp->se_slotid)->C_GetObjectSize(sessp->se_handle,
267 hObject, pulSize);
269 /* Present consistent interface to the application */
270 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
271 return (CKR_FUNCTION_FAILED);
274 return (rv);
278 * C_FindObjectsInit is a pure wrapper to the underlying provider.
279 * The only argument checked is whether or not hSession is valid.
281 CK_RV
282 C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
283 CK_ULONG ulCount)
285 CK_RV rv;
286 pkcs11_session_t *sessp;
288 /* Check for a fastpath */
289 if (purefastpath || policyfastpath) {
290 return (fast_funcs->C_FindObjectsInit(hSession, pTemplate,
291 ulCount));
294 if (!pkcs11_initialized) {
295 return (CKR_CRYPTOKI_NOT_INITIALIZED);
298 /* Obtain the session pointer */
299 HANDLE2SESSION(hSession, sessp, rv);
301 if (rv != CKR_OK) {
302 return (rv);
305 /* Pass data to the provider */
306 rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsInit(sessp->se_handle,
307 pTemplate, ulCount);
309 /* Present consistent interface to the application */
310 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
311 return (CKR_FUNCTION_FAILED);
314 return (rv);
318 * C_FindObjects is a pure wrapper to the underlying provider.
319 * The only argument checked is whether or not hSession is valid.
321 CK_RV
322 C_FindObjects(CK_SESSION_HANDLE hSession,
323 CK_OBJECT_HANDLE_PTR phObject,
324 CK_ULONG ulMaxObjectCount,
325 CK_ULONG_PTR pulObjectCount)
327 CK_RV rv;
328 pkcs11_session_t *sessp;
330 /* Check for a fastpath */
331 if (purefastpath || policyfastpath) {
332 return (fast_funcs->C_FindObjects(hSession, phObject,
333 ulMaxObjectCount, pulObjectCount));
336 if (!pkcs11_initialized) {
337 return (CKR_CRYPTOKI_NOT_INITIALIZED);
340 /* Obtain the session pointer */
341 HANDLE2SESSION(hSession, sessp, rv);
343 if (rv != CKR_OK) {
344 return (rv);
347 /* Pass data to the provider */
348 rv = FUNCLIST(sessp->se_slotid)->C_FindObjects(sessp->se_handle,
349 phObject, ulMaxObjectCount, pulObjectCount);
351 /* Present consistent interface to the application */
352 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
353 return (CKR_FUNCTION_FAILED);
356 return (rv);
360 * C_FindObjectsFinal is a pure wrapper to the underlying provider.
361 * The only argument checked is whether or not hSession is valid.
363 CK_RV
364 C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
366 CK_RV rv;
367 pkcs11_session_t *sessp;
369 /* Check for a fastpath */
370 if (purefastpath || policyfastpath) {
371 return (fast_funcs->C_FindObjectsFinal(hSession));
374 if (!pkcs11_initialized) {
375 return (CKR_CRYPTOKI_NOT_INITIALIZED);
378 /* Obtain the session pointer */
379 HANDLE2SESSION(hSession, sessp, rv);
381 if (rv != CKR_OK) {
382 return (rv);
385 /* Pass data to the provider */
386 rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsFinal(sessp->se_handle);
388 /* Present consistent interface to the application */
389 if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
390 return (CKR_FUNCTION_FAILED);
393 return (rv);