xref: /titanic_52/usr/src/uts/common/crypto/api/kcf_object.c (revision 9b009fc1b553084f6003dcd46b171890049de0ff)
1894b2776Smcpowers /*
2894b2776Smcpowers  * CDDL HEADER START
3894b2776Smcpowers  *
4894b2776Smcpowers  * The contents of this file are subject to the terms of the
5*9b009fc1SValerie Bubb Fenwick  * Common Development and Distribution License (the "License").
6*9b009fc1SValerie Bubb Fenwick  * You may not use this file except in compliance with the License.
7894b2776Smcpowers  *
8894b2776Smcpowers  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9894b2776Smcpowers  * or http://www.opensolaris.org/os/licensing.
10894b2776Smcpowers  * See the License for the specific language governing permissions
11894b2776Smcpowers  * and limitations under the License.
12894b2776Smcpowers  *
13894b2776Smcpowers  * When distributing Covered Code, include this CDDL HEADER in each
14894b2776Smcpowers  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15894b2776Smcpowers  * If applicable, add the following below this CDDL HEADER, with the
16894b2776Smcpowers  * fields enclosed by brackets "[]" replaced with your own identifying
17894b2776Smcpowers  * information: Portions Copyright [yyyy] [name of copyright owner]
18894b2776Smcpowers  *
19894b2776Smcpowers  * CDDL HEADER END
20894b2776Smcpowers  */
21894b2776Smcpowers /*
22*9b009fc1SValerie Bubb Fenwick  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23894b2776Smcpowers  */
24894b2776Smcpowers 
25894b2776Smcpowers 
26894b2776Smcpowers #include <sys/errno.h>
27894b2776Smcpowers #include <sys/types.h>
28894b2776Smcpowers #include <sys/kmem.h>
29894b2776Smcpowers #include <sys/cmn_err.h>
30894b2776Smcpowers #include <sys/sysmacros.h>
31894b2776Smcpowers #include <sys/crypto/common.h>
32894b2776Smcpowers #include <sys/crypto/impl.h>
33894b2776Smcpowers #include <sys/crypto/api.h>
34894b2776Smcpowers #include <sys/crypto/spi.h>
35894b2776Smcpowers #include <sys/crypto/sched_impl.h>
36894b2776Smcpowers 
37894b2776Smcpowers #define	CRYPTO_OPS_OFFSET(f)		offsetof(crypto_ops_t, co_##f)
38894b2776Smcpowers #define	CRYPTO_OBJECT_OFFSET(f)		offsetof(crypto_object_ops_t, f)
39894b2776Smcpowers 
40894b2776Smcpowers int
41894b2776Smcpowers crypto_object_create(crypto_provider_t provider, crypto_session_id_t sid,
42894b2776Smcpowers     crypto_object_attribute_t *attrs, uint_t count,
43894b2776Smcpowers     crypto_object_id_t *object_handle, crypto_call_req_t *crq)
44894b2776Smcpowers {
45894b2776Smcpowers 	kcf_req_params_t params;
46894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
47894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
48894b2776Smcpowers 	int rv;
49894b2776Smcpowers 
50894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
51894b2776Smcpowers 
52894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
53894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
54894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_create),
55*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
56894b2776Smcpowers 
57894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
58894b2776Smcpowers 			return (rv);
59894b2776Smcpowers 	}
60894b2776Smcpowers 
61894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
62894b2776Smcpowers 		rv = KCF_PROV_OBJECT_CREATE(real_provider, sid,
63894b2776Smcpowers 		    attrs, count, object_handle, KCF_SWFP_RHNDL(crq));
64894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
65894b2776Smcpowers 	} else {
66894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_CREATE,
67894b2776Smcpowers 		    sid, 0, attrs, count, object_handle, 0,
68894b2776Smcpowers 		    NULL, NULL, 0, NULL);
69894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
70894b2776Smcpowers 		    &params, B_FALSE);
71894b2776Smcpowers 	}
72894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
73894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
74894b2776Smcpowers 
75894b2776Smcpowers 	return (rv);
76894b2776Smcpowers }
77894b2776Smcpowers 
78894b2776Smcpowers int
79894b2776Smcpowers crypto_object_destroy(crypto_provider_t provider, crypto_session_id_t sid,
80894b2776Smcpowers     crypto_object_id_t object_handle, crypto_call_req_t *crq)
81894b2776Smcpowers {
82894b2776Smcpowers 	kcf_req_params_t params;
83894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
84894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
85894b2776Smcpowers 	int rv;
86894b2776Smcpowers 
87894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
88894b2776Smcpowers 
89894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
90894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
91894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_destroy),
92*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
93894b2776Smcpowers 
94894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
95894b2776Smcpowers 			return (rv);
96894b2776Smcpowers 	}
97894b2776Smcpowers 
98894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
99894b2776Smcpowers 		rv = KCF_PROV_OBJECT_DESTROY(real_provider, sid,
100894b2776Smcpowers 		    object_handle, KCF_SWFP_RHNDL(crq));
101894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
102894b2776Smcpowers 	} else {
103894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_DESTROY,
104894b2776Smcpowers 		    sid, object_handle, NULL, 0, NULL, 0,
105894b2776Smcpowers 		    NULL, NULL, 0, NULL);
106894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
107894b2776Smcpowers 		    &params, B_FALSE);
108894b2776Smcpowers 	}
109894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
110894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
111894b2776Smcpowers 
112894b2776Smcpowers 	return (rv);
113894b2776Smcpowers }
114894b2776Smcpowers 
115894b2776Smcpowers int
116894b2776Smcpowers crypto_object_copy(crypto_provider_t provider, crypto_session_id_t sid,
117894b2776Smcpowers     crypto_object_id_t object_handle, crypto_object_attribute_t *attrs,
118894b2776Smcpowers     uint_t count, crypto_object_id_t *new_handle, crypto_call_req_t *crq)
119894b2776Smcpowers {
120894b2776Smcpowers 	kcf_req_params_t params;
121894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
122894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
123894b2776Smcpowers 	int rv;
124894b2776Smcpowers 
125894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
126894b2776Smcpowers 
127894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
128894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
129894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_copy),
130*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
131894b2776Smcpowers 
132894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
133894b2776Smcpowers 			return (rv);
134894b2776Smcpowers 	}
135894b2776Smcpowers 
136894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
137894b2776Smcpowers 		rv = KCF_PROV_OBJECT_COPY(real_provider, sid,
138894b2776Smcpowers 		    object_handle, attrs, count, new_handle,
139894b2776Smcpowers 		    KCF_SWFP_RHNDL(crq));
140894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
141894b2776Smcpowers 	} else {
142894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_COPY,
143894b2776Smcpowers 		    sid, object_handle, attrs, count,
144894b2776Smcpowers 		    new_handle, 0, NULL, NULL, 0, NULL);
145894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
146894b2776Smcpowers 		    &params, B_FALSE);
147894b2776Smcpowers 	}
148894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
149894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
150894b2776Smcpowers 
151894b2776Smcpowers 	return (rv);
152894b2776Smcpowers }
153894b2776Smcpowers 
154894b2776Smcpowers int
155894b2776Smcpowers crypto_object_get_attribute_value(crypto_provider_t provider,
156894b2776Smcpowers     crypto_session_id_t sid, crypto_object_id_t object_handle,
157894b2776Smcpowers     crypto_object_attribute_t *attrs, uint_t count, crypto_call_req_t *crq)
158894b2776Smcpowers {
159894b2776Smcpowers 	kcf_req_params_t params;
160894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
161894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
162894b2776Smcpowers 	int rv;
163894b2776Smcpowers 
164894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
165894b2776Smcpowers 
166894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
167894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
168894b2776Smcpowers 		    object_ops),
169894b2776Smcpowers 		    CRYPTO_OBJECT_OFFSET(object_get_attribute_value),
170*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
171894b2776Smcpowers 
172894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
173894b2776Smcpowers 			return (rv);
174894b2776Smcpowers 	}
175894b2776Smcpowers 
176894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
177894b2776Smcpowers 		rv = KCF_PROV_OBJECT_GET_ATTRIBUTE_VALUE(real_provider,
178894b2776Smcpowers 		    sid, object_handle, attrs, count, KCF_SWFP_RHNDL(crq));
179894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
180894b2776Smcpowers 	} else {
181894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params,
182894b2776Smcpowers 		    KCF_OP_OBJECT_GET_ATTRIBUTE_VALUE, sid, object_handle,
183894b2776Smcpowers 		    attrs, count, NULL, 0, NULL, NULL, 0, NULL);
184894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
185894b2776Smcpowers 		    &params, B_FALSE);
186894b2776Smcpowers 	}
187894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
188894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
189894b2776Smcpowers 
190894b2776Smcpowers 	return (rv);
191894b2776Smcpowers }
192894b2776Smcpowers 
193894b2776Smcpowers int
194894b2776Smcpowers crypto_object_set_attribute_value(crypto_provider_t provider,
195894b2776Smcpowers     crypto_session_id_t sid, crypto_object_id_t object_handle,
196894b2776Smcpowers     crypto_object_attribute_t *attrs, uint_t count, crypto_call_req_t *crq)
197894b2776Smcpowers {
198894b2776Smcpowers 	kcf_req_params_t params;
199894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
200894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
201894b2776Smcpowers 	int rv;
202894b2776Smcpowers 
203894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
204894b2776Smcpowers 
205894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
206894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
207894b2776Smcpowers 		    object_ops),
208894b2776Smcpowers 		    CRYPTO_OBJECT_OFFSET(object_set_attribute_value),
209*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
210894b2776Smcpowers 
211894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
212894b2776Smcpowers 			return (rv);
213894b2776Smcpowers 	}
214894b2776Smcpowers 
215894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
216894b2776Smcpowers 		rv = KCF_PROV_OBJECT_SET_ATTRIBUTE_VALUE(real_provider,
217894b2776Smcpowers 		    sid, object_handle, attrs, count, KCF_SWFP_RHNDL(crq));
218894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
219894b2776Smcpowers 	} else {
220894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params,
221894b2776Smcpowers 		    KCF_OP_OBJECT_SET_ATTRIBUTE_VALUE, sid, object_handle,
222894b2776Smcpowers 		    attrs, count, NULL, 0, NULL, NULL, 0, NULL);
223894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
224894b2776Smcpowers 		    &params, B_FALSE);
225894b2776Smcpowers 	}
226894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
227894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
228894b2776Smcpowers 
229894b2776Smcpowers 	return (rv);
230894b2776Smcpowers }
231894b2776Smcpowers 
232894b2776Smcpowers int
233894b2776Smcpowers crypto_object_get_size(crypto_provider_t provider, crypto_session_id_t sid,
234894b2776Smcpowers     crypto_object_id_t object_handle, size_t *size, crypto_call_req_t *crq)
235894b2776Smcpowers {
236894b2776Smcpowers 	kcf_req_params_t params;
237894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
238894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
239894b2776Smcpowers 	int rv;
240894b2776Smcpowers 
241894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
242894b2776Smcpowers 
243894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
244894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
245894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_get_size),
246*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
247894b2776Smcpowers 
248894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
249894b2776Smcpowers 			return (rv);
250894b2776Smcpowers 
251894b2776Smcpowers 	}
252894b2776Smcpowers 
253894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
254894b2776Smcpowers 		rv = KCF_PROV_OBJECT_GET_SIZE(real_provider,
255894b2776Smcpowers 		    sid, object_handle, size, KCF_SWFP_RHNDL(crq));
256894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
257894b2776Smcpowers 	} else {
258894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_GET_SIZE, sid,
259894b2776Smcpowers 		    object_handle, NULL, 0, NULL, size, NULL, NULL, 0, NULL);
260894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
261894b2776Smcpowers 		    &params, B_FALSE);
262894b2776Smcpowers 	}
263894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
264894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
265894b2776Smcpowers 
266894b2776Smcpowers 	return (rv);
267894b2776Smcpowers }
268894b2776Smcpowers 
269894b2776Smcpowers int
270894b2776Smcpowers crypto_object_find_init(crypto_provider_t provider, crypto_session_id_t sid,
271894b2776Smcpowers     crypto_object_attribute_t *attrs, uint_t count, void **cookie,
272894b2776Smcpowers     crypto_call_req_t *crq)
273894b2776Smcpowers {
274894b2776Smcpowers 	kcf_req_params_t params;
275894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
276894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
277894b2776Smcpowers 	int rv;
278894b2776Smcpowers 
279894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
280894b2776Smcpowers 
281894b2776Smcpowers 	if (cookie == NULL) {
282894b2776Smcpowers 		return (CRYPTO_ARGUMENTS_BAD);
283894b2776Smcpowers 	}
284894b2776Smcpowers 
285894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
286894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
287894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_find_init),
288*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
289894b2776Smcpowers 
290894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
291894b2776Smcpowers 			return (rv);
292894b2776Smcpowers 	}
293894b2776Smcpowers 
294894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
295894b2776Smcpowers 		rv = KCF_PROV_OBJECT_FIND_INIT(real_provider,
296894b2776Smcpowers 		    sid, attrs, count, cookie, KCF_SWFP_RHNDL(crq));
297894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
298894b2776Smcpowers 	} else {
299894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_FIND_INIT,
300894b2776Smcpowers 		    sid, 0, attrs, count, NULL, 0, cookie, NULL, 0, NULL);
301894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
302894b2776Smcpowers 		    &params, B_FALSE);
303894b2776Smcpowers 	}
304894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
305894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
306894b2776Smcpowers 
307894b2776Smcpowers 	return (rv);
308894b2776Smcpowers }
309894b2776Smcpowers 
310894b2776Smcpowers int
311894b2776Smcpowers crypto_object_find_final(crypto_provider_t provider, void *cookie,
312894b2776Smcpowers     crypto_call_req_t *crq)
313894b2776Smcpowers {
314894b2776Smcpowers 	kcf_req_params_t params;
315894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
316894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
317894b2776Smcpowers 	int rv;
318894b2776Smcpowers 
319894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
320894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
321894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_find_final),
322*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
323894b2776Smcpowers 
324894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
325894b2776Smcpowers 			return (rv);
326894b2776Smcpowers 	}
327894b2776Smcpowers 
328894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
329894b2776Smcpowers 		rv = KCF_PROV_OBJECT_FIND_FINAL(real_provider,
330894b2776Smcpowers 		    cookie, KCF_SWFP_RHNDL(crq));
331894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
332894b2776Smcpowers 	} else {
333894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_FIND_FINAL,
334894b2776Smcpowers 		    0, 0, NULL, 0, NULL, 0, NULL, cookie, 0, NULL);
335894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, NULL, &params,
336894b2776Smcpowers 		    B_FALSE);
337894b2776Smcpowers 	}
338894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
339894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
340894b2776Smcpowers 
341894b2776Smcpowers 	return (rv);
342894b2776Smcpowers }
343894b2776Smcpowers 
344894b2776Smcpowers int
345894b2776Smcpowers crypto_object_find(crypto_provider_t provider, void *cookie,
346894b2776Smcpowers     crypto_object_id_t *handles, uint_t *count, uint_t max_count,
347894b2776Smcpowers     crypto_call_req_t *crq)
348894b2776Smcpowers {
349894b2776Smcpowers 	kcf_req_params_t params;
350894b2776Smcpowers 	kcf_provider_desc_t *pd = provider;
351894b2776Smcpowers 	kcf_provider_desc_t *real_provider = pd;
352894b2776Smcpowers 	int rv;
353894b2776Smcpowers 
354894b2776Smcpowers 	ASSERT(KCF_PROV_REFHELD(pd));
355894b2776Smcpowers 
356894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) {
357894b2776Smcpowers 		rv = kcf_get_hardware_provider_nomech(CRYPTO_OPS_OFFSET(
358894b2776Smcpowers 		    object_ops), CRYPTO_OBJECT_OFFSET(object_find),
359*9b009fc1SValerie Bubb Fenwick 		    pd, &real_provider);
360894b2776Smcpowers 
361894b2776Smcpowers 		if (rv != CRYPTO_SUCCESS)
362894b2776Smcpowers 			return (rv);
363894b2776Smcpowers 	}
364894b2776Smcpowers 
365894b2776Smcpowers 	if (CHECK_FASTPATH(crq, real_provider)) {
366894b2776Smcpowers 		rv = KCF_PROV_OBJECT_FIND(real_provider, cookie, handles,
367894b2776Smcpowers 		    max_count, count, KCF_SWFP_RHNDL(crq));
368894b2776Smcpowers 		KCF_PROV_INCRSTATS(pd, rv);
369894b2776Smcpowers 	} else {
370894b2776Smcpowers 		KCF_WRAP_OBJECT_OPS_PARAMS(&params, KCF_OP_OBJECT_FIND, 0,
371894b2776Smcpowers 		    0, NULL, 0, handles, 0, NULL, cookie, max_count, count);
372894b2776Smcpowers 		rv = kcf_submit_request(real_provider, NULL, crq,
373894b2776Smcpowers 		    &params, B_FALSE);
374894b2776Smcpowers 	}
375894b2776Smcpowers 	if (pd->pd_prov_type == CRYPTO_LOGICAL_PROVIDER)
376894b2776Smcpowers 		KCF_PROV_REFRELE(real_provider);
377894b2776Smcpowers 
378894b2776Smcpowers 	return (rv);
379894b2776Smcpowers }
380