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 * Functions for Verifying Signatures and MACS
30 * (as defined in PKCS#11 spec section 11.13)
33 #include "metaGlobal.h"
41 meta_VerifyInit(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_VERIFY
, session
, pMechanism
, key
);
75 meta_Verify(CK_SESSION_HANDLE hSession
, CK_BYTE_PTR pData
, CK_ULONG ulDataLen
,
76 CK_BYTE_PTR pSignature
, CK_ULONG ulSignatureLen
)
79 meta_session_t
*session
;
81 rv
= meta_handle2session(hSession
, &session
);
85 /* Note: unlike other ops, both buffers are inputs, and required. */
86 if (pData
== NULL
|| pSignature
== NULL
) {
87 meta_operation_cleanup(session
, CKF_VERIFY
, FALSE
);
89 return (CKR_ARGUMENTS_BAD
);
92 rv
= meta_do_operation(CKF_VERIFY
, MODE_SINGLE
, session
, NULL
,
93 pData
, ulDataLen
, pSignature
, &ulSignatureLen
);
106 meta_VerifyUpdate(CK_SESSION_HANDLE hSession
, CK_BYTE_PTR pPart
,
110 meta_session_t
*session
;
112 rv
= meta_handle2session(hSession
, &session
);
117 meta_operation_cleanup(session
, CKF_VERIFY
, FALSE
);
119 return (CKR_ARGUMENTS_BAD
);
122 rv
= meta_do_operation(CKF_VERIFY
, MODE_UPDATE
, session
, NULL
,
123 pPart
, ulPartLen
, NULL
, NULL
);
136 meta_VerifyFinal(CK_SESSION_HANDLE hSession
, CK_BYTE_PTR pSignature
,
137 CK_ULONG ulSignatureLen
)
140 meta_session_t
*session
;
142 rv
= meta_handle2session(hSession
, &session
);
147 * Unlike other ops the buffer is an input. Allow NULL if there's
150 if (pSignature
== NULL
&& ulSignatureLen
!= 0) {
151 meta_operation_cleanup(session
, CKF_VERIFY
, FALSE
);
153 return (CKR_ARGUMENTS_BAD
);
156 rv
= meta_do_operation(CKF_VERIFY
, MODE_FINAL
, session
, NULL
,
157 pSignature
, ulSignatureLen
, NULL
, NULL
);
166 * meta_VerifyRecoverInit
170 meta_VerifyRecoverInit(CK_SESSION_HANDLE hSession
, CK_MECHANISM_PTR pMechanism
,
171 CK_OBJECT_HANDLE hKey
)
174 meta_session_t
*session
;
177 if (pMechanism
== NULL
)
178 return (CKR_ARGUMENTS_BAD
);
180 rv
= meta_handle2session(hSession
, &session
);
184 rv
= meta_handle2object(hKey
, &key
);
190 rv
= meta_operation_init(CKF_VERIFY_RECOVER
, session
, pMechanism
, key
);
204 meta_VerifyRecover(CK_SESSION_HANDLE hSession
, CK_BYTE_PTR pSignature
,
205 CK_ULONG ulSignatureLen
, CK_BYTE_PTR pData
, CK_ULONG_PTR pulDataLen
)
208 meta_session_t
*session
;
210 rv
= meta_handle2session(hSession
, &session
);
214 if (pSignature
== NULL
|| pulDataLen
== NULL
) {
215 meta_operation_cleanup(session
, CKF_VERIFY_RECOVER
, FALSE
);
217 return (CKR_ARGUMENTS_BAD
);
220 rv
= meta_do_operation(CKF_VERIFY_RECOVER
, MODE_SINGLE
, session
, NULL
,
221 pSignature
, ulSignatureLen
, pData
, pulDataLen
);