5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <pthread.h>
30 #include <errno.h>
31 #include <stdio.h>
32 #include <strings.h>
33 #include <sys/crypto/ioctl.h>
34 #include <security/cryptoki.h>
35 #include <security/pkcs11t.h>
36 #include "softSession.h"
37 #include "softObject.h"
38 #include "softOps.h"
39 #include "softMAC.h"
40 #include "kernelSoftCommon.h"
41
42 /*
43 * Do the operation(s) specified by opflag.
44 */
45 CK_RV
46 do_soft_digest(void **s, CK_MECHANISM_PTR pMechanism, CK_BYTE_PTR pData,
47 CK_ULONG ulDataLen, CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen,
48 int opflag)
217 rv = CKR_SIGNATURE_INVALID;
218 }
219 }
220
221 return (rv);
222 }
223
224 /*
225 * Helper routine to handle the case when the ctx is abandoned.
226 */
227 void
228 free_soft_ctx(void *s, int opflag)
229 {
230 soft_session_t *session_p;
231
232 session_p = (soft_session_t *)s;
233 if (session_p == NULL)
234 return;
235
236 if (opflag & OP_SIGN) {
237 if (session_p->sign.context == NULL)
238 return;
239 bzero(session_p->sign.context, sizeof (soft_hmac_ctx_t));
240 free(session_p->sign.context);
241 session_p->sign.context = NULL;
242 session_p->sign.flags = 0;
243 } else if (opflag & OP_VERIFY) {
244 if (session_p->verify.context == NULL)
245 return;
246 bzero(session_p->verify.context, sizeof (soft_hmac_ctx_t));
247 free(session_p->verify.context);
248 session_p->verify.context = NULL;
249 session_p->verify.flags = 0;
250 } else {
251 if (session_p->digest.context == NULL)
252 return;
253 free(session_p->digest.context);
254 session_p->digest.context = NULL;
255 session_p->digest.flags = 0;
256 }
257 }
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright (c) 2018, Joyent, Inc.
26 */
27
28 #include <pthread.h>
29 #include <errno.h>
30 #include <stdio.h>
31 #include <strings.h>
32 #include <sys/crypto/ioctl.h>
33 #include <security/cryptoki.h>
34 #include <security/pkcs11t.h>
35 #include "softSession.h"
36 #include "softObject.h"
37 #include "softOps.h"
38 #include "softMAC.h"
39 #include "kernelSoftCommon.h"
40
41 /*
42 * Do the operation(s) specified by opflag.
43 */
44 CK_RV
45 do_soft_digest(void **s, CK_MECHANISM_PTR pMechanism, CK_BYTE_PTR pData,
46 CK_ULONG ulDataLen, CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen,
47 int opflag)
216 rv = CKR_SIGNATURE_INVALID;
217 }
218 }
219
220 return (rv);
221 }
222
223 /*
224 * Helper routine to handle the case when the ctx is abandoned.
225 */
226 void
227 free_soft_ctx(void *s, int opflag)
228 {
229 soft_session_t *session_p;
230
231 session_p = (soft_session_t *)s;
232 if (session_p == NULL)
233 return;
234
235 if (opflag & OP_SIGN) {
236 freezero(session_p->sign.context,
237 sizeof (soft_hmac_ctx_t));
238 session_p->sign.context = NULL;
239 session_p->sign.flags = 0;
240 } else if (opflag & OP_VERIFY) {
241 freezero(session_p->verify.context,
242 sizeof (soft_hmac_ctx_t));
243 session_p->verify.context = NULL;
244 session_p->verify.flags = 0;
245 } else {
246 free(session_p->digest.context);
247 session_p->digest.context = NULL;
248 session_p->digest.flags = 0;
249 }
250 }
|