1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate #include <security/cryptoki.h>
30*7c478bd9Sstevel@tonic-gate #include "pkcs11Global.h"
31*7c478bd9Sstevel@tonic-gate #include "pkcs11Session.h"
32*7c478bd9Sstevel@tonic-gate #include "pkcs11Slot.h"
33*7c478bd9Sstevel@tonic-gate
34*7c478bd9Sstevel@tonic-gate /*
35*7c478bd9Sstevel@tonic-gate * C_CreateObject is a pure wrapper to the underlying provider.
36*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
37*7c478bd9Sstevel@tonic-gate */
38*7c478bd9Sstevel@tonic-gate CK_RV
C_CreateObject(CK_SESSION_HANDLE hSession,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phObject)39*7c478bd9Sstevel@tonic-gate C_CreateObject(CK_SESSION_HANDLE hSession,
40*7c478bd9Sstevel@tonic-gate CK_ATTRIBUTE_PTR pTemplate,
41*7c478bd9Sstevel@tonic-gate CK_ULONG ulCount,
42*7c478bd9Sstevel@tonic-gate CK_OBJECT_HANDLE_PTR phObject)
43*7c478bd9Sstevel@tonic-gate {
44*7c478bd9Sstevel@tonic-gate
45*7c478bd9Sstevel@tonic-gate CK_RV rv;
46*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
49*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
50*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_CreateObject(hSession, pTemplate,
51*7c478bd9Sstevel@tonic-gate ulCount, phObject));
52*7c478bd9Sstevel@tonic-gate }
53*7c478bd9Sstevel@tonic-gate
54*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
55*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
56*7c478bd9Sstevel@tonic-gate }
57*7c478bd9Sstevel@tonic-gate
58*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
59*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
60*7c478bd9Sstevel@tonic-gate
61*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
62*7c478bd9Sstevel@tonic-gate return (rv);
63*7c478bd9Sstevel@tonic-gate }
64*7c478bd9Sstevel@tonic-gate
65*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
66*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_CreateObject(sessp->se_handle,
67*7c478bd9Sstevel@tonic-gate pTemplate, ulCount, phObject);
68*7c478bd9Sstevel@tonic-gate
69*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
70*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
71*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
72*7c478bd9Sstevel@tonic-gate }
73*7c478bd9Sstevel@tonic-gate
74*7c478bd9Sstevel@tonic-gate return (rv);
75*7c478bd9Sstevel@tonic-gate }
76*7c478bd9Sstevel@tonic-gate
77*7c478bd9Sstevel@tonic-gate /*
78*7c478bd9Sstevel@tonic-gate * C_CopyObject is a pure wrapper to the underlying provider.
79*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
80*7c478bd9Sstevel@tonic-gate */
81*7c478bd9Sstevel@tonic-gate CK_RV
C_CopyObject(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phNewObject)82*7c478bd9Sstevel@tonic-gate C_CopyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
83*7c478bd9Sstevel@tonic-gate CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
84*7c478bd9Sstevel@tonic-gate CK_OBJECT_HANDLE_PTR phNewObject)
85*7c478bd9Sstevel@tonic-gate {
86*7c478bd9Sstevel@tonic-gate CK_RV rv;
87*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
88*7c478bd9Sstevel@tonic-gate
89*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
90*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
91*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_CopyObject(hSession, hObject,
92*7c478bd9Sstevel@tonic-gate pTemplate, ulCount, phNewObject));
93*7c478bd9Sstevel@tonic-gate }
94*7c478bd9Sstevel@tonic-gate
95*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
96*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
97*7c478bd9Sstevel@tonic-gate }
98*7c478bd9Sstevel@tonic-gate
99*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
100*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
101*7c478bd9Sstevel@tonic-gate
102*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
103*7c478bd9Sstevel@tonic-gate return (rv);
104*7c478bd9Sstevel@tonic-gate }
105*7c478bd9Sstevel@tonic-gate
106*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
107*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_CopyObject(sessp->se_handle,
108*7c478bd9Sstevel@tonic-gate hObject, pTemplate, ulCount, phNewObject);
109*7c478bd9Sstevel@tonic-gate
110*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
111*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
112*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
113*7c478bd9Sstevel@tonic-gate }
114*7c478bd9Sstevel@tonic-gate
115*7c478bd9Sstevel@tonic-gate return (rv);
116*7c478bd9Sstevel@tonic-gate }
117*7c478bd9Sstevel@tonic-gate
118*7c478bd9Sstevel@tonic-gate /*
119*7c478bd9Sstevel@tonic-gate * C_DestroyObject is a pure wrapper to the underlying provider.
120*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
121*7c478bd9Sstevel@tonic-gate */
122*7c478bd9Sstevel@tonic-gate CK_RV
C_DestroyObject(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject)123*7c478bd9Sstevel@tonic-gate C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
124*7c478bd9Sstevel@tonic-gate {
125*7c478bd9Sstevel@tonic-gate CK_RV rv;
126*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
127*7c478bd9Sstevel@tonic-gate
128*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
129*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
130*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_DestroyObject(hSession, hObject));
131*7c478bd9Sstevel@tonic-gate }
132*7c478bd9Sstevel@tonic-gate
133*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
134*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
135*7c478bd9Sstevel@tonic-gate }
136*7c478bd9Sstevel@tonic-gate
137*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
138*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
139*7c478bd9Sstevel@tonic-gate
140*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
141*7c478bd9Sstevel@tonic-gate return (rv);
142*7c478bd9Sstevel@tonic-gate }
143*7c478bd9Sstevel@tonic-gate
144*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
145*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_DestroyObject(sessp->se_handle,
146*7c478bd9Sstevel@tonic-gate hObject);
147*7c478bd9Sstevel@tonic-gate
148*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
149*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
150*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
151*7c478bd9Sstevel@tonic-gate }
152*7c478bd9Sstevel@tonic-gate
153*7c478bd9Sstevel@tonic-gate return (rv);
154*7c478bd9Sstevel@tonic-gate }
155*7c478bd9Sstevel@tonic-gate
156*7c478bd9Sstevel@tonic-gate /*
157*7c478bd9Sstevel@tonic-gate * C_GetAttributeValue is a pure wrapper to the underlying provider.
158*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
159*7c478bd9Sstevel@tonic-gate */
160*7c478bd9Sstevel@tonic-gate CK_RV
C_GetAttributeValue(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)161*7c478bd9Sstevel@tonic-gate C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
162*7c478bd9Sstevel@tonic-gate CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
163*7c478bd9Sstevel@tonic-gate {
164*7c478bd9Sstevel@tonic-gate CK_RV rv;
165*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
166*7c478bd9Sstevel@tonic-gate
167*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
168*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
169*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_GetAttributeValue(hSession, hObject,
170*7c478bd9Sstevel@tonic-gate pTemplate, ulCount));
171*7c478bd9Sstevel@tonic-gate }
172*7c478bd9Sstevel@tonic-gate
173*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
174*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
175*7c478bd9Sstevel@tonic-gate }
176*7c478bd9Sstevel@tonic-gate
177*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
178*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
179*7c478bd9Sstevel@tonic-gate
180*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
181*7c478bd9Sstevel@tonic-gate return (rv);
182*7c478bd9Sstevel@tonic-gate }
183*7c478bd9Sstevel@tonic-gate
184*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
185*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_GetAttributeValue(sessp->se_handle,
186*7c478bd9Sstevel@tonic-gate hObject, pTemplate, ulCount);
187*7c478bd9Sstevel@tonic-gate
188*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
189*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
190*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
191*7c478bd9Sstevel@tonic-gate }
192*7c478bd9Sstevel@tonic-gate
193*7c478bd9Sstevel@tonic-gate return (rv);
194*7c478bd9Sstevel@tonic-gate
195*7c478bd9Sstevel@tonic-gate }
196*7c478bd9Sstevel@tonic-gate
197*7c478bd9Sstevel@tonic-gate /*
198*7c478bd9Sstevel@tonic-gate * C_SetAttributeValue is a pure wrapper to the underlying provider.
199*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
200*7c478bd9Sstevel@tonic-gate */
201*7c478bd9Sstevel@tonic-gate CK_RV
C_SetAttributeValue(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)202*7c478bd9Sstevel@tonic-gate C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
203*7c478bd9Sstevel@tonic-gate CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
204*7c478bd9Sstevel@tonic-gate {
205*7c478bd9Sstevel@tonic-gate CK_RV rv;
206*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
207*7c478bd9Sstevel@tonic-gate
208*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
209*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
210*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_SetAttributeValue(hSession, hObject,
211*7c478bd9Sstevel@tonic-gate pTemplate, ulCount));
212*7c478bd9Sstevel@tonic-gate }
213*7c478bd9Sstevel@tonic-gate
214*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
215*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
216*7c478bd9Sstevel@tonic-gate }
217*7c478bd9Sstevel@tonic-gate
218*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
219*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
220*7c478bd9Sstevel@tonic-gate
221*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
222*7c478bd9Sstevel@tonic-gate return (rv);
223*7c478bd9Sstevel@tonic-gate }
224*7c478bd9Sstevel@tonic-gate
225*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
226*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_SetAttributeValue(sessp->se_handle,
227*7c478bd9Sstevel@tonic-gate hObject, pTemplate, ulCount);
228*7c478bd9Sstevel@tonic-gate
229*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
230*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
231*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
232*7c478bd9Sstevel@tonic-gate }
233*7c478bd9Sstevel@tonic-gate
234*7c478bd9Sstevel@tonic-gate return (rv);
235*7c478bd9Sstevel@tonic-gate }
236*7c478bd9Sstevel@tonic-gate
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate * C_GetObjectSize is a pure wrapper to the underlying provider.
239*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
240*7c478bd9Sstevel@tonic-gate */
241*7c478bd9Sstevel@tonic-gate CK_RV
C_GetObjectSize(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ULONG_PTR pulSize)242*7c478bd9Sstevel@tonic-gate C_GetObjectSize(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
243*7c478bd9Sstevel@tonic-gate CK_ULONG_PTR pulSize)
244*7c478bd9Sstevel@tonic-gate {
245*7c478bd9Sstevel@tonic-gate CK_RV rv;
246*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
247*7c478bd9Sstevel@tonic-gate
248*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
249*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
250*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_GetObjectSize(hSession, hObject,
251*7c478bd9Sstevel@tonic-gate pulSize));
252*7c478bd9Sstevel@tonic-gate }
253*7c478bd9Sstevel@tonic-gate
254*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
255*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
256*7c478bd9Sstevel@tonic-gate }
257*7c478bd9Sstevel@tonic-gate
258*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
259*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
260*7c478bd9Sstevel@tonic-gate
261*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
262*7c478bd9Sstevel@tonic-gate return (rv);
263*7c478bd9Sstevel@tonic-gate }
264*7c478bd9Sstevel@tonic-gate
265*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
266*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_GetObjectSize(sessp->se_handle,
267*7c478bd9Sstevel@tonic-gate hObject, pulSize);
268*7c478bd9Sstevel@tonic-gate
269*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
270*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
271*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
272*7c478bd9Sstevel@tonic-gate }
273*7c478bd9Sstevel@tonic-gate
274*7c478bd9Sstevel@tonic-gate return (rv);
275*7c478bd9Sstevel@tonic-gate }
276*7c478bd9Sstevel@tonic-gate
277*7c478bd9Sstevel@tonic-gate /*
278*7c478bd9Sstevel@tonic-gate * C_FindObjectsInit is a pure wrapper to the underlying provider.
279*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
280*7c478bd9Sstevel@tonic-gate */
281*7c478bd9Sstevel@tonic-gate CK_RV
C_FindObjectsInit(CK_SESSION_HANDLE hSession,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)282*7c478bd9Sstevel@tonic-gate C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
283*7c478bd9Sstevel@tonic-gate CK_ULONG ulCount)
284*7c478bd9Sstevel@tonic-gate {
285*7c478bd9Sstevel@tonic-gate CK_RV rv;
286*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
287*7c478bd9Sstevel@tonic-gate
288*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
289*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
290*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_FindObjectsInit(hSession, pTemplate,
291*7c478bd9Sstevel@tonic-gate ulCount));
292*7c478bd9Sstevel@tonic-gate }
293*7c478bd9Sstevel@tonic-gate
294*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
295*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
296*7c478bd9Sstevel@tonic-gate }
297*7c478bd9Sstevel@tonic-gate
298*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
299*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
300*7c478bd9Sstevel@tonic-gate
301*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
302*7c478bd9Sstevel@tonic-gate return (rv);
303*7c478bd9Sstevel@tonic-gate }
304*7c478bd9Sstevel@tonic-gate
305*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
306*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsInit(sessp->se_handle,
307*7c478bd9Sstevel@tonic-gate pTemplate, ulCount);
308*7c478bd9Sstevel@tonic-gate
309*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
310*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
311*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
312*7c478bd9Sstevel@tonic-gate }
313*7c478bd9Sstevel@tonic-gate
314*7c478bd9Sstevel@tonic-gate return (rv);
315*7c478bd9Sstevel@tonic-gate }
316*7c478bd9Sstevel@tonic-gate
317*7c478bd9Sstevel@tonic-gate /*
318*7c478bd9Sstevel@tonic-gate * C_FindObjects is a pure wrapper to the underlying provider.
319*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
320*7c478bd9Sstevel@tonic-gate */
321*7c478bd9Sstevel@tonic-gate CK_RV
C_FindObjects(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE_PTR phObject,CK_ULONG ulMaxObjectCount,CK_ULONG_PTR pulObjectCount)322*7c478bd9Sstevel@tonic-gate C_FindObjects(CK_SESSION_HANDLE hSession,
323*7c478bd9Sstevel@tonic-gate CK_OBJECT_HANDLE_PTR phObject,
324*7c478bd9Sstevel@tonic-gate CK_ULONG ulMaxObjectCount,
325*7c478bd9Sstevel@tonic-gate CK_ULONG_PTR pulObjectCount)
326*7c478bd9Sstevel@tonic-gate {
327*7c478bd9Sstevel@tonic-gate CK_RV rv;
328*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
329*7c478bd9Sstevel@tonic-gate
330*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
331*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
332*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_FindObjects(hSession, phObject,
333*7c478bd9Sstevel@tonic-gate ulMaxObjectCount, pulObjectCount));
334*7c478bd9Sstevel@tonic-gate }
335*7c478bd9Sstevel@tonic-gate
336*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
337*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
338*7c478bd9Sstevel@tonic-gate }
339*7c478bd9Sstevel@tonic-gate
340*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
341*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
342*7c478bd9Sstevel@tonic-gate
343*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
344*7c478bd9Sstevel@tonic-gate return (rv);
345*7c478bd9Sstevel@tonic-gate }
346*7c478bd9Sstevel@tonic-gate
347*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
348*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_FindObjects(sessp->se_handle,
349*7c478bd9Sstevel@tonic-gate phObject, ulMaxObjectCount, pulObjectCount);
350*7c478bd9Sstevel@tonic-gate
351*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
352*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
353*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
354*7c478bd9Sstevel@tonic-gate }
355*7c478bd9Sstevel@tonic-gate
356*7c478bd9Sstevel@tonic-gate return (rv);
357*7c478bd9Sstevel@tonic-gate }
358*7c478bd9Sstevel@tonic-gate
359*7c478bd9Sstevel@tonic-gate /*
360*7c478bd9Sstevel@tonic-gate * C_FindObjectsFinal is a pure wrapper to the underlying provider.
361*7c478bd9Sstevel@tonic-gate * The only argument checked is whether or not hSession is valid.
362*7c478bd9Sstevel@tonic-gate */
363*7c478bd9Sstevel@tonic-gate CK_RV
C_FindObjectsFinal(CK_SESSION_HANDLE hSession)364*7c478bd9Sstevel@tonic-gate C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
365*7c478bd9Sstevel@tonic-gate {
366*7c478bd9Sstevel@tonic-gate CK_RV rv;
367*7c478bd9Sstevel@tonic-gate pkcs11_session_t *sessp;
368*7c478bd9Sstevel@tonic-gate
369*7c478bd9Sstevel@tonic-gate /* Check for a fastpath */
370*7c478bd9Sstevel@tonic-gate if (purefastpath || policyfastpath) {
371*7c478bd9Sstevel@tonic-gate return (fast_funcs->C_FindObjectsFinal(hSession));
372*7c478bd9Sstevel@tonic-gate }
373*7c478bd9Sstevel@tonic-gate
374*7c478bd9Sstevel@tonic-gate if (!pkcs11_initialized) {
375*7c478bd9Sstevel@tonic-gate return (CKR_CRYPTOKI_NOT_INITIALIZED);
376*7c478bd9Sstevel@tonic-gate }
377*7c478bd9Sstevel@tonic-gate
378*7c478bd9Sstevel@tonic-gate /* Obtain the session pointer */
379*7c478bd9Sstevel@tonic-gate HANDLE2SESSION(hSession, sessp, rv);
380*7c478bd9Sstevel@tonic-gate
381*7c478bd9Sstevel@tonic-gate if (rv != CKR_OK) {
382*7c478bd9Sstevel@tonic-gate return (rv);
383*7c478bd9Sstevel@tonic-gate }
384*7c478bd9Sstevel@tonic-gate
385*7c478bd9Sstevel@tonic-gate /* Pass data to the provider */
386*7c478bd9Sstevel@tonic-gate rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsFinal(sessp->se_handle);
387*7c478bd9Sstevel@tonic-gate
388*7c478bd9Sstevel@tonic-gate /* Present consistent interface to the application */
389*7c478bd9Sstevel@tonic-gate if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
390*7c478bd9Sstevel@tonic-gate return (CKR_FUNCTION_FAILED);
391*7c478bd9Sstevel@tonic-gate }
392*7c478bd9Sstevel@tonic-gate
393*7c478bd9Sstevel@tonic-gate return (rv);
394*7c478bd9Sstevel@tonic-gate }
395