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
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]
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.
39 C_CreateObject(CK_SESSION_HANDLE hSession
,
40 CK_ATTRIBUTE_PTR pTemplate
,
42 CK_OBJECT_HANDLE_PTR phObject
)
46 pkcs11_session_t
*sessp
;
48 /* Check for a fastpath */
49 if (purefastpath
|| policyfastpath
) {
50 return (fast_funcs
->C_CreateObject(hSession
, pTemplate
,
54 if (!pkcs11_initialized
) {
55 return (CKR_CRYPTOKI_NOT_INITIALIZED
);
58 /* Obtain the session pointer */
59 HANDLE2SESSION(hSession
, sessp
, 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
);
78 * C_CopyObject is a pure wrapper to the underlying provider.
79 * The only argument checked is whether or not hSession is valid.
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
)
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
);
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
);
119 * C_DestroyObject is a pure wrapper to the underlying provider.
120 * The only argument checked is whether or not hSession is valid.
123 C_DestroyObject(CK_SESSION_HANDLE hSession
, CK_OBJECT_HANDLE hObject
)
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
);
144 /* Pass data to the provider */
145 rv
= FUNCLIST(sessp
->se_slotid
)->C_DestroyObject(sessp
->se_handle
,
148 /* Present consistent interface to the application */
149 if (rv
== CKR_FUNCTION_NOT_SUPPORTED
) {
150 return (CKR_FUNCTION_FAILED
);
157 * C_GetAttributeValue is a pure wrapper to the underlying provider.
158 * The only argument checked is whether or not hSession is valid.
161 C_GetAttributeValue(CK_SESSION_HANDLE hSession
, CK_OBJECT_HANDLE hObject
,
162 CK_ATTRIBUTE_PTR pTemplate
, CK_ULONG ulCount
)
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
);
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
);
198 * C_SetAttributeValue is a pure wrapper to the underlying provider.
199 * The only argument checked is whether or not hSession is valid.
202 C_SetAttributeValue(CK_SESSION_HANDLE hSession
, CK_OBJECT_HANDLE hObject
,
203 CK_ATTRIBUTE_PTR pTemplate
, CK_ULONG ulCount
)
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
);
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
);
238 * C_GetObjectSize is a pure wrapper to the underlying provider.
239 * The only argument checked is whether or not hSession is valid.
242 C_GetObjectSize(CK_SESSION_HANDLE hSession
, CK_OBJECT_HANDLE hObject
,
243 CK_ULONG_PTR pulSize
)
246 pkcs11_session_t
*sessp
;
248 /* Check for a fastpath */
249 if (purefastpath
|| policyfastpath
) {
250 return (fast_funcs
->C_GetObjectSize(hSession
, hObject
,
254 if (!pkcs11_initialized
) {
255 return (CKR_CRYPTOKI_NOT_INITIALIZED
);
258 /* Obtain the session pointer */
259 HANDLE2SESSION(hSession
, sessp
, rv
);
265 /* Pass data to the provider */
266 rv
= FUNCLIST(sessp
->se_slotid
)->C_GetObjectSize(sessp
->se_handle
,
269 /* Present consistent interface to the application */
270 if (rv
== CKR_FUNCTION_NOT_SUPPORTED
) {
271 return (CKR_FUNCTION_FAILED
);
278 * C_FindObjectsInit is a pure wrapper to the underlying provider.
279 * The only argument checked is whether or not hSession is valid.
282 C_FindObjectsInit(CK_SESSION_HANDLE hSession
, CK_ATTRIBUTE_PTR pTemplate
,
286 pkcs11_session_t
*sessp
;
288 /* Check for a fastpath */
289 if (purefastpath
|| policyfastpath
) {
290 return (fast_funcs
->C_FindObjectsInit(hSession
, pTemplate
,
294 if (!pkcs11_initialized
) {
295 return (CKR_CRYPTOKI_NOT_INITIALIZED
);
298 /* Obtain the session pointer */
299 HANDLE2SESSION(hSession
, sessp
, rv
);
305 /* Pass data to the provider */
306 rv
= FUNCLIST(sessp
->se_slotid
)->C_FindObjectsInit(sessp
->se_handle
,
309 /* Present consistent interface to the application */
310 if (rv
== CKR_FUNCTION_NOT_SUPPORTED
) {
311 return (CKR_FUNCTION_FAILED
);
318 * C_FindObjects is a pure wrapper to the underlying provider.
319 * The only argument checked is whether or not hSession is valid.
322 C_FindObjects(CK_SESSION_HANDLE hSession
,
323 CK_OBJECT_HANDLE_PTR phObject
,
324 CK_ULONG ulMaxObjectCount
,
325 CK_ULONG_PTR pulObjectCount
)
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
);
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
);
360 * C_FindObjectsFinal is a pure wrapper to the underlying provider.
361 * The only argument checked is whether or not hSession is valid.
364 C_FindObjectsFinal(CK_SESSION_HANDLE hSession
)
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
);
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
);