4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Signing and MACing Functions
30 * (as defined in PKCs#11 spec section 11.11)
33 #include "metaGlobal.h"
41 meta_SignInit(CK_SESSION_HANDLE hSession
, CK_MECHANISM_PTR pMechanism
,
42 CK_OBJECT_HANDLE hKey
)
45 meta_session_t
*session
;
48 if (pMechanism
== NULL
)
49 return (CKR_ARGUMENTS_BAD
);
51 rv
= meta_handle2session(hSession
, &session
);
55 rv
= meta_handle2object(hKey
, &key
);
61 rv
= meta_operation_init(CKF_SIGN
, session
, pMechanism
, key
);
75 meta_Sign(CK_SESSION_HANDLE hSession
,
76 CK_BYTE_PTR pData
, CK_ULONG ulDataLen
,
77 CK_BYTE_PTR pSignature
, CK_ULONG_PTR pulSignatureLen
)
80 meta_session_t
*session
;
82 rv
= meta_handle2session(hSession
, &session
);
86 if (pData
== NULL
|| pulSignatureLen
== NULL
) {
87 meta_operation_cleanup(session
, CKF_SIGN
, FALSE
);
89 return (CKR_ARGUMENTS_BAD
);
92 rv
= meta_do_operation(CKF_SIGN
, MODE_SINGLE
, session
, NULL
,
93 pData
, ulDataLen
, pSignature
, pulSignatureLen
);
106 meta_SignUpdate(CK_SESSION_HANDLE hSession
,
107 CK_BYTE_PTR pPart
, CK_ULONG ulPartLen
)
110 meta_session_t
*session
;
112 rv
= meta_handle2session(hSession
, &session
);
117 meta_operation_cleanup(session
, CKF_SIGN
, FALSE
);
119 return (CKR_ARGUMENTS_BAD
);
122 rv
= meta_do_operation(CKF_SIGN
, MODE_UPDATE
, session
, NULL
,
123 pPart
, ulPartLen
, NULL
, NULL
);
136 meta_SignFinal(CK_SESSION_HANDLE hSession
, CK_BYTE_PTR pSignature
,
137 CK_ULONG_PTR pulSignatureLen
)
140 meta_session_t
*session
;
142 rv
= meta_handle2session(hSession
, &session
);
146 if (pulSignatureLen
== NULL
) {
147 meta_operation_cleanup(session
, CKF_SIGN
, FALSE
);
149 return (CKR_ARGUMENTS_BAD
);
152 rv
= meta_do_operation(CKF_SIGN
, MODE_FINAL
, session
, NULL
,
153 NULL
, 0, pSignature
, pulSignatureLen
);
161 * meta_SignRecoverInit
165 meta_SignRecoverInit(CK_SESSION_HANDLE hSession
, CK_MECHANISM_PTR pMechanism
,
166 CK_OBJECT_HANDLE hKey
)
169 meta_session_t
*session
;
172 if (pMechanism
== NULL
)
173 return (CKR_ARGUMENTS_BAD
);
175 rv
= meta_handle2session(hSession
, &session
);
179 rv
= meta_handle2object(hKey
, &key
);
185 rv
= meta_operation_init(CKF_SIGN_RECOVER
, session
, pMechanism
, key
);
199 meta_SignRecover(CK_SESSION_HANDLE hSession
, CK_BYTE_PTR pData
,
200 CK_ULONG ulDataLen
, CK_BYTE_PTR pSignature
, CK_ULONG_PTR pulSignatureLen
)
203 meta_session_t
*session
;
205 rv
= meta_handle2session(hSession
, &session
);
209 if (pData
== NULL
|| pulSignatureLen
== NULL
) {
210 meta_operation_cleanup(session
, CKF_SIGN_RECOVER
, FALSE
);
212 return (CKR_ARGUMENTS_BAD
);
215 rv
= meta_do_operation(CKF_SIGN_RECOVER
, MODE_SINGLE
, session
, NULL
,
216 pData
, ulDataLen
, pSignature
, pulSignatureLen
);