19126SWyllys.Ingersoll@Sun.COM /*
29126SWyllys.Ingersoll@Sun.COM * The Initial Developer of the Original Code is International
39126SWyllys.Ingersoll@Sun.COM * Business Machines Corporation. Portions created by IBM
49126SWyllys.Ingersoll@Sun.COM * Corporation are Copyright (C) 2005 International Business
59126SWyllys.Ingersoll@Sun.COM * Machines Corporation. All Rights Reserved.
69126SWyllys.Ingersoll@Sun.COM *
79126SWyllys.Ingersoll@Sun.COM * This program is free software; you can redistribute it and/or modify
89126SWyllys.Ingersoll@Sun.COM * it under the terms of the Common Public License as published by
99126SWyllys.Ingersoll@Sun.COM * IBM Corporation; either version 1 of the License, or (at your option)
109126SWyllys.Ingersoll@Sun.COM * any later version.
119126SWyllys.Ingersoll@Sun.COM *
129126SWyllys.Ingersoll@Sun.COM * This program is distributed in the hope that it will be useful,
139126SWyllys.Ingersoll@Sun.COM * but WITHOUT ANY WARRANTY; without even the implied warranty of
149126SWyllys.Ingersoll@Sun.COM * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
159126SWyllys.Ingersoll@Sun.COM * Common Public License for more details.
169126SWyllys.Ingersoll@Sun.COM *
179126SWyllys.Ingersoll@Sun.COM * You should have received a copy of the Common Public License
189126SWyllys.Ingersoll@Sun.COM * along with this program; if not, a copy can be viewed at
199126SWyllys.Ingersoll@Sun.COM * http://www.opensource.org/licenses/cpl1.0.php.
209126SWyllys.Ingersoll@Sun.COM */
219126SWyllys.Ingersoll@Sun.COM
229126SWyllys.Ingersoll@Sun.COM /* (C) COPYRIGHT International Business Machines Corp. 2001, 2002, 2005 */
239126SWyllys.Ingersoll@Sun.COM /*
249126SWyllys.Ingersoll@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
259126SWyllys.Ingersoll@Sun.COM * Use is subject to license terms.
269126SWyllys.Ingersoll@Sun.COM */
279126SWyllys.Ingersoll@Sun.COM
289126SWyllys.Ingersoll@Sun.COM #include <pwd.h>
299126SWyllys.Ingersoll@Sun.COM #include <grp.h>
309126SWyllys.Ingersoll@Sun.COM
319126SWyllys.Ingersoll@Sun.COM #include "tpmtok_int.h"
329126SWyllys.Ingersoll@Sun.COM #include "tpmtok_defs.h"
339126SWyllys.Ingersoll@Sun.COM
349126SWyllys.Ingersoll@Sun.COM extern pthread_rwlock_t obj_list_rw_mutex;
359126SWyllys.Ingersoll@Sun.COM
369126SWyllys.Ingersoll@Sun.COM void SC_SetFunctionList(void);
379126SWyllys.Ingersoll@Sun.COM
389126SWyllys.Ingersoll@Sun.COM struct ST_FCN_LIST function_list;
399126SWyllys.Ingersoll@Sun.COM
409126SWyllys.Ingersoll@Sun.COM int debugfile = 0;
419126SWyllys.Ingersoll@Sun.COM
429126SWyllys.Ingersoll@Sun.COM pid_t initedpid = 0; // for initialized pid
439126SWyllys.Ingersoll@Sun.COM
449126SWyllys.Ingersoll@Sun.COM CK_C_INITIALIZE_ARGS cinit_args = {NULL, NULL, NULL, NULL, 0, NULL};
459126SWyllys.Ingersoll@Sun.COM
469126SWyllys.Ingersoll@Sun.COM extern void stlogterm();
479126SWyllys.Ingersoll@Sun.COM extern void stloginit();
489126SWyllys.Ingersoll@Sun.COM extern void stlogit2(int type, char *fmt, ...);
499126SWyllys.Ingersoll@Sun.COM extern void stlogit(char *fmt, ...);
509126SWyllys.Ingersoll@Sun.COM
519126SWyllys.Ingersoll@Sun.COM CK_BBOOL
st_Initialized()529126SWyllys.Ingersoll@Sun.COM st_Initialized()
539126SWyllys.Ingersoll@Sun.COM {
549126SWyllys.Ingersoll@Sun.COM return (initedpid == getpid());
559126SWyllys.Ingersoll@Sun.COM }
569126SWyllys.Ingersoll@Sun.COM
579126SWyllys.Ingersoll@Sun.COM void
Fork_Initializer(void)589126SWyllys.Ingersoll@Sun.COM Fork_Initializer(void)
599126SWyllys.Ingersoll@Sun.COM {
609126SWyllys.Ingersoll@Sun.COM stlogterm();
619126SWyllys.Ingersoll@Sun.COM stloginit(); // Initialize Logging so we can capture EVERYTHING
629126SWyllys.Ingersoll@Sun.COM
639126SWyllys.Ingersoll@Sun.COM // Force logout. This cleans out the private session and list
649126SWyllys.Ingersoll@Sun.COM // and cleans out the private object map
659126SWyllys.Ingersoll@Sun.COM (void) session_mgr_logout_all();
669126SWyllys.Ingersoll@Sun.COM
679126SWyllys.Ingersoll@Sun.COM // Clean out the public object map
689126SWyllys.Ingersoll@Sun.COM // First parm is no longer used..
699126SWyllys.Ingersoll@Sun.COM (void) object_mgr_purge_map((SESSION *)0xFFFF, PUBLIC);
709126SWyllys.Ingersoll@Sun.COM (void) object_mgr_purge_map((SESSION *)0xFFFF, PRIVATE);
719126SWyllys.Ingersoll@Sun.COM
729126SWyllys.Ingersoll@Sun.COM // This should clear the entire session list out
739126SWyllys.Ingersoll@Sun.COM (void) session_mgr_close_all_sessions();
749126SWyllys.Ingersoll@Sun.COM
759126SWyllys.Ingersoll@Sun.COM next_session_handle = 1;
769126SWyllys.Ingersoll@Sun.COM next_object_handle = 1;
779126SWyllys.Ingersoll@Sun.COM
789126SWyllys.Ingersoll@Sun.COM while (priv_token_obj_list) {
799126SWyllys.Ingersoll@Sun.COM priv_token_obj_list = dlist_remove_node(priv_token_obj_list,
809126SWyllys.Ingersoll@Sun.COM priv_token_obj_list);
819126SWyllys.Ingersoll@Sun.COM }
829126SWyllys.Ingersoll@Sun.COM
839126SWyllys.Ingersoll@Sun.COM while (publ_token_obj_list) {
849126SWyllys.Ingersoll@Sun.COM publ_token_obj_list = dlist_remove_node(publ_token_obj_list,
859126SWyllys.Ingersoll@Sun.COM publ_token_obj_list);
869126SWyllys.Ingersoll@Sun.COM }
879126SWyllys.Ingersoll@Sun.COM }
889126SWyllys.Ingersoll@Sun.COM
899126SWyllys.Ingersoll@Sun.COM #define SESSION_HANDLE sSession.sessionh
909126SWyllys.Ingersoll@Sun.COM
919126SWyllys.Ingersoll@Sun.COM #define SESS_SET \
929126SWyllys.Ingersoll@Sun.COM CK_SESSION_HANDLE hSession = sSession.sessionh;
939126SWyllys.Ingersoll@Sun.COM
949126SWyllys.Ingersoll@Sun.COM static CK_RV
validate_mechanism(CK_MECHANISM_PTR pMechanism)959126SWyllys.Ingersoll@Sun.COM validate_mechanism(CK_MECHANISM_PTR pMechanism)
969126SWyllys.Ingersoll@Sun.COM {
979126SWyllys.Ingersoll@Sun.COM CK_ULONG i;
989126SWyllys.Ingersoll@Sun.COM
999126SWyllys.Ingersoll@Sun.COM for (i = 0; i < mech_list_len; i++) {
1009126SWyllys.Ingersoll@Sun.COM if (pMechanism->mechanism == mech_list[i].mech_type) {
1019126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
1029126SWyllys.Ingersoll@Sun.COM }
1039126SWyllys.Ingersoll@Sun.COM }
1049126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
1059126SWyllys.Ingersoll@Sun.COM }
1069126SWyllys.Ingersoll@Sun.COM
1079126SWyllys.Ingersoll@Sun.COM #define VALID_MECH(p) \
1089126SWyllys.Ingersoll@Sun.COM if (validate_mechanism(p) != CKR_OK) { \
1099126SWyllys.Ingersoll@Sun.COM rc = CKR_MECHANISM_INVALID; \
1109126SWyllys.Ingersoll@Sun.COM goto done; \
1119126SWyllys.Ingersoll@Sun.COM }
1129126SWyllys.Ingersoll@Sun.COM
1139126SWyllys.Ingersoll@Sun.COM CK_RV
ST_Initialize(void * FunctionList,CK_SLOT_ID SlotNumber,unsigned char * Correlator)1149126SWyllys.Ingersoll@Sun.COM ST_Initialize(void *FunctionList,
1159126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID SlotNumber,
1169126SWyllys.Ingersoll@Sun.COM unsigned char *Correlator)
1179126SWyllys.Ingersoll@Sun.COM {
1189126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
1199126SWyllys.Ingersoll@Sun.COM struct ST_FCN_LIST *flist = (struct ST_FCN_LIST *)FunctionList;
1209126SWyllys.Ingersoll@Sun.COM TSS_HCONTEXT hContext = 0;
1219126SWyllys.Ingersoll@Sun.COM
1229126SWyllys.Ingersoll@Sun.COM stlogterm();
1239126SWyllys.Ingersoll@Sun.COM stloginit();
1249126SWyllys.Ingersoll@Sun.COM
1259126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == TRUE) {
1269126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
1279126SWyllys.Ingersoll@Sun.COM }
1289126SWyllys.Ingersoll@Sun.COM // assume that the upper API prevents multiple calls of initialize
1299126SWyllys.Ingersoll@Sun.COM // since that only happens on C_Initialize and that is the
1309126SWyllys.Ingersoll@Sun.COM // resonsibility of the upper layer..
1319126SWyllys.Ingersoll@Sun.COM initialized = FALSE;
1329126SWyllys.Ingersoll@Sun.COM
1339126SWyllys.Ingersoll@Sun.COM // check for other completing this before creating mutexes...
1349126SWyllys.Ingersoll@Sun.COM // make sure that the same process tried to to the init...
1359126SWyllys.Ingersoll@Sun.COM // thread issues should be caught up above...
1369126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == TRUE) {
1379126SWyllys.Ingersoll@Sun.COM goto done;
1389126SWyllys.Ingersoll@Sun.COM }
1399126SWyllys.Ingersoll@Sun.COM
1409126SWyllys.Ingersoll@Sun.COM Fork_Initializer();
1419126SWyllys.Ingersoll@Sun.COM
1429126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_init(&pkcs_mutex, NULL);
1439126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_init(&obj_list_mutex, NULL);
1449126SWyllys.Ingersoll@Sun.COM (void) pthread_rwlock_init(&obj_list_rw_mutex, NULL);
1459126SWyllys.Ingersoll@Sun.COM
1469126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_init(&sess_list_mutex, NULL);
1479126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_init(&login_mutex, NULL);
1489126SWyllys.Ingersoll@Sun.COM
1499126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
1509126SWyllys.Ingersoll@Sun.COM if ((rc = attach_shm()) != CKR_OK)
1519126SWyllys.Ingersoll@Sun.COM goto done;
1529126SWyllys.Ingersoll@Sun.COM
1539126SWyllys.Ingersoll@Sun.COM nv_token_data = &global_shm->nv_token_data;
1549126SWyllys.Ingersoll@Sun.COM
1559126SWyllys.Ingersoll@Sun.COM initialized = TRUE;
1569126SWyllys.Ingersoll@Sun.COM initedpid = getpid();
1579126SWyllys.Ingersoll@Sun.COM SC_SetFunctionList();
1589126SWyllys.Ingersoll@Sun.COM
159*10346Swyllys.ingersoll@sun.com if (flist != NULL)
160*10346Swyllys.ingersoll@sun.com (*flist) = function_list;
161*10346Swyllys.ingersoll@sun.com
1629126SWyllys.Ingersoll@Sun.COM /* Always call the token_specific_init function.... */
1639126SWyllys.Ingersoll@Sun.COM rc = token_specific.t_init((char *)Correlator, SlotNumber,
1649126SWyllys.Ingersoll@Sun.COM &hContext);
165*10346Swyllys.ingersoll@sun.com if (rc != 0) {
166*10346Swyllys.ingersoll@sun.com /*
167*10346Swyllys.ingersoll@sun.com * The token could not be initialized, return OK, but
168*10346Swyllys.ingersoll@sun.com * present no slots.
169*10346Swyllys.ingersoll@sun.com */
170*10346Swyllys.ingersoll@sun.com rc = CKR_OK;
1719126SWyllys.Ingersoll@Sun.COM goto done;
172*10346Swyllys.ingersoll@sun.com } else {
173*10346Swyllys.ingersoll@sun.com /* Mark the token as available */
174*10346Swyllys.ingersoll@sun.com global_shm->token_available = TRUE;
175*10346Swyllys.ingersoll@sun.com }
1769126SWyllys.Ingersoll@Sun.COM }
1779126SWyllys.Ingersoll@Sun.COM
1789126SWyllys.Ingersoll@Sun.COM rc = load_token_data(hContext, nv_token_data);
1799126SWyllys.Ingersoll@Sun.COM
1809126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
1819126SWyllys.Ingersoll@Sun.COM goto done;
1829126SWyllys.Ingersoll@Sun.COM }
1839126SWyllys.Ingersoll@Sun.COM
1849126SWyllys.Ingersoll@Sun.COM rc = load_public_token_objects();
1859126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
1869126SWyllys.Ingersoll@Sun.COM goto done;
1879126SWyllys.Ingersoll@Sun.COM
1889126SWyllys.Ingersoll@Sun.COM (void) XProcLock(xproclock);
1899126SWyllys.Ingersoll@Sun.COM global_shm->publ_loaded = TRUE;
1909126SWyllys.Ingersoll@Sun.COM (void) XProcUnLock(xproclock);
1919126SWyllys.Ingersoll@Sun.COM
1929126SWyllys.Ingersoll@Sun.COM init_slot_info(nv_token_data);
1939126SWyllys.Ingersoll@Sun.COM
1949126SWyllys.Ingersoll@Sun.COM done:
1959126SWyllys.Ingersoll@Sun.COM if (hContext)
1969126SWyllys.Ingersoll@Sun.COM Tspi_Context_Close(hContext);
1979126SWyllys.Ingersoll@Sun.COM return (rc);
1989126SWyllys.Ingersoll@Sun.COM }
1999126SWyllys.Ingersoll@Sun.COM
2009126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
2019126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Finalize(void * argptr)2029126SWyllys.Ingersoll@Sun.COM SC_Finalize(void *argptr)
2039126SWyllys.Ingersoll@Sun.COM {
2049126SWyllys.Ingersoll@Sun.COM CK_RV rc;
2059126SWyllys.Ingersoll@Sun.COM TSS_HCONTEXT hContext;
2069126SWyllys.Ingersoll@Sun.COM
2079126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
2089126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
2099126SWyllys.Ingersoll@Sun.COM }
2109126SWyllys.Ingersoll@Sun.COM
2119126SWyllys.Ingersoll@Sun.COM rc = pthread_mutex_lock(&pkcs_mutex);
2129126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
2139126SWyllys.Ingersoll@Sun.COM return (rc);
2149126SWyllys.Ingersoll@Sun.COM }
2159126SWyllys.Ingersoll@Sun.COM //
2169126SWyllys.Ingersoll@Sun.COM // If somebody else has taken care of things, leave...
2179126SWyllys.Ingersoll@Sun.COM //
2189126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
2199126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&pkcs_mutex);
2209126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
2219126SWyllys.Ingersoll@Sun.COM }
2229126SWyllys.Ingersoll@Sun.COM if (open_tss_context(&hContext)) {
2239126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&pkcs_mutex);
2249126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
2259126SWyllys.Ingersoll@Sun.COM }
2269126SWyllys.Ingersoll@Sun.COM
2279126SWyllys.Ingersoll@Sun.COM initialized = FALSE;
2289126SWyllys.Ingersoll@Sun.COM
2299453SWyllys.Ingersoll@Sun.COM if (token_specific.t_final != NULL) {
2309453SWyllys.Ingersoll@Sun.COM token_specific.t_final(hContext);
2319453SWyllys.Ingersoll@Sun.COM }
2329453SWyllys.Ingersoll@Sun.COM
2339126SWyllys.Ingersoll@Sun.COM (void) session_mgr_close_all_sessions();
2349126SWyllys.Ingersoll@Sun.COM (void) object_mgr_purge_token_objects(hContext);
2359453SWyllys.Ingersoll@Sun.COM
2369126SWyllys.Ingersoll@Sun.COM (void) Tspi_Context_Close(hContext);
2379126SWyllys.Ingersoll@Sun.COM
2389126SWyllys.Ingersoll@Sun.COM (void) detach_shm();
2399126SWyllys.Ingersoll@Sun.COM
2409126SWyllys.Ingersoll@Sun.COM rc = pthread_mutex_unlock(&pkcs_mutex);
2419126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
2429126SWyllys.Ingersoll@Sun.COM return (rc);
2439126SWyllys.Ingersoll@Sun.COM }
2449126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
2459126SWyllys.Ingersoll@Sun.COM }
2469126SWyllys.Ingersoll@Sun.COM
2479126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
2489126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GetTokenInfo(CK_SLOT_ID sid,CK_TOKEN_INFO_PTR pInfo)2499126SWyllys.Ingersoll@Sun.COM SC_GetTokenInfo(CK_SLOT_ID sid, CK_TOKEN_INFO_PTR pInfo)
2509126SWyllys.Ingersoll@Sun.COM {
2519126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
2529126SWyllys.Ingersoll@Sun.COM time_t now;
2539126SWyllys.Ingersoll@Sun.COM
2549126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE)
2559126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
2569126SWyllys.Ingersoll@Sun.COM
2579126SWyllys.Ingersoll@Sun.COM if (pInfo == NULL)
2589126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
2599126SWyllys.Ingersoll@Sun.COM
2609126SWyllys.Ingersoll@Sun.COM if (sid != TPM_SLOTID)
2619126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
2629126SWyllys.Ingersoll@Sun.COM
2639126SWyllys.Ingersoll@Sun.COM (void) memcpy(pInfo, &nv_token_data->token_info,
2649126SWyllys.Ingersoll@Sun.COM sizeof (CK_TOKEN_INFO));
2659126SWyllys.Ingersoll@Sun.COM
2669126SWyllys.Ingersoll@Sun.COM now = time((time_t *)NULL);
2679126SWyllys.Ingersoll@Sun.COM (void) strftime((char *)pInfo->utcTime, 16, "%X", localtime(&now));
2689126SWyllys.Ingersoll@Sun.COM
2699126SWyllys.Ingersoll@Sun.COM return (rc);
2709126SWyllys.Ingersoll@Sun.COM }
2719126SWyllys.Ingersoll@Sun.COM
2729126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
2739126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GetMechanismList(CK_SLOT_ID sid,CK_MECHANISM_TYPE_PTR pMechList,CK_ULONG_PTR count)2749126SWyllys.Ingersoll@Sun.COM SC_GetMechanismList(
2759126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID sid,
2769126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_TYPE_PTR pMechList,
2779126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR count)
2789126SWyllys.Ingersoll@Sun.COM {
2799126SWyllys.Ingersoll@Sun.COM CK_ULONG i;
2809126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
2819126SWyllys.Ingersoll@Sun.COM
2829126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
2839126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
2849126SWyllys.Ingersoll@Sun.COM goto done;
2859126SWyllys.Ingersoll@Sun.COM }
2869126SWyllys.Ingersoll@Sun.COM
2879126SWyllys.Ingersoll@Sun.COM if (count == NULL) {
2889126SWyllys.Ingersoll@Sun.COM rc = CKR_FUNCTION_FAILED;
2899126SWyllys.Ingersoll@Sun.COM goto done;
2909126SWyllys.Ingersoll@Sun.COM }
2919126SWyllys.Ingersoll@Sun.COM
2929126SWyllys.Ingersoll@Sun.COM if (sid != TPM_SLOTID) {
2939126SWyllys.Ingersoll@Sun.COM rc = CKR_SLOT_ID_INVALID;
2949126SWyllys.Ingersoll@Sun.COM goto done;
2959126SWyllys.Ingersoll@Sun.COM }
2969126SWyllys.Ingersoll@Sun.COM
2979126SWyllys.Ingersoll@Sun.COM if (pMechList == NULL) {
2989126SWyllys.Ingersoll@Sun.COM *count = mech_list_len;
2999126SWyllys.Ingersoll@Sun.COM rc = CKR_OK;
3009126SWyllys.Ingersoll@Sun.COM goto done;
3019126SWyllys.Ingersoll@Sun.COM }
3029126SWyllys.Ingersoll@Sun.COM
3039126SWyllys.Ingersoll@Sun.COM if (*count < mech_list_len) {
3049126SWyllys.Ingersoll@Sun.COM *count = mech_list_len;
3059126SWyllys.Ingersoll@Sun.COM rc = CKR_BUFFER_TOO_SMALL;
3069126SWyllys.Ingersoll@Sun.COM goto done;
3079126SWyllys.Ingersoll@Sun.COM }
3089126SWyllys.Ingersoll@Sun.COM
3099126SWyllys.Ingersoll@Sun.COM for (i = 0; i < mech_list_len; i++)
3109126SWyllys.Ingersoll@Sun.COM pMechList[i] = mech_list[i].mech_type;
3119126SWyllys.Ingersoll@Sun.COM
3129126SWyllys.Ingersoll@Sun.COM *count = mech_list_len;
3139126SWyllys.Ingersoll@Sun.COM rc = CKR_OK;
3149126SWyllys.Ingersoll@Sun.COM
3159126SWyllys.Ingersoll@Sun.COM done:
3169126SWyllys.Ingersoll@Sun.COM if (debugfile) {
3179126SWyllys.Ingersoll@Sun.COM stlogit2(debugfile,
3189126SWyllys.Ingersoll@Sun.COM "% - 25s: rc = 0x%08x, # mechanisms: %d\n",
3199126SWyllys.Ingersoll@Sun.COM "C_GetMechanismList", rc, *count);
3209126SWyllys.Ingersoll@Sun.COM }
3219126SWyllys.Ingersoll@Sun.COM return (rc);
3229126SWyllys.Ingersoll@Sun.COM }
3239126SWyllys.Ingersoll@Sun.COM
3249126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
3259126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GetMechanismInfo(CK_SLOT_ID sid,CK_MECHANISM_TYPE type,CK_MECHANISM_INFO_PTR pInfo)3269126SWyllys.Ingersoll@Sun.COM SC_GetMechanismInfo(
3279126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID sid,
3289126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_TYPE type,
3299126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_INFO_PTR pInfo)
3309126SWyllys.Ingersoll@Sun.COM {
3319126SWyllys.Ingersoll@Sun.COM CK_ULONG i;
3329126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
3339126SWyllys.Ingersoll@Sun.COM
3349126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
3359126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
3369126SWyllys.Ingersoll@Sun.COM goto done;
3379126SWyllys.Ingersoll@Sun.COM }
3389126SWyllys.Ingersoll@Sun.COM
3399126SWyllys.Ingersoll@Sun.COM if (pInfo == NULL) {
3409126SWyllys.Ingersoll@Sun.COM rc = CKR_FUNCTION_FAILED;
3419126SWyllys.Ingersoll@Sun.COM goto done;
3429126SWyllys.Ingersoll@Sun.COM }
3439126SWyllys.Ingersoll@Sun.COM
3449126SWyllys.Ingersoll@Sun.COM if (sid != TPM_SLOTID) {
3459126SWyllys.Ingersoll@Sun.COM rc = CKR_SLOT_ID_INVALID;
3469126SWyllys.Ingersoll@Sun.COM goto done;
3479126SWyllys.Ingersoll@Sun.COM }
3489126SWyllys.Ingersoll@Sun.COM
3499126SWyllys.Ingersoll@Sun.COM for (i = 0; i < mech_list_len; i++) {
3509126SWyllys.Ingersoll@Sun.COM if (mech_list[i].mech_type == type) {
3519126SWyllys.Ingersoll@Sun.COM (void) memcpy(pInfo, &mech_list[i].mech_info,
3529126SWyllys.Ingersoll@Sun.COM sizeof (CK_MECHANISM_INFO));
3539126SWyllys.Ingersoll@Sun.COM rc = CKR_OK;
3549126SWyllys.Ingersoll@Sun.COM goto done;
3559126SWyllys.Ingersoll@Sun.COM }
3569126SWyllys.Ingersoll@Sun.COM }
3579126SWyllys.Ingersoll@Sun.COM rc = CKR_MECHANISM_INVALID;
3589126SWyllys.Ingersoll@Sun.COM
3599126SWyllys.Ingersoll@Sun.COM done:
3609126SWyllys.Ingersoll@Sun.COM if (debugfile) {
3619126SWyllys.Ingersoll@Sun.COM stlogit2(debugfile, "% - 25s: "
3629126SWyllys.Ingersoll@Sun.COM "rc = 0x%08x, mech type = 0x%08x\n",
3639126SWyllys.Ingersoll@Sun.COM "C_GetMechanismInfo", rc, type);
3649126SWyllys.Ingersoll@Sun.COM }
3659126SWyllys.Ingersoll@Sun.COM
3669126SWyllys.Ingersoll@Sun.COM return (rc);
3679126SWyllys.Ingersoll@Sun.COM }
3689126SWyllys.Ingersoll@Sun.COM
3699126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
3709126SWyllys.Ingersoll@Sun.COM CK_RV
SC_InitToken(CK_SLOT_ID sid,CK_CHAR_PTR pPin,CK_ULONG ulPinLen,CK_CHAR_PTR pLabel)3719126SWyllys.Ingersoll@Sun.COM SC_InitToken(
3729126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID sid,
3739126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pPin,
3749126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPinLen,
3759126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pLabel)
3769126SWyllys.Ingersoll@Sun.COM {
3779126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
3789126SWyllys.Ingersoll@Sun.COM CK_BYTE hash_sha[SHA1_DIGEST_LENGTH];
3799126SWyllys.Ingersoll@Sun.COM TOKEN_DATA newtoken;
3809126SWyllys.Ingersoll@Sun.COM TSS_HCONTEXT hContext = 0;
3819126SWyllys.Ingersoll@Sun.COM
3829126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
3839126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
3849126SWyllys.Ingersoll@Sun.COM goto done;
3859126SWyllys.Ingersoll@Sun.COM }
3869126SWyllys.Ingersoll@Sun.COM if (sid != TPM_SLOTID) {
3879126SWyllys.Ingersoll@Sun.COM rc = CKR_SLOT_ID_INVALID;
3889126SWyllys.Ingersoll@Sun.COM goto done;
3899126SWyllys.Ingersoll@Sun.COM }
3909126SWyllys.Ingersoll@Sun.COM
3919126SWyllys.Ingersoll@Sun.COM if (! pPin || ! pLabel) {
3929126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
3939126SWyllys.Ingersoll@Sun.COM goto done;
3949126SWyllys.Ingersoll@Sun.COM }
3959126SWyllys.Ingersoll@Sun.COM if (open_tss_context(&hContext)) {
3969126SWyllys.Ingersoll@Sun.COM rc = CKR_FUNCTION_FAILED;
3979126SWyllys.Ingersoll@Sun.COM goto done;
3989126SWyllys.Ingersoll@Sun.COM }
3999126SWyllys.Ingersoll@Sun.COM
4009126SWyllys.Ingersoll@Sun.COM rc = load_token_data(hContext, &newtoken);
4019126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
4029126SWyllys.Ingersoll@Sun.COM goto done;
4039126SWyllys.Ingersoll@Sun.COM }
4049126SWyllys.Ingersoll@Sun.COM
4059126SWyllys.Ingersoll@Sun.COM if (newtoken.token_info.flags & CKF_SO_PIN_LOCKED) {
4069126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_LOCKED;
4079126SWyllys.Ingersoll@Sun.COM goto done;
4089126SWyllys.Ingersoll@Sun.COM }
4099126SWyllys.Ingersoll@Sun.COM
4109126SWyllys.Ingersoll@Sun.COM rc = token_specific.t_verify_so_pin(hContext, pPin, ulPinLen);
4119126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
4129126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_INCORRECT;
4139126SWyllys.Ingersoll@Sun.COM goto done;
4149126SWyllys.Ingersoll@Sun.COM }
4159126SWyllys.Ingersoll@Sun.COM
4169126SWyllys.Ingersoll@Sun.COM /*
4179126SWyllys.Ingersoll@Sun.COM * Before we reconstruct all the data, we should delete the
4189126SWyllys.Ingersoll@Sun.COM * token objects from the filesystem.
4199126SWyllys.Ingersoll@Sun.COM *
4209126SWyllys.Ingersoll@Sun.COM * Construct a string to delete the token objects.
4219126SWyllys.Ingersoll@Sun.COM */
4229126SWyllys.Ingersoll@Sun.COM (void) object_mgr_destroy_token_objects(hContext);
4239126SWyllys.Ingersoll@Sun.COM
4249126SWyllys.Ingersoll@Sun.COM (void) init_token_data(hContext, &newtoken);
4259126SWyllys.Ingersoll@Sun.COM (void) init_slot_info(&newtoken);
4269126SWyllys.Ingersoll@Sun.COM
4279126SWyllys.Ingersoll@Sun.COM /* change the label */
4289126SWyllys.Ingersoll@Sun.COM (void) strncpy((char *)newtoken.token_info.label, (char *)pLabel,
4299126SWyllys.Ingersoll@Sun.COM sizeof (newtoken.token_info.label));
4309126SWyllys.Ingersoll@Sun.COM
4319126SWyllys.Ingersoll@Sun.COM (void) memcpy(newtoken.so_pin_sha, hash_sha,
4329126SWyllys.Ingersoll@Sun.COM SHA1_DIGEST_LENGTH);
4339126SWyllys.Ingersoll@Sun.COM
4349126SWyllys.Ingersoll@Sun.COM newtoken.token_info.flags |= CKF_TOKEN_INITIALIZED;
4359126SWyllys.Ingersoll@Sun.COM
4369126SWyllys.Ingersoll@Sun.COM rc = save_token_data(&newtoken);
4379126SWyllys.Ingersoll@Sun.COM done:
4389126SWyllys.Ingersoll@Sun.COM if (hContext)
4399126SWyllys.Ingersoll@Sun.COM (void) Tspi_Context_Close(hContext);
4409126SWyllys.Ingersoll@Sun.COM
4419126SWyllys.Ingersoll@Sun.COM return (rc);
4429126SWyllys.Ingersoll@Sun.COM }
4439126SWyllys.Ingersoll@Sun.COM
4449126SWyllys.Ingersoll@Sun.COM CK_RV
SC_InitPIN(ST_SESSION_HANDLE sSession,CK_CHAR_PTR pPin,CK_ULONG ulPinLen)4459126SWyllys.Ingersoll@Sun.COM SC_InitPIN(
4469126SWyllys.Ingersoll@Sun.COM ST_SESSION_HANDLE sSession,
4479126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pPin,
4489126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPinLen)
4499126SWyllys.Ingersoll@Sun.COM {
4509126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
4519126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
4529126SWyllys.Ingersoll@Sun.COM CK_FLAGS * flags = NULL;
4539126SWyllys.Ingersoll@Sun.COM SESS_SET
4549126SWyllys.Ingersoll@Sun.COM
4559126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
4569126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
4579126SWyllys.Ingersoll@Sun.COM goto done;
4589126SWyllys.Ingersoll@Sun.COM }
4599126SWyllys.Ingersoll@Sun.COM
4609126SWyllys.Ingersoll@Sun.COM if (! pPin) {
4619126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
4629126SWyllys.Ingersoll@Sun.COM goto done;
4639126SWyllys.Ingersoll@Sun.COM }
4649126SWyllys.Ingersoll@Sun.COM
4659126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
4669126SWyllys.Ingersoll@Sun.COM if (! sess) {
4679126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
4689126SWyllys.Ingersoll@Sun.COM goto done;
4699126SWyllys.Ingersoll@Sun.COM }
4709126SWyllys.Ingersoll@Sun.COM
4719126SWyllys.Ingersoll@Sun.COM if (pin_locked(&sess->session_info,
4729126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
4739126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_LOCKED;
4749126SWyllys.Ingersoll@Sun.COM goto done;
4759126SWyllys.Ingersoll@Sun.COM }
4769126SWyllys.Ingersoll@Sun.COM
4779126SWyllys.Ingersoll@Sun.COM if (sess->session_info.state != CKS_RW_SO_FUNCTIONS) {
4789126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_NOT_LOGGED_IN;
4799126SWyllys.Ingersoll@Sun.COM goto done;
4809126SWyllys.Ingersoll@Sun.COM }
4819126SWyllys.Ingersoll@Sun.COM
4829126SWyllys.Ingersoll@Sun.COM rc = token_specific.t_init_pin(sess->hContext, pPin, ulPinLen);
4839126SWyllys.Ingersoll@Sun.COM if (rc == CKR_OK) {
4849126SWyllys.Ingersoll@Sun.COM flags = &nv_token_data->token_info.flags;
4859126SWyllys.Ingersoll@Sun.COM
4869126SWyllys.Ingersoll@Sun.COM *flags &= ~(CKF_USER_PIN_LOCKED |
4879126SWyllys.Ingersoll@Sun.COM CKF_USER_PIN_FINAL_TRY |
4889126SWyllys.Ingersoll@Sun.COM CKF_USER_PIN_COUNT_LOW);
4899126SWyllys.Ingersoll@Sun.COM
4909126SWyllys.Ingersoll@Sun.COM rc = save_token_data(nv_token_data);
4919126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
4929126SWyllys.Ingersoll@Sun.COM goto done;
4939126SWyllys.Ingersoll@Sun.COM }
4949126SWyllys.Ingersoll@Sun.COM }
4959126SWyllys.Ingersoll@Sun.COM
4969126SWyllys.Ingersoll@Sun.COM done:
4979126SWyllys.Ingersoll@Sun.COM
4989126SWyllys.Ingersoll@Sun.COM if (debugfile) {
4999126SWyllys.Ingersoll@Sun.COM stlogit2(debugfile, "% - 25s: session = %08x\n",
5009126SWyllys.Ingersoll@Sun.COM "C_InitPin", rc, hSession);
5019126SWyllys.Ingersoll@Sun.COM }
5029126SWyllys.Ingersoll@Sun.COM
5039126SWyllys.Ingersoll@Sun.COM return (rc);
5049126SWyllys.Ingersoll@Sun.COM }
5059126SWyllys.Ingersoll@Sun.COM
5069126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SetPIN(ST_SESSION_HANDLE sSession,CK_CHAR_PTR pOldPin,CK_ULONG ulOldLen,CK_CHAR_PTR pNewPin,CK_ULONG ulNewLen)5079126SWyllys.Ingersoll@Sun.COM SC_SetPIN(ST_SESSION_HANDLE sSession,
5089126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pOldPin,
5099126SWyllys.Ingersoll@Sun.COM CK_ULONG ulOldLen,
5109126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pNewPin,
5119126SWyllys.Ingersoll@Sun.COM CK_ULONG ulNewLen)
5129126SWyllys.Ingersoll@Sun.COM {
5139126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
5149126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
5159126SWyllys.Ingersoll@Sun.COM SESS_SET
5169126SWyllys.Ingersoll@Sun.COM
5179126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
5189126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
5199126SWyllys.Ingersoll@Sun.COM goto done;
5209126SWyllys.Ingersoll@Sun.COM }
5219126SWyllys.Ingersoll@Sun.COM
5229126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
5239126SWyllys.Ingersoll@Sun.COM if (! sess) {
5249126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
5259126SWyllys.Ingersoll@Sun.COM goto done;
5269126SWyllys.Ingersoll@Sun.COM }
5279126SWyllys.Ingersoll@Sun.COM
5289126SWyllys.Ingersoll@Sun.COM if (pin_locked(&sess->session_info,
5299126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
5309126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_LOCKED;
5319126SWyllys.Ingersoll@Sun.COM goto done;
5329126SWyllys.Ingersoll@Sun.COM }
5339126SWyllys.Ingersoll@Sun.COM
5349126SWyllys.Ingersoll@Sun.COM rc = token_specific.t_set_pin(sSession, pOldPin,
5359126SWyllys.Ingersoll@Sun.COM ulOldLen, pNewPin, ulNewLen);
5369126SWyllys.Ingersoll@Sun.COM
5379126SWyllys.Ingersoll@Sun.COM done:
5389126SWyllys.Ingersoll@Sun.COM if (debugfile) {
5399126SWyllys.Ingersoll@Sun.COM stlogit2(debugfile, "% - 25s: session = %08x\n",
5409126SWyllys.Ingersoll@Sun.COM "C_SetPin", rc, hSession);
5419126SWyllys.Ingersoll@Sun.COM }
5429126SWyllys.Ingersoll@Sun.COM
5439126SWyllys.Ingersoll@Sun.COM return (rc);
5449126SWyllys.Ingersoll@Sun.COM }
5459126SWyllys.Ingersoll@Sun.COM
5469126SWyllys.Ingersoll@Sun.COM CK_RV
SC_OpenSession(CK_SLOT_ID sid,CK_FLAGS flags,CK_SESSION_HANDLE_PTR phSession)5479126SWyllys.Ingersoll@Sun.COM SC_OpenSession(
5489126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID sid,
5499126SWyllys.Ingersoll@Sun.COM CK_FLAGS flags,
5509126SWyllys.Ingersoll@Sun.COM CK_SESSION_HANDLE_PTR phSession)
5519126SWyllys.Ingersoll@Sun.COM {
5529126SWyllys.Ingersoll@Sun.COM SESSION *sess;
5539126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
5549126SWyllys.Ingersoll@Sun.COM TSS_HCONTEXT hContext;
5559126SWyllys.Ingersoll@Sun.COM
5569126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
5579126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
5589126SWyllys.Ingersoll@Sun.COM goto done;
5599126SWyllys.Ingersoll@Sun.COM }
5609126SWyllys.Ingersoll@Sun.COM
5619126SWyllys.Ingersoll@Sun.COM if ((flags & CKF_RW_SESSION) == 0) {
5629126SWyllys.Ingersoll@Sun.COM if (session_mgr_so_session_exists()) {
5639126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_READ_WRITE_SO_EXISTS);
5649126SWyllys.Ingersoll@Sun.COM }
5659126SWyllys.Ingersoll@Sun.COM }
5669126SWyllys.Ingersoll@Sun.COM if (sid != TPM_SLOTID) {
5679126SWyllys.Ingersoll@Sun.COM rc = CKR_SLOT_ID_INVALID;
5689126SWyllys.Ingersoll@Sun.COM goto done;
5699126SWyllys.Ingersoll@Sun.COM }
5709126SWyllys.Ingersoll@Sun.COM if (open_tss_context(&hContext)) {
5719126SWyllys.Ingersoll@Sun.COM rc = CKR_FUNCTION_FAILED;
5729126SWyllys.Ingersoll@Sun.COM goto done;
5739126SWyllys.Ingersoll@Sun.COM }
5749126SWyllys.Ingersoll@Sun.COM
5759126SWyllys.Ingersoll@Sun.COM rc = pthread_mutex_lock(&pkcs_mutex);
5769126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
5779126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&pkcs_mutex);
5789126SWyllys.Ingersoll@Sun.COM Tspi_Context_Close(hContext);
5799126SWyllys.Ingersoll@Sun.COM goto done;
5809126SWyllys.Ingersoll@Sun.COM }
5819126SWyllys.Ingersoll@Sun.COM token_specific.t_session(sid);
5829126SWyllys.Ingersoll@Sun.COM
5839126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&pkcs_mutex);
5849126SWyllys.Ingersoll@Sun.COM
5859126SWyllys.Ingersoll@Sun.COM rc = session_mgr_new(flags, &sess);
5869126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
5879126SWyllys.Ingersoll@Sun.COM Tspi_Context_Close(hContext);
5889126SWyllys.Ingersoll@Sun.COM goto done;
5899126SWyllys.Ingersoll@Sun.COM }
5909126SWyllys.Ingersoll@Sun.COM *phSession = sess->handle;
5919126SWyllys.Ingersoll@Sun.COM sess->session_info.slotID = sid;
5929126SWyllys.Ingersoll@Sun.COM
5939126SWyllys.Ingersoll@Sun.COM /* Open a new context for each session */
5949126SWyllys.Ingersoll@Sun.COM sess->hContext = hContext;
5959126SWyllys.Ingersoll@Sun.COM done:
5969126SWyllys.Ingersoll@Sun.COM return (rc);
5979126SWyllys.Ingersoll@Sun.COM }
5989126SWyllys.Ingersoll@Sun.COM
5999126SWyllys.Ingersoll@Sun.COM CK_RV
SC_CloseSession(ST_SESSION_HANDLE sSession)6009126SWyllys.Ingersoll@Sun.COM SC_CloseSession(ST_SESSION_HANDLE sSession)
6019126SWyllys.Ingersoll@Sun.COM {
6029126SWyllys.Ingersoll@Sun.COM SESSION *sess = NULL;
6039126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
6049126SWyllys.Ingersoll@Sun.COM SESS_SET
6059126SWyllys.Ingersoll@Sun.COM
6069126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
6079126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
6089126SWyllys.Ingersoll@Sun.COM goto done;
6099126SWyllys.Ingersoll@Sun.COM }
6109126SWyllys.Ingersoll@Sun.COM
6119126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
6129126SWyllys.Ingersoll@Sun.COM if (!sess) {
6139126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
6149126SWyllys.Ingersoll@Sun.COM goto done;
6159126SWyllys.Ingersoll@Sun.COM }
6169126SWyllys.Ingersoll@Sun.COM
6179453SWyllys.Ingersoll@Sun.COM if (token_specific.t_final != NULL) {
6189453SWyllys.Ingersoll@Sun.COM token_specific.t_final(sess->hContext);
6199453SWyllys.Ingersoll@Sun.COM }
6209453SWyllys.Ingersoll@Sun.COM
6219126SWyllys.Ingersoll@Sun.COM rc = session_mgr_close_session(sess);
6229126SWyllys.Ingersoll@Sun.COM
6239126SWyllys.Ingersoll@Sun.COM done:
6249126SWyllys.Ingersoll@Sun.COM
6259126SWyllys.Ingersoll@Sun.COM return (rc);
6269126SWyllys.Ingersoll@Sun.COM }
6279126SWyllys.Ingersoll@Sun.COM
6289126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
6299126SWyllys.Ingersoll@Sun.COM CK_RV
SC_CloseAllSessions(CK_SLOT_ID sid)6309126SWyllys.Ingersoll@Sun.COM SC_CloseAllSessions(CK_SLOT_ID sid)
6319126SWyllys.Ingersoll@Sun.COM {
6329126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
6339126SWyllys.Ingersoll@Sun.COM
6349126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE)
6359126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
6369126SWyllys.Ingersoll@Sun.COM
6379126SWyllys.Ingersoll@Sun.COM if (sid != TPM_SLOTID)
6389126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
6399126SWyllys.Ingersoll@Sun.COM
6409126SWyllys.Ingersoll@Sun.COM rc = session_mgr_close_all_sessions();
6419126SWyllys.Ingersoll@Sun.COM
6429126SWyllys.Ingersoll@Sun.COM return (rc);
6439126SWyllys.Ingersoll@Sun.COM }
6449126SWyllys.Ingersoll@Sun.COM
6459126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GetSessionInfo(ST_SESSION_HANDLE sSession,CK_SESSION_INFO_PTR pInfo)6469126SWyllys.Ingersoll@Sun.COM SC_GetSessionInfo(ST_SESSION_HANDLE sSession,
6479126SWyllys.Ingersoll@Sun.COM CK_SESSION_INFO_PTR pInfo)
6489126SWyllys.Ingersoll@Sun.COM {
6499126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
6509126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
6519126SWyllys.Ingersoll@Sun.COM SESS_SET
6529126SWyllys.Ingersoll@Sun.COM
6539126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
6549126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
6559126SWyllys.Ingersoll@Sun.COM goto done;
6569126SWyllys.Ingersoll@Sun.COM }
6579126SWyllys.Ingersoll@Sun.COM
6589126SWyllys.Ingersoll@Sun.COM if (! pInfo) {
6599126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
6609126SWyllys.Ingersoll@Sun.COM goto done;
6619126SWyllys.Ingersoll@Sun.COM }
6629126SWyllys.Ingersoll@Sun.COM
6639126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
6649126SWyllys.Ingersoll@Sun.COM if (! sess) {
6659126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
6669126SWyllys.Ingersoll@Sun.COM goto done;
6679126SWyllys.Ingersoll@Sun.COM }
6689126SWyllys.Ingersoll@Sun.COM
6699126SWyllys.Ingersoll@Sun.COM (void) memcpy(pInfo, &sess->session_info, sizeof (CK_SESSION_INFO));
6709126SWyllys.Ingersoll@Sun.COM
6719126SWyllys.Ingersoll@Sun.COM done:
6729126SWyllys.Ingersoll@Sun.COM return (rc);
6739126SWyllys.Ingersoll@Sun.COM }
6749126SWyllys.Ingersoll@Sun.COM
SC_GetOperationState(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pOperationState,CK_ULONG_PTR pulOperationStateLen)6759126SWyllys.Ingersoll@Sun.COM CK_RV SC_GetOperationState(ST_SESSION_HANDLE sSession,
6769126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pOperationState,
6779126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulOperationStateLen)
6789126SWyllys.Ingersoll@Sun.COM {
6799126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
6809126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
6819126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
6829126SWyllys.Ingersoll@Sun.COM SESS_SET
6839126SWyllys.Ingersoll@Sun.COM
6849126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
6859126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
6869126SWyllys.Ingersoll@Sun.COM goto done;
6879126SWyllys.Ingersoll@Sun.COM }
6889126SWyllys.Ingersoll@Sun.COM
6899126SWyllys.Ingersoll@Sun.COM if (! pulOperationStateLen) {
6909126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
6919126SWyllys.Ingersoll@Sun.COM goto done;
6929126SWyllys.Ingersoll@Sun.COM }
6939126SWyllys.Ingersoll@Sun.COM
6949126SWyllys.Ingersoll@Sun.COM if (! pOperationState)
6959126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
6969126SWyllys.Ingersoll@Sun.COM
6979126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
6989126SWyllys.Ingersoll@Sun.COM if (! sess) {
6999126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
7009126SWyllys.Ingersoll@Sun.COM goto done;
7019126SWyllys.Ingersoll@Sun.COM }
7029126SWyllys.Ingersoll@Sun.COM
7039126SWyllys.Ingersoll@Sun.COM rc = session_mgr_get_op_state(sess, length_only,
7049126SWyllys.Ingersoll@Sun.COM pOperationState, pulOperationStateLen);
7059126SWyllys.Ingersoll@Sun.COM done:
7069126SWyllys.Ingersoll@Sun.COM return (rc);
7079126SWyllys.Ingersoll@Sun.COM }
7089126SWyllys.Ingersoll@Sun.COM
7099126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SetOperationState(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pOperationState,CK_ULONG ulOperationStateLen,CK_OBJECT_HANDLE hEncryptionKey,CK_OBJECT_HANDLE hAuthenticationKey)7109126SWyllys.Ingersoll@Sun.COM SC_SetOperationState(ST_SESSION_HANDLE sSession,
7119126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pOperationState,
7129126SWyllys.Ingersoll@Sun.COM CK_ULONG ulOperationStateLen,
7139126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hEncryptionKey,
7149126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hAuthenticationKey)
7159126SWyllys.Ingersoll@Sun.COM {
7169126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
7179126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
7189126SWyllys.Ingersoll@Sun.COM SESS_SET
7199126SWyllys.Ingersoll@Sun.COM
7209126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
7219126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
7229126SWyllys.Ingersoll@Sun.COM }
7239126SWyllys.Ingersoll@Sun.COM
7249126SWyllys.Ingersoll@Sun.COM if (!pOperationState || (ulOperationStateLen == 0)) {
7259126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
7269126SWyllys.Ingersoll@Sun.COM }
7279126SWyllys.Ingersoll@Sun.COM
7289126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
7299126SWyllys.Ingersoll@Sun.COM if (! sess) {
7309126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
7319126SWyllys.Ingersoll@Sun.COM }
7329126SWyllys.Ingersoll@Sun.COM
7339126SWyllys.Ingersoll@Sun.COM rc = session_mgr_set_op_state(sess,
7349126SWyllys.Ingersoll@Sun.COM hEncryptionKey, hAuthenticationKey,
7359126SWyllys.Ingersoll@Sun.COM pOperationState);
7369126SWyllys.Ingersoll@Sun.COM
7379126SWyllys.Ingersoll@Sun.COM return (rc);
7389126SWyllys.Ingersoll@Sun.COM }
7399126SWyllys.Ingersoll@Sun.COM
7409126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Login(ST_SESSION_HANDLE sSession,CK_USER_TYPE userType,CK_CHAR_PTR pPin,CK_ULONG ulPinLen)7419126SWyllys.Ingersoll@Sun.COM SC_Login(ST_SESSION_HANDLE sSession,
7429126SWyllys.Ingersoll@Sun.COM CK_USER_TYPE userType,
7439126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pPin,
7449126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPinLen)
7459126SWyllys.Ingersoll@Sun.COM {
7469126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
7479126SWyllys.Ingersoll@Sun.COM CK_FLAGS * flags = NULL, flagcheck, flagmask;
7489126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
7499126SWyllys.Ingersoll@Sun.COM
7509126SWyllys.Ingersoll@Sun.COM SESS_SET
7519126SWyllys.Ingersoll@Sun.COM // In v2.11, logins should be exclusive, since token
7529126SWyllys.Ingersoll@Sun.COM // specific flags may need to be set for a bad login. - KEY
7539126SWyllys.Ingersoll@Sun.COM rc = pthread_mutex_lock(&login_mutex);
7549126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
7559126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
7569126SWyllys.Ingersoll@Sun.COM }
7579126SWyllys.Ingersoll@Sun.COM
7589126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
7599126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
7609126SWyllys.Ingersoll@Sun.COM goto done;
7619126SWyllys.Ingersoll@Sun.COM }
7629126SWyllys.Ingersoll@Sun.COM
7639126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
7649126SWyllys.Ingersoll@Sun.COM if (! sess) {
7659126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
7669126SWyllys.Ingersoll@Sun.COM goto done;
7679126SWyllys.Ingersoll@Sun.COM }
7689126SWyllys.Ingersoll@Sun.COM flags = &nv_token_data->token_info.flags;
7699126SWyllys.Ingersoll@Sun.COM
7709453SWyllys.Ingersoll@Sun.COM if (pPin == NULL) {
7719126SWyllys.Ingersoll@Sun.COM set_login_flags(userType, flags);
7729453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
7739453SWyllys.Ingersoll@Sun.COM goto done;
7749453SWyllys.Ingersoll@Sun.COM }
7759453SWyllys.Ingersoll@Sun.COM if (ulPinLen < MIN_PIN_LEN || ulPinLen > MAX_PIN_LEN) {
7769453SWyllys.Ingersoll@Sun.COM set_login_flags(userType, flags);
7779453SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_LEN_RANGE;
7789126SWyllys.Ingersoll@Sun.COM goto done;
7799126SWyllys.Ingersoll@Sun.COM }
7809126SWyllys.Ingersoll@Sun.COM
7819126SWyllys.Ingersoll@Sun.COM /*
7829126SWyllys.Ingersoll@Sun.COM * PKCS #11 v2.01 requires that all sessions have the same login status:
7839126SWyllys.Ingersoll@Sun.COM * --> all sessions are public, all are SO or all are USER
7849126SWyllys.Ingersoll@Sun.COM */
7859126SWyllys.Ingersoll@Sun.COM if (userType == CKU_USER) {
7869126SWyllys.Ingersoll@Sun.COM if (session_mgr_so_session_exists()) {
7879126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_ANOTHER_ALREADY_LOGGED_IN;
7889126SWyllys.Ingersoll@Sun.COM }
7899126SWyllys.Ingersoll@Sun.COM if (session_mgr_user_session_exists()) {
7909126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_ALREADY_LOGGED_IN;
7919126SWyllys.Ingersoll@Sun.COM }
7929453SWyllys.Ingersoll@Sun.COM } else if (userType == CKU_SO) {
7939126SWyllys.Ingersoll@Sun.COM if (session_mgr_user_session_exists()) {
7949126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_ANOTHER_ALREADY_LOGGED_IN;
7959126SWyllys.Ingersoll@Sun.COM }
7969126SWyllys.Ingersoll@Sun.COM if (session_mgr_so_session_exists()) {
7979126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_ALREADY_LOGGED_IN;
7989126SWyllys.Ingersoll@Sun.COM }
7999126SWyllys.Ingersoll@Sun.COM if (session_mgr_readonly_exists()) {
8009126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_READ_ONLY_EXISTS;
8019126SWyllys.Ingersoll@Sun.COM }
8029126SWyllys.Ingersoll@Sun.COM } else {
8039126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_TYPE_INVALID;
8049126SWyllys.Ingersoll@Sun.COM }
8059126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
8069126SWyllys.Ingersoll@Sun.COM goto done;
8079126SWyllys.Ingersoll@Sun.COM
8089126SWyllys.Ingersoll@Sun.COM if (userType == CKU_USER) {
8099126SWyllys.Ingersoll@Sun.COM flagcheck = CKF_USER_PIN_LOCKED;
8109126SWyllys.Ingersoll@Sun.COM flagmask = (CKF_USER_PIN_LOCKED | CKF_USER_PIN_FINAL_TRY |
8119126SWyllys.Ingersoll@Sun.COM CKF_USER_PIN_COUNT_LOW);
8129126SWyllys.Ingersoll@Sun.COM } else {
8139126SWyllys.Ingersoll@Sun.COM flagcheck = CKF_SO_PIN_LOCKED;
8149126SWyllys.Ingersoll@Sun.COM flagmask = (CKF_SO_PIN_LOCKED |
8159126SWyllys.Ingersoll@Sun.COM CKF_SO_PIN_FINAL_TRY |
8169126SWyllys.Ingersoll@Sun.COM CKF_SO_PIN_COUNT_LOW);
8179126SWyllys.Ingersoll@Sun.COM }
8189126SWyllys.Ingersoll@Sun.COM if (*flags & flagcheck) {
8199126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_LOCKED;
8209126SWyllys.Ingersoll@Sun.COM goto done;
8219126SWyllys.Ingersoll@Sun.COM }
8229126SWyllys.Ingersoll@Sun.COM
8239126SWyllys.Ingersoll@Sun.COM /* call the pluggable login function here */
8249126SWyllys.Ingersoll@Sun.COM rc = token_specific.t_login(sess->hContext, userType, pPin, ulPinLen);
8259126SWyllys.Ingersoll@Sun.COM if (rc == CKR_OK) {
8269126SWyllys.Ingersoll@Sun.COM *flags &= ~(flagmask);
8279126SWyllys.Ingersoll@Sun.COM } else if (rc == CKR_PIN_INCORRECT) {
8289126SWyllys.Ingersoll@Sun.COM set_login_flags(userType, flags);
8299126SWyllys.Ingersoll@Sun.COM goto done;
8309126SWyllys.Ingersoll@Sun.COM } else {
8319126SWyllys.Ingersoll@Sun.COM goto done;
8329126SWyllys.Ingersoll@Sun.COM }
8339126SWyllys.Ingersoll@Sun.COM
8349126SWyllys.Ingersoll@Sun.COM rc = session_mgr_login_all(userType);
8359126SWyllys.Ingersoll@Sun.COM
8369126SWyllys.Ingersoll@Sun.COM done:
8379126SWyllys.Ingersoll@Sun.COM if (rc == CKR_OK)
8389126SWyllys.Ingersoll@Sun.COM rc = save_token_data(nv_token_data);
8399126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&login_mutex);
8409126SWyllys.Ingersoll@Sun.COM return (rc);
8419126SWyllys.Ingersoll@Sun.COM }
8429126SWyllys.Ingersoll@Sun.COM
8439126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Logout(ST_SESSION_HANDLE sSession)8449126SWyllys.Ingersoll@Sun.COM SC_Logout(ST_SESSION_HANDLE sSession)
8459126SWyllys.Ingersoll@Sun.COM {
8469126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
8479126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
8489126SWyllys.Ingersoll@Sun.COM
8499126SWyllys.Ingersoll@Sun.COM SESS_SET
8509126SWyllys.Ingersoll@Sun.COM
8519126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
8529126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
8539126SWyllys.Ingersoll@Sun.COM goto done;
8549126SWyllys.Ingersoll@Sun.COM }
8559126SWyllys.Ingersoll@Sun.COM
8569126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
8579126SWyllys.Ingersoll@Sun.COM if (! sess) {
8589126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
8599126SWyllys.Ingersoll@Sun.COM goto done;
8609126SWyllys.Ingersoll@Sun.COM }
8619126SWyllys.Ingersoll@Sun.COM
8629126SWyllys.Ingersoll@Sun.COM // all sessions have the same state so we just have to check one
8639126SWyllys.Ingersoll@Sun.COM //
8649126SWyllys.Ingersoll@Sun.COM if (session_mgr_public_session_exists()) {
8659126SWyllys.Ingersoll@Sun.COM rc = CKR_USER_NOT_LOGGED_IN;
8669126SWyllys.Ingersoll@Sun.COM goto done;
8679126SWyllys.Ingersoll@Sun.COM }
8689126SWyllys.Ingersoll@Sun.COM
8699126SWyllys.Ingersoll@Sun.COM (void) session_mgr_logout_all();
8709126SWyllys.Ingersoll@Sun.COM
8719126SWyllys.Ingersoll@Sun.COM rc = token_specific.t_logout(sess->hContext);
8729126SWyllys.Ingersoll@Sun.COM
8739126SWyllys.Ingersoll@Sun.COM done:
8749126SWyllys.Ingersoll@Sun.COM return (rc);
8759126SWyllys.Ingersoll@Sun.COM }
8769126SWyllys.Ingersoll@Sun.COM
8779126SWyllys.Ingersoll@Sun.COM CK_RV
SC_CreateObject(ST_SESSION_HANDLE sSession,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phObject)8789126SWyllys.Ingersoll@Sun.COM SC_CreateObject(ST_SESSION_HANDLE sSession,
8799126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
8809126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount,
8819126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phObject)
8829126SWyllys.Ingersoll@Sun.COM {
8839126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
8849126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
8859126SWyllys.Ingersoll@Sun.COM SESS_SET
8869126SWyllys.Ingersoll@Sun.COM
8879126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
8889126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
8899126SWyllys.Ingersoll@Sun.COM goto done;
8909126SWyllys.Ingersoll@Sun.COM }
8919126SWyllys.Ingersoll@Sun.COM
8929126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
8939126SWyllys.Ingersoll@Sun.COM if (! sess) {
8949126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
8959126SWyllys.Ingersoll@Sun.COM goto done;
8969126SWyllys.Ingersoll@Sun.COM }
8979126SWyllys.Ingersoll@Sun.COM
8989126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
8999126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
9009126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
9019126SWyllys.Ingersoll@Sun.COM goto done;
9029126SWyllys.Ingersoll@Sun.COM }
9039126SWyllys.Ingersoll@Sun.COM rc = object_mgr_add(sess, pTemplate, ulCount, phObject);
9049126SWyllys.Ingersoll@Sun.COM
9059126SWyllys.Ingersoll@Sun.COM done:
9069126SWyllys.Ingersoll@Sun.COM return (rc);
9079126SWyllys.Ingersoll@Sun.COM
9089126SWyllys.Ingersoll@Sun.COM }
9099126SWyllys.Ingersoll@Sun.COM
9109126SWyllys.Ingersoll@Sun.COM CK_RV
SC_CopyObject(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phNewObject)9119126SWyllys.Ingersoll@Sun.COM SC_CopyObject(
9129126SWyllys.Ingersoll@Sun.COM ST_SESSION_HANDLE sSession,
9139126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
9149126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
9159126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount,
9169126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phNewObject)
9179126SWyllys.Ingersoll@Sun.COM {
9189126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
9199126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
9209126SWyllys.Ingersoll@Sun.COM SESS_SET
9219126SWyllys.Ingersoll@Sun.COM
9229126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
9239126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
9249126SWyllys.Ingersoll@Sun.COM goto done;
9259126SWyllys.Ingersoll@Sun.COM }
9269126SWyllys.Ingersoll@Sun.COM
9279126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
9289126SWyllys.Ingersoll@Sun.COM if (! sess) {
9299126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
9309126SWyllys.Ingersoll@Sun.COM goto done;
9319126SWyllys.Ingersoll@Sun.COM }
9329126SWyllys.Ingersoll@Sun.COM
9339126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
9349126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
9359126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
9369126SWyllys.Ingersoll@Sun.COM goto done;
9379126SWyllys.Ingersoll@Sun.COM }
9389126SWyllys.Ingersoll@Sun.COM
9399126SWyllys.Ingersoll@Sun.COM rc = object_mgr_copy(sess, pTemplate, ulCount,
9409126SWyllys.Ingersoll@Sun.COM hObject, phNewObject);
9419126SWyllys.Ingersoll@Sun.COM
9429126SWyllys.Ingersoll@Sun.COM done:
9439126SWyllys.Ingersoll@Sun.COM return (rc);
9449126SWyllys.Ingersoll@Sun.COM }
9459126SWyllys.Ingersoll@Sun.COM
9469126SWyllys.Ingersoll@Sun.COM CK_RV
SC_DestroyObject(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE hObject)9479126SWyllys.Ingersoll@Sun.COM SC_DestroyObject(ST_SESSION_HANDLE sSession,
9489126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject)
9499126SWyllys.Ingersoll@Sun.COM {
9509126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
9519126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
9529126SWyllys.Ingersoll@Sun.COM SESS_SET
9539126SWyllys.Ingersoll@Sun.COM
9549126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
9559126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
9569126SWyllys.Ingersoll@Sun.COM goto done;
9579126SWyllys.Ingersoll@Sun.COM }
9589126SWyllys.Ingersoll@Sun.COM
9599126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
9609126SWyllys.Ingersoll@Sun.COM if (! sess) {
9619126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
9629126SWyllys.Ingersoll@Sun.COM goto done;
9639126SWyllys.Ingersoll@Sun.COM }
9649126SWyllys.Ingersoll@Sun.COM
9659126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
9669126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
9679126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
9689126SWyllys.Ingersoll@Sun.COM goto done;
9699126SWyllys.Ingersoll@Sun.COM }
9709126SWyllys.Ingersoll@Sun.COM
9719126SWyllys.Ingersoll@Sun.COM rc = object_mgr_destroy_object(sess, hObject);
9729126SWyllys.Ingersoll@Sun.COM done:
9739126SWyllys.Ingersoll@Sun.COM return (rc);
9749126SWyllys.Ingersoll@Sun.COM }
9759126SWyllys.Ingersoll@Sun.COM
9769126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GetObjectSize(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE hObject,CK_ULONG_PTR pulSize)9779126SWyllys.Ingersoll@Sun.COM SC_GetObjectSize(
9789126SWyllys.Ingersoll@Sun.COM ST_SESSION_HANDLE sSession,
9799126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
9809126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSize)
9819126SWyllys.Ingersoll@Sun.COM {
9829126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
9839126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
9849126SWyllys.Ingersoll@Sun.COM SESS_SET
9859126SWyllys.Ingersoll@Sun.COM
9869126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
9879126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
9889126SWyllys.Ingersoll@Sun.COM goto done;
9899126SWyllys.Ingersoll@Sun.COM }
9909126SWyllys.Ingersoll@Sun.COM
9919126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
9929126SWyllys.Ingersoll@Sun.COM if (! sess) {
9939126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
9949126SWyllys.Ingersoll@Sun.COM goto done;
9959126SWyllys.Ingersoll@Sun.COM }
9969126SWyllys.Ingersoll@Sun.COM
9979126SWyllys.Ingersoll@Sun.COM rc = object_mgr_get_object_size(sess->hContext, hObject, pulSize);
9989126SWyllys.Ingersoll@Sun.COM
9999126SWyllys.Ingersoll@Sun.COM done:
10009126SWyllys.Ingersoll@Sun.COM return (rc);
10019126SWyllys.Ingersoll@Sun.COM }
10029126SWyllys.Ingersoll@Sun.COM
10039126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GetAttributeValue(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)10049126SWyllys.Ingersoll@Sun.COM SC_GetAttributeValue(ST_SESSION_HANDLE sSession,
10059126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
10069126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
10079126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount)
10089126SWyllys.Ingersoll@Sun.COM {
10099126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
10109126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
10119126SWyllys.Ingersoll@Sun.COM SESS_SET
10129126SWyllys.Ingersoll@Sun.COM
10139126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
10149126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
10159126SWyllys.Ingersoll@Sun.COM goto done;
10169126SWyllys.Ingersoll@Sun.COM }
10179126SWyllys.Ingersoll@Sun.COM
10189126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
10199126SWyllys.Ingersoll@Sun.COM if (! sess) {
10209126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
10219126SWyllys.Ingersoll@Sun.COM goto done;
10229126SWyllys.Ingersoll@Sun.COM }
10239126SWyllys.Ingersoll@Sun.COM
10249126SWyllys.Ingersoll@Sun.COM rc = object_mgr_get_attribute_values(sess, hObject, pTemplate, ulCount);
10259126SWyllys.Ingersoll@Sun.COM
10269126SWyllys.Ingersoll@Sun.COM done:
10279126SWyllys.Ingersoll@Sun.COM return (rc);
10289126SWyllys.Ingersoll@Sun.COM }
10299126SWyllys.Ingersoll@Sun.COM
10309126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SetAttributeValue(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)10319126SWyllys.Ingersoll@Sun.COM SC_SetAttributeValue(ST_SESSION_HANDLE sSession,
10329126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
10339126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
10349126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount)
10359126SWyllys.Ingersoll@Sun.COM {
10369126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
10379126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
10389126SWyllys.Ingersoll@Sun.COM SESS_SET
10399126SWyllys.Ingersoll@Sun.COM
10409126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
10419126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
10429126SWyllys.Ingersoll@Sun.COM goto done;
10439126SWyllys.Ingersoll@Sun.COM }
10449126SWyllys.Ingersoll@Sun.COM
10459126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
10469126SWyllys.Ingersoll@Sun.COM if (! sess) {
10479126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
10489126SWyllys.Ingersoll@Sun.COM goto done;
10499126SWyllys.Ingersoll@Sun.COM }
10509126SWyllys.Ingersoll@Sun.COM
10519126SWyllys.Ingersoll@Sun.COM rc = object_mgr_set_attribute_values(sess, hObject, pTemplate, ulCount);
10529126SWyllys.Ingersoll@Sun.COM
10539126SWyllys.Ingersoll@Sun.COM done:
10549126SWyllys.Ingersoll@Sun.COM return (rc);
10559126SWyllys.Ingersoll@Sun.COM }
10569126SWyllys.Ingersoll@Sun.COM
10579126SWyllys.Ingersoll@Sun.COM CK_RV
SC_FindObjectsInit(ST_SESSION_HANDLE sSession,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)10589126SWyllys.Ingersoll@Sun.COM SC_FindObjectsInit(ST_SESSION_HANDLE sSession,
10599126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
10609126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount)
10619126SWyllys.Ingersoll@Sun.COM {
10629126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
10639126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
10649126SWyllys.Ingersoll@Sun.COM SESS_SET
10659126SWyllys.Ingersoll@Sun.COM
10669126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
10679126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
10689126SWyllys.Ingersoll@Sun.COM goto done;
10699126SWyllys.Ingersoll@Sun.COM }
10709126SWyllys.Ingersoll@Sun.COM
10719126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
10729126SWyllys.Ingersoll@Sun.COM if (! sess) {
10739126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
10749126SWyllys.Ingersoll@Sun.COM goto done;
10759126SWyllys.Ingersoll@Sun.COM }
10769126SWyllys.Ingersoll@Sun.COM
10779126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
10789126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
10799126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
10809126SWyllys.Ingersoll@Sun.COM goto done;
10819126SWyllys.Ingersoll@Sun.COM }
10829126SWyllys.Ingersoll@Sun.COM
10839126SWyllys.Ingersoll@Sun.COM if (sess->find_active == TRUE) {
10849126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
10859126SWyllys.Ingersoll@Sun.COM goto done;
10869126SWyllys.Ingersoll@Sun.COM }
10879126SWyllys.Ingersoll@Sun.COM
10889126SWyllys.Ingersoll@Sun.COM rc = object_mgr_find_init(sess, pTemplate, ulCount);
10899126SWyllys.Ingersoll@Sun.COM
10909126SWyllys.Ingersoll@Sun.COM done:
10919126SWyllys.Ingersoll@Sun.COM return (rc);
10929126SWyllys.Ingersoll@Sun.COM }
10939126SWyllys.Ingersoll@Sun.COM
10949126SWyllys.Ingersoll@Sun.COM CK_RV
SC_FindObjects(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE_PTR phObject,CK_ULONG ulMaxObjectCount,CK_ULONG_PTR pulObjectCount)10959126SWyllys.Ingersoll@Sun.COM SC_FindObjects(ST_SESSION_HANDLE sSession,
10969126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phObject,
10979126SWyllys.Ingersoll@Sun.COM CK_ULONG ulMaxObjectCount,
10989126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulObjectCount)
10999126SWyllys.Ingersoll@Sun.COM {
11009126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
11019126SWyllys.Ingersoll@Sun.COM CK_ULONG count = 0;
11029126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
11039126SWyllys.Ingersoll@Sun.COM SESS_SET
11049126SWyllys.Ingersoll@Sun.COM
11059126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
11069126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
11079126SWyllys.Ingersoll@Sun.COM goto done;
11089126SWyllys.Ingersoll@Sun.COM }
11099126SWyllys.Ingersoll@Sun.COM
11109126SWyllys.Ingersoll@Sun.COM if (! phObject || ! pulObjectCount) {
11119126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
11129126SWyllys.Ingersoll@Sun.COM goto done;
11139126SWyllys.Ingersoll@Sun.COM }
11149126SWyllys.Ingersoll@Sun.COM
11159126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
11169126SWyllys.Ingersoll@Sun.COM if (! sess) {
11179126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
11189126SWyllys.Ingersoll@Sun.COM goto done;
11199126SWyllys.Ingersoll@Sun.COM }
11209126SWyllys.Ingersoll@Sun.COM
11219126SWyllys.Ingersoll@Sun.COM if (sess->find_active == FALSE) {
11229126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
11239126SWyllys.Ingersoll@Sun.COM goto done;
11249126SWyllys.Ingersoll@Sun.COM }
11259126SWyllys.Ingersoll@Sun.COM
11269126SWyllys.Ingersoll@Sun.COM if (! sess->find_list) {
11279126SWyllys.Ingersoll@Sun.COM rc = CKR_FUNCTION_FAILED;
11289126SWyllys.Ingersoll@Sun.COM goto done;
11299126SWyllys.Ingersoll@Sun.COM }
11309126SWyllys.Ingersoll@Sun.COM count = MIN(ulMaxObjectCount, (sess->find_count - sess->find_idx));
11319126SWyllys.Ingersoll@Sun.COM
11329126SWyllys.Ingersoll@Sun.COM (void) memcpy(phObject, sess->find_list + sess->find_idx,
11339126SWyllys.Ingersoll@Sun.COM count * sizeof (CK_OBJECT_HANDLE));
11349126SWyllys.Ingersoll@Sun.COM *pulObjectCount = count;
11359126SWyllys.Ingersoll@Sun.COM
11369126SWyllys.Ingersoll@Sun.COM sess->find_idx += count;
11379126SWyllys.Ingersoll@Sun.COM rc = CKR_OK;
11389126SWyllys.Ingersoll@Sun.COM
11399126SWyllys.Ingersoll@Sun.COM done:
11409126SWyllys.Ingersoll@Sun.COM return (rc);
11419126SWyllys.Ingersoll@Sun.COM }
11429126SWyllys.Ingersoll@Sun.COM
11439126SWyllys.Ingersoll@Sun.COM CK_RV
SC_FindObjectsFinal(ST_SESSION_HANDLE sSession)11449126SWyllys.Ingersoll@Sun.COM SC_FindObjectsFinal(ST_SESSION_HANDLE sSession)
11459126SWyllys.Ingersoll@Sun.COM {
11469126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
11479126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
11489126SWyllys.Ingersoll@Sun.COM SESS_SET
11499126SWyllys.Ingersoll@Sun.COM
11509126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
11519126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
11529126SWyllys.Ingersoll@Sun.COM goto done;
11539126SWyllys.Ingersoll@Sun.COM }
11549126SWyllys.Ingersoll@Sun.COM
11559126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
11569126SWyllys.Ingersoll@Sun.COM if (! sess) {
11579126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
11589126SWyllys.Ingersoll@Sun.COM goto done;
11599126SWyllys.Ingersoll@Sun.COM }
11609126SWyllys.Ingersoll@Sun.COM
11619126SWyllys.Ingersoll@Sun.COM if (sess->find_active == FALSE) {
11629126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
11639126SWyllys.Ingersoll@Sun.COM goto done;
11649126SWyllys.Ingersoll@Sun.COM }
11659126SWyllys.Ingersoll@Sun.COM
11669126SWyllys.Ingersoll@Sun.COM if (sess->find_list)
11679126SWyllys.Ingersoll@Sun.COM free(sess->find_list);
11689126SWyllys.Ingersoll@Sun.COM
11699126SWyllys.Ingersoll@Sun.COM sess->find_list = NULL;
11709126SWyllys.Ingersoll@Sun.COM sess->find_len = 0;
11719126SWyllys.Ingersoll@Sun.COM sess->find_idx = 0;
11729126SWyllys.Ingersoll@Sun.COM sess->find_active = FALSE;
11739126SWyllys.Ingersoll@Sun.COM
11749126SWyllys.Ingersoll@Sun.COM rc = CKR_OK;
11759126SWyllys.Ingersoll@Sun.COM
11769126SWyllys.Ingersoll@Sun.COM done:
11779126SWyllys.Ingersoll@Sun.COM return (rc);
11789126SWyllys.Ingersoll@Sun.COM }
11799126SWyllys.Ingersoll@Sun.COM
11809126SWyllys.Ingersoll@Sun.COM CK_RV
SC_EncryptInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)11819126SWyllys.Ingersoll@Sun.COM SC_EncryptInit(ST_SESSION_HANDLE sSession,
11829126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
11839126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
11849126SWyllys.Ingersoll@Sun.COM {
11859126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
11869126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
11879126SWyllys.Ingersoll@Sun.COM SESS_SET
11889126SWyllys.Ingersoll@Sun.COM
11899126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
11909126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
11919126SWyllys.Ingersoll@Sun.COM goto done;
11929126SWyllys.Ingersoll@Sun.COM }
11939126SWyllys.Ingersoll@Sun.COM
11949126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
11959126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
11969126SWyllys.Ingersoll@Sun.COM goto done;
11979126SWyllys.Ingersoll@Sun.COM }
11989126SWyllys.Ingersoll@Sun.COM
11999126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
12009126SWyllys.Ingersoll@Sun.COM
12019126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
12029126SWyllys.Ingersoll@Sun.COM if (! sess) {
12039126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
12049126SWyllys.Ingersoll@Sun.COM goto done;
12059126SWyllys.Ingersoll@Sun.COM }
12069126SWyllys.Ingersoll@Sun.COM
12079126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
12089126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
12099126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
12109126SWyllys.Ingersoll@Sun.COM goto done;
12119126SWyllys.Ingersoll@Sun.COM }
12129126SWyllys.Ingersoll@Sun.COM
12139126SWyllys.Ingersoll@Sun.COM if (sess->encr_ctx.active == TRUE) {
12149126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
12159126SWyllys.Ingersoll@Sun.COM goto done;
12169126SWyllys.Ingersoll@Sun.COM }
12179126SWyllys.Ingersoll@Sun.COM
12189126SWyllys.Ingersoll@Sun.COM rc = encr_mgr_init(sess, &sess->encr_ctx, OP_ENCRYPT_INIT,
12199126SWyllys.Ingersoll@Sun.COM pMechanism, hKey);
12209126SWyllys.Ingersoll@Sun.COM done:
12219126SWyllys.Ingersoll@Sun.COM return (rc);
12229126SWyllys.Ingersoll@Sun.COM }
12239126SWyllys.Ingersoll@Sun.COM
12249126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Encrypt(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pEncryptedData,CK_ULONG_PTR pulEncryptedDataLen)12259126SWyllys.Ingersoll@Sun.COM SC_Encrypt(ST_SESSION_HANDLE sSession,
12269126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
12279126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
12289126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedData,
12299126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulEncryptedDataLen)
12309126SWyllys.Ingersoll@Sun.COM {
12319126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
12329126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
12339126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
12349126SWyllys.Ingersoll@Sun.COM SESS_SET
12359126SWyllys.Ingersoll@Sun.COM
12369126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
12379126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
12389126SWyllys.Ingersoll@Sun.COM goto done;
12399126SWyllys.Ingersoll@Sun.COM }
12409126SWyllys.Ingersoll@Sun.COM
12419126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
12429126SWyllys.Ingersoll@Sun.COM if (! sess) {
12439126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
12449126SWyllys.Ingersoll@Sun.COM goto done;
12459126SWyllys.Ingersoll@Sun.COM }
12469126SWyllys.Ingersoll@Sun.COM
12479453SWyllys.Ingersoll@Sun.COM if (! pData || ! pulEncryptedDataLen) {
12489453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
12499453SWyllys.Ingersoll@Sun.COM goto done;
12509453SWyllys.Ingersoll@Sun.COM }
12519126SWyllys.Ingersoll@Sun.COM if (sess->encr_ctx.active == FALSE) {
12529126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
12539126SWyllys.Ingersoll@Sun.COM goto done;
12549126SWyllys.Ingersoll@Sun.COM }
12559126SWyllys.Ingersoll@Sun.COM
12569126SWyllys.Ingersoll@Sun.COM if (! pEncryptedData)
12579126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
12589126SWyllys.Ingersoll@Sun.COM
12599126SWyllys.Ingersoll@Sun.COM rc = encr_mgr_encrypt(sess, length_only,
12609126SWyllys.Ingersoll@Sun.COM &sess->encr_ctx, pData, ulDataLen,
12619126SWyllys.Ingersoll@Sun.COM pEncryptedData, pulEncryptedDataLen);
12629126SWyllys.Ingersoll@Sun.COM
12639126SWyllys.Ingersoll@Sun.COM done:
12649126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
12659126SWyllys.Ingersoll@Sun.COM (void) encr_mgr_cleanup(&sess->encr_ctx);
12669126SWyllys.Ingersoll@Sun.COM
12679126SWyllys.Ingersoll@Sun.COM return (rc);
12689126SWyllys.Ingersoll@Sun.COM }
12699126SWyllys.Ingersoll@Sun.COM
12709126SWyllys.Ingersoll@Sun.COM #if 0
12719126SWyllys.Ingersoll@Sun.COM CK_RV
12729126SWyllys.Ingersoll@Sun.COM SC_EncryptUpdate(ST_SESSION_HANDLE sSession,
12739126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
12749126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen,
12759126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
12769126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulEncryptedPartLen)
12779126SWyllys.Ingersoll@Sun.COM {
12789126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
12799126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
12809126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
12819126SWyllys.Ingersoll@Sun.COM SESS_SET
12829126SWyllys.Ingersoll@Sun.COM
12839126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
12849126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
12859126SWyllys.Ingersoll@Sun.COM goto done;
12869126SWyllys.Ingersoll@Sun.COM }
12879126SWyllys.Ingersoll@Sun.COM
12889126SWyllys.Ingersoll@Sun.COM if (! pPart || ! pulEncryptedPartLen) {
12899126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
12909126SWyllys.Ingersoll@Sun.COM goto done;
12919126SWyllys.Ingersoll@Sun.COM }
12929126SWyllys.Ingersoll@Sun.COM
12939126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
12949126SWyllys.Ingersoll@Sun.COM if (! sess) {
12959126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
12969126SWyllys.Ingersoll@Sun.COM goto done;
12979126SWyllys.Ingersoll@Sun.COM }
12989126SWyllys.Ingersoll@Sun.COM
12999126SWyllys.Ingersoll@Sun.COM if (sess->encr_ctx.active == FALSE) {
13009126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
13019126SWyllys.Ingersoll@Sun.COM goto done;
13029126SWyllys.Ingersoll@Sun.COM }
13039126SWyllys.Ingersoll@Sun.COM
13049126SWyllys.Ingersoll@Sun.COM if (! pEncryptedPart)
13059126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
13069126SWyllys.Ingersoll@Sun.COM
13079126SWyllys.Ingersoll@Sun.COM rc = encr_mgr_encrypt_update(sess, length_only,
13089126SWyllys.Ingersoll@Sun.COM &sess->encr_ctx, pPart, ulPartLen,
13099126SWyllys.Ingersoll@Sun.COM pEncryptedPart, pulEncryptedPartLen);
13109126SWyllys.Ingersoll@Sun.COM
13119126SWyllys.Ingersoll@Sun.COM done:
13129126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK && rc != CKR_BUFFER_TOO_SMALL)
13139126SWyllys.Ingersoll@Sun.COM (void) encr_mgr_cleanup(&sess->encr_ctx);
13149126SWyllys.Ingersoll@Sun.COM
13159126SWyllys.Ingersoll@Sun.COM return (rc);
13169126SWyllys.Ingersoll@Sun.COM }
13179126SWyllys.Ingersoll@Sun.COM
13189126SWyllys.Ingersoll@Sun.COM CK_RV
13199126SWyllys.Ingersoll@Sun.COM SC_EncryptFinal(ST_SESSION_HANDLE sSession,
13209126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pLastEncryptedPart,
13219126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulLastEncryptedPartLen)
13229126SWyllys.Ingersoll@Sun.COM {
13239126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
13249126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
13259126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
13269126SWyllys.Ingersoll@Sun.COM SESS_SET
13279126SWyllys.Ingersoll@Sun.COM
13289126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
13299126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
13309126SWyllys.Ingersoll@Sun.COM goto done;
13319126SWyllys.Ingersoll@Sun.COM }
13329126SWyllys.Ingersoll@Sun.COM
13339126SWyllys.Ingersoll@Sun.COM if (! pulLastEncryptedPartLen) {
13349126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
13359126SWyllys.Ingersoll@Sun.COM goto done;
13369126SWyllys.Ingersoll@Sun.COM }
13379126SWyllys.Ingersoll@Sun.COM
13389126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
13399126SWyllys.Ingersoll@Sun.COM if (! sess) {
13409126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
13419126SWyllys.Ingersoll@Sun.COM goto done;
13429126SWyllys.Ingersoll@Sun.COM }
13439126SWyllys.Ingersoll@Sun.COM
13449126SWyllys.Ingersoll@Sun.COM if (sess->encr_ctx.active == FALSE) {
13459126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
13469126SWyllys.Ingersoll@Sun.COM goto done;
13479126SWyllys.Ingersoll@Sun.COM }
13489126SWyllys.Ingersoll@Sun.COM
13499126SWyllys.Ingersoll@Sun.COM if (! pLastEncryptedPart)
13509126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
13519126SWyllys.Ingersoll@Sun.COM
13529126SWyllys.Ingersoll@Sun.COM rc = encr_mgr_encrypt_final(sess, length_only, &sess->encr_ctx,
13539126SWyllys.Ingersoll@Sun.COM pLastEncryptedPart, pulLastEncryptedPartLen);
13549126SWyllys.Ingersoll@Sun.COM
13559126SWyllys.Ingersoll@Sun.COM done:
13569126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
13579126SWyllys.Ingersoll@Sun.COM (void) encr_mgr_cleanup(&sess->encr_ctx);
13589126SWyllys.Ingersoll@Sun.COM
13599126SWyllys.Ingersoll@Sun.COM return (rc);
13609126SWyllys.Ingersoll@Sun.COM }
13619126SWyllys.Ingersoll@Sun.COM #endif
13629126SWyllys.Ingersoll@Sun.COM
13639126SWyllys.Ingersoll@Sun.COM CK_RV
SC_DecryptInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)13649126SWyllys.Ingersoll@Sun.COM SC_DecryptInit(ST_SESSION_HANDLE sSession,
13659126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
13669126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
13679126SWyllys.Ingersoll@Sun.COM {
13689126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
13699126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
13709126SWyllys.Ingersoll@Sun.COM SESS_SET
13719126SWyllys.Ingersoll@Sun.COM
13729126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
13739126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
13749126SWyllys.Ingersoll@Sun.COM goto done;
13759126SWyllys.Ingersoll@Sun.COM }
13769126SWyllys.Ingersoll@Sun.COM
13779126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
13789126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
13799126SWyllys.Ingersoll@Sun.COM goto done;
13809126SWyllys.Ingersoll@Sun.COM }
13819126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
13829126SWyllys.Ingersoll@Sun.COM
13839126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
13849126SWyllys.Ingersoll@Sun.COM if (! sess) {
13859126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
13869126SWyllys.Ingersoll@Sun.COM goto done;
13879126SWyllys.Ingersoll@Sun.COM }
13889126SWyllys.Ingersoll@Sun.COM
13899126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
13909126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
13919126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
13929126SWyllys.Ingersoll@Sun.COM goto done;
13939126SWyllys.Ingersoll@Sun.COM }
13949126SWyllys.Ingersoll@Sun.COM
13959126SWyllys.Ingersoll@Sun.COM if (sess->decr_ctx.active == TRUE) {
13969126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
13979126SWyllys.Ingersoll@Sun.COM goto done;
13989126SWyllys.Ingersoll@Sun.COM }
13999126SWyllys.Ingersoll@Sun.COM
14009126SWyllys.Ingersoll@Sun.COM rc = decr_mgr_init(sess, &sess->decr_ctx,
14019126SWyllys.Ingersoll@Sun.COM OP_DECRYPT_INIT, pMechanism, hKey);
14029126SWyllys.Ingersoll@Sun.COM
14039126SWyllys.Ingersoll@Sun.COM done:
14049126SWyllys.Ingersoll@Sun.COM return (rc);
14059126SWyllys.Ingersoll@Sun.COM }
14069126SWyllys.Ingersoll@Sun.COM
14079126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Decrypt(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pEncryptedData,CK_ULONG ulEncryptedDataLen,CK_BYTE_PTR pData,CK_ULONG_PTR pulDataLen)14089126SWyllys.Ingersoll@Sun.COM SC_Decrypt(ST_SESSION_HANDLE sSession,
14099126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedData,
14109126SWyllys.Ingersoll@Sun.COM CK_ULONG ulEncryptedDataLen,
14119126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
14129126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDataLen)
14139126SWyllys.Ingersoll@Sun.COM {
14149126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
14159126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
14169126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
14179126SWyllys.Ingersoll@Sun.COM SESS_SET
14189126SWyllys.Ingersoll@Sun.COM
14199126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
14209126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
14219126SWyllys.Ingersoll@Sun.COM goto done;
14229126SWyllys.Ingersoll@Sun.COM }
14239126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
14249126SWyllys.Ingersoll@Sun.COM if (! sess) {
14259126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
14269126SWyllys.Ingersoll@Sun.COM goto done;
14279126SWyllys.Ingersoll@Sun.COM }
14289453SWyllys.Ingersoll@Sun.COM if (! pEncryptedData || ! pulDataLen) {
14299453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
14309453SWyllys.Ingersoll@Sun.COM goto done;
14319453SWyllys.Ingersoll@Sun.COM }
14329126SWyllys.Ingersoll@Sun.COM if (sess->decr_ctx.active == FALSE) {
14339126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
14349126SWyllys.Ingersoll@Sun.COM goto done;
14359126SWyllys.Ingersoll@Sun.COM }
14369126SWyllys.Ingersoll@Sun.COM
14379126SWyllys.Ingersoll@Sun.COM if (! pData)
14389126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
14399126SWyllys.Ingersoll@Sun.COM
14409453SWyllys.Ingersoll@Sun.COM rc = decr_mgr_decrypt(sess,
14419453SWyllys.Ingersoll@Sun.COM length_only,
14429126SWyllys.Ingersoll@Sun.COM &sess->decr_ctx,
14439453SWyllys.Ingersoll@Sun.COM pEncryptedData,
14449453SWyllys.Ingersoll@Sun.COM ulEncryptedDataLen,
14459453SWyllys.Ingersoll@Sun.COM pData,
14469453SWyllys.Ingersoll@Sun.COM pulDataLen);
14479126SWyllys.Ingersoll@Sun.COM
14489126SWyllys.Ingersoll@Sun.COM done:
14499126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
14509126SWyllys.Ingersoll@Sun.COM (void) decr_mgr_cleanup(&sess->decr_ctx);
14519126SWyllys.Ingersoll@Sun.COM
14529126SWyllys.Ingersoll@Sun.COM return (rc);
14539126SWyllys.Ingersoll@Sun.COM }
14549126SWyllys.Ingersoll@Sun.COM
14559126SWyllys.Ingersoll@Sun.COM CK_RV
SC_DigestInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism)14569126SWyllys.Ingersoll@Sun.COM SC_DigestInit(ST_SESSION_HANDLE sSession,
14579126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism)
14589126SWyllys.Ingersoll@Sun.COM {
14599126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
14609126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
14619126SWyllys.Ingersoll@Sun.COM SESS_SET
14629126SWyllys.Ingersoll@Sun.COM
14639126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
14649126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
14659126SWyllys.Ingersoll@Sun.COM goto done;
14669126SWyllys.Ingersoll@Sun.COM }
14679126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
14689126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
14699126SWyllys.Ingersoll@Sun.COM goto done;
14709126SWyllys.Ingersoll@Sun.COM }
14719126SWyllys.Ingersoll@Sun.COM
14729126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
14739126SWyllys.Ingersoll@Sun.COM
14749126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
14759126SWyllys.Ingersoll@Sun.COM if (! sess) {
14769126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
14779126SWyllys.Ingersoll@Sun.COM goto done;
14789126SWyllys.Ingersoll@Sun.COM }
14799126SWyllys.Ingersoll@Sun.COM
14809126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
14819126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
14829126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
14839126SWyllys.Ingersoll@Sun.COM goto done;
14849126SWyllys.Ingersoll@Sun.COM }
14859126SWyllys.Ingersoll@Sun.COM
14869126SWyllys.Ingersoll@Sun.COM if (sess->digest_ctx.active == TRUE) {
14879126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
14889126SWyllys.Ingersoll@Sun.COM goto done;
14899126SWyllys.Ingersoll@Sun.COM }
14909126SWyllys.Ingersoll@Sun.COM
14919126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_init(sess, &sess->digest_ctx, pMechanism);
14929126SWyllys.Ingersoll@Sun.COM
14939126SWyllys.Ingersoll@Sun.COM done:
14949126SWyllys.Ingersoll@Sun.COM return (rc);
14959126SWyllys.Ingersoll@Sun.COM }
14969126SWyllys.Ingersoll@Sun.COM
14979126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Digest(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pDigest,CK_ULONG_PTR pulDigestLen)14989126SWyllys.Ingersoll@Sun.COM SC_Digest(ST_SESSION_HANDLE sSession,
14999126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
15009126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
15019126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pDigest,
15029126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDigestLen)
15039126SWyllys.Ingersoll@Sun.COM {
15049126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
15059126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
15069126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
15079126SWyllys.Ingersoll@Sun.COM SESS_SET
15089126SWyllys.Ingersoll@Sun.COM
15099126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
15109126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
15119126SWyllys.Ingersoll@Sun.COM goto done;
15129126SWyllys.Ingersoll@Sun.COM }
15139126SWyllys.Ingersoll@Sun.COM
15149126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
15159126SWyllys.Ingersoll@Sun.COM if (! sess) {
15169126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
15179126SWyllys.Ingersoll@Sun.COM goto done;
15189126SWyllys.Ingersoll@Sun.COM }
15199126SWyllys.Ingersoll@Sun.COM
15209453SWyllys.Ingersoll@Sun.COM if (! pData || ! pulDigestLen) {
15219453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
15229453SWyllys.Ingersoll@Sun.COM goto done;
15239453SWyllys.Ingersoll@Sun.COM }
15249453SWyllys.Ingersoll@Sun.COM
15259126SWyllys.Ingersoll@Sun.COM if (sess->digest_ctx.active == FALSE) {
15269126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
15279126SWyllys.Ingersoll@Sun.COM goto done;
15289126SWyllys.Ingersoll@Sun.COM }
15299126SWyllys.Ingersoll@Sun.COM
15309126SWyllys.Ingersoll@Sun.COM if (! pDigest)
15319126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
15329126SWyllys.Ingersoll@Sun.COM
15339126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest(sess, length_only,
15349126SWyllys.Ingersoll@Sun.COM &sess->digest_ctx, pData, ulDataLen,
15359126SWyllys.Ingersoll@Sun.COM pDigest, pulDigestLen);
15369126SWyllys.Ingersoll@Sun.COM
15379126SWyllys.Ingersoll@Sun.COM done:
15389126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
15399126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&sess->digest_ctx);
15409126SWyllys.Ingersoll@Sun.COM
15419126SWyllys.Ingersoll@Sun.COM return (rc);
15429126SWyllys.Ingersoll@Sun.COM }
15439126SWyllys.Ingersoll@Sun.COM
15449126SWyllys.Ingersoll@Sun.COM CK_RV
SC_DigestUpdate(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen)15459126SWyllys.Ingersoll@Sun.COM SC_DigestUpdate(ST_SESSION_HANDLE sSession,
15469126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
15479126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen)
15489126SWyllys.Ingersoll@Sun.COM {
15499126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
15509126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
15519126SWyllys.Ingersoll@Sun.COM SESS_SET
15529126SWyllys.Ingersoll@Sun.COM
15539126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
15549126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
15559126SWyllys.Ingersoll@Sun.COM goto done;
15569126SWyllys.Ingersoll@Sun.COM }
15579126SWyllys.Ingersoll@Sun.COM
15589126SWyllys.Ingersoll@Sun.COM if (! pPart && ulPartLen != 0) {
15599126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
15609126SWyllys.Ingersoll@Sun.COM goto done;
15619126SWyllys.Ingersoll@Sun.COM }
15629126SWyllys.Ingersoll@Sun.COM
15639126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
15649126SWyllys.Ingersoll@Sun.COM if (! sess) {
15659126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
15669126SWyllys.Ingersoll@Sun.COM goto done;
15679126SWyllys.Ingersoll@Sun.COM }
15689126SWyllys.Ingersoll@Sun.COM
15699126SWyllys.Ingersoll@Sun.COM if (sess->digest_ctx.active == FALSE) {
15709126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
15719126SWyllys.Ingersoll@Sun.COM goto done;
15729126SWyllys.Ingersoll@Sun.COM }
15739126SWyllys.Ingersoll@Sun.COM
15749126SWyllys.Ingersoll@Sun.COM if (pPart) {
15759126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_update(sess, &sess->digest_ctx,
15769126SWyllys.Ingersoll@Sun.COM pPart, ulPartLen);
15779126SWyllys.Ingersoll@Sun.COM }
15789126SWyllys.Ingersoll@Sun.COM done:
15799126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
15809126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&sess->digest_ctx);
15819126SWyllys.Ingersoll@Sun.COM
15829126SWyllys.Ingersoll@Sun.COM return (rc);
15839126SWyllys.Ingersoll@Sun.COM }
15849126SWyllys.Ingersoll@Sun.COM
15859126SWyllys.Ingersoll@Sun.COM CK_RV
SC_DigestKey(ST_SESSION_HANDLE sSession,CK_OBJECT_HANDLE hKey)15869126SWyllys.Ingersoll@Sun.COM SC_DigestKey(ST_SESSION_HANDLE sSession,
15879126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
15889126SWyllys.Ingersoll@Sun.COM {
15899126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
15909126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
15919126SWyllys.Ingersoll@Sun.COM SESS_SET
15929126SWyllys.Ingersoll@Sun.COM
15939126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
15949126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
15959126SWyllys.Ingersoll@Sun.COM goto done;
15969126SWyllys.Ingersoll@Sun.COM }
15979126SWyllys.Ingersoll@Sun.COM
15989126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
15999126SWyllys.Ingersoll@Sun.COM if (! sess) {
16009126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
16019126SWyllys.Ingersoll@Sun.COM goto done;
16029126SWyllys.Ingersoll@Sun.COM }
16039126SWyllys.Ingersoll@Sun.COM
16049126SWyllys.Ingersoll@Sun.COM if (sess->digest_ctx.active == FALSE) {
16059126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
16069126SWyllys.Ingersoll@Sun.COM goto done;
16079126SWyllys.Ingersoll@Sun.COM }
16089126SWyllys.Ingersoll@Sun.COM
16099126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_key(sess, &sess->digest_ctx, hKey);
16109126SWyllys.Ingersoll@Sun.COM
16119126SWyllys.Ingersoll@Sun.COM done:
16129126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
16139126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&sess->digest_ctx);
16149126SWyllys.Ingersoll@Sun.COM
16159126SWyllys.Ingersoll@Sun.COM return (rc);
16169126SWyllys.Ingersoll@Sun.COM }
16179126SWyllys.Ingersoll@Sun.COM
16189126SWyllys.Ingersoll@Sun.COM CK_RV
SC_DigestFinal(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pDigest,CK_ULONG_PTR pulDigestLen)16199126SWyllys.Ingersoll@Sun.COM SC_DigestFinal(ST_SESSION_HANDLE sSession,
16209126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pDigest,
16219126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDigestLen)
16229126SWyllys.Ingersoll@Sun.COM {
16239126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
16249126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
16259126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
16269126SWyllys.Ingersoll@Sun.COM SESS_SET
16279126SWyllys.Ingersoll@Sun.COM
16289126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
16299126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
16309126SWyllys.Ingersoll@Sun.COM goto done;
16319126SWyllys.Ingersoll@Sun.COM }
16329126SWyllys.Ingersoll@Sun.COM
16339126SWyllys.Ingersoll@Sun.COM if (! pulDigestLen) {
16349126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
16359126SWyllys.Ingersoll@Sun.COM goto done;
16369126SWyllys.Ingersoll@Sun.COM }
16379126SWyllys.Ingersoll@Sun.COM
16389126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
16399126SWyllys.Ingersoll@Sun.COM if (! sess) {
16409126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
16419126SWyllys.Ingersoll@Sun.COM goto done;
16429126SWyllys.Ingersoll@Sun.COM }
16439126SWyllys.Ingersoll@Sun.COM
16449126SWyllys.Ingersoll@Sun.COM if (sess->digest_ctx.active == FALSE) {
16459126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
16469126SWyllys.Ingersoll@Sun.COM goto done;
16479126SWyllys.Ingersoll@Sun.COM }
16489126SWyllys.Ingersoll@Sun.COM
16499126SWyllys.Ingersoll@Sun.COM if (! pDigest)
16509126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
16519126SWyllys.Ingersoll@Sun.COM
16529126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_final(sess,
16539126SWyllys.Ingersoll@Sun.COM &sess->digest_ctx, pDigest, pulDigestLen);
16549126SWyllys.Ingersoll@Sun.COM
16559126SWyllys.Ingersoll@Sun.COM done:
16569126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
16579126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&sess->digest_ctx);
16589126SWyllys.Ingersoll@Sun.COM
16599126SWyllys.Ingersoll@Sun.COM return (rc);
16609126SWyllys.Ingersoll@Sun.COM }
16619126SWyllys.Ingersoll@Sun.COM
16629126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SignInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)16639126SWyllys.Ingersoll@Sun.COM SC_SignInit(ST_SESSION_HANDLE sSession,
16649126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
16659126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
16669126SWyllys.Ingersoll@Sun.COM {
16679126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
16689126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
16699126SWyllys.Ingersoll@Sun.COM SESS_SET
16709126SWyllys.Ingersoll@Sun.COM
16719126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
16729126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
16739126SWyllys.Ingersoll@Sun.COM goto done;
16749126SWyllys.Ingersoll@Sun.COM }
16759126SWyllys.Ingersoll@Sun.COM
16769126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
16779126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
16789126SWyllys.Ingersoll@Sun.COM goto done;
16799126SWyllys.Ingersoll@Sun.COM }
16809126SWyllys.Ingersoll@Sun.COM
16819126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
16829126SWyllys.Ingersoll@Sun.COM if (! sess) {
16839126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
16849126SWyllys.Ingersoll@Sun.COM goto done;
16859126SWyllys.Ingersoll@Sun.COM }
16869126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
16879126SWyllys.Ingersoll@Sun.COM
16889126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
16899126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
16909126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
16919126SWyllys.Ingersoll@Sun.COM goto done;
16929126SWyllys.Ingersoll@Sun.COM }
16939126SWyllys.Ingersoll@Sun.COM
16949126SWyllys.Ingersoll@Sun.COM if (sess->sign_ctx.active == TRUE) {
16959126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
16969126SWyllys.Ingersoll@Sun.COM goto done;
16979126SWyllys.Ingersoll@Sun.COM }
16989126SWyllys.Ingersoll@Sun.COM
16999126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_init(sess, &sess->sign_ctx, pMechanism, FALSE, hKey);
17009126SWyllys.Ingersoll@Sun.COM
17019126SWyllys.Ingersoll@Sun.COM done:
17029126SWyllys.Ingersoll@Sun.COM return (rc);
17039126SWyllys.Ingersoll@Sun.COM }
17049126SWyllys.Ingersoll@Sun.COM
17059126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Sign(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pSignature,CK_ULONG_PTR pulSignatureLen)17069126SWyllys.Ingersoll@Sun.COM SC_Sign(ST_SESSION_HANDLE sSession,
17079126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
17089126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
17099126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
17109126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSignatureLen)
17119126SWyllys.Ingersoll@Sun.COM {
17129126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
17139126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
17149126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
17159126SWyllys.Ingersoll@Sun.COM SESS_SET
17169126SWyllys.Ingersoll@Sun.COM
17179126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
17189126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
17199126SWyllys.Ingersoll@Sun.COM goto done;
17209126SWyllys.Ingersoll@Sun.COM }
17219126SWyllys.Ingersoll@Sun.COM
17229126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
17239126SWyllys.Ingersoll@Sun.COM if (! sess) {
17249126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
17259126SWyllys.Ingersoll@Sun.COM goto done;
17269126SWyllys.Ingersoll@Sun.COM }
17279453SWyllys.Ingersoll@Sun.COM if (!pData || !pulSignatureLen) {
17289453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
17299453SWyllys.Ingersoll@Sun.COM goto done;
17309453SWyllys.Ingersoll@Sun.COM }
17319126SWyllys.Ingersoll@Sun.COM
17329126SWyllys.Ingersoll@Sun.COM if (sess->sign_ctx.active == FALSE) {
17339126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
17349126SWyllys.Ingersoll@Sun.COM goto done;
17359126SWyllys.Ingersoll@Sun.COM }
17369126SWyllys.Ingersoll@Sun.COM
17379126SWyllys.Ingersoll@Sun.COM if (! pSignature)
17389126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
17399126SWyllys.Ingersoll@Sun.COM
17409126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_sign(sess, length_only,
17419126SWyllys.Ingersoll@Sun.COM &sess->sign_ctx, pData, ulDataLen,
17429126SWyllys.Ingersoll@Sun.COM pSignature, pulSignatureLen);
17439126SWyllys.Ingersoll@Sun.COM
17449126SWyllys.Ingersoll@Sun.COM done:
17459126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
17469126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&sess->sign_ctx);
17479126SWyllys.Ingersoll@Sun.COM
17489126SWyllys.Ingersoll@Sun.COM return (rc);
17499126SWyllys.Ingersoll@Sun.COM }
17509126SWyllys.Ingersoll@Sun.COM
17519126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SignUpdate(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen)17529126SWyllys.Ingersoll@Sun.COM SC_SignUpdate(ST_SESSION_HANDLE sSession,
17539126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
17549126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen)
17559126SWyllys.Ingersoll@Sun.COM {
17569126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
17579126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
17589126SWyllys.Ingersoll@Sun.COM SESS_SET
17599126SWyllys.Ingersoll@Sun.COM
17609126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
17619126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
17629126SWyllys.Ingersoll@Sun.COM goto done;
17639126SWyllys.Ingersoll@Sun.COM }
17649126SWyllys.Ingersoll@Sun.COM
17659126SWyllys.Ingersoll@Sun.COM if (! pPart) {
17669126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
17679126SWyllys.Ingersoll@Sun.COM goto done;
17689126SWyllys.Ingersoll@Sun.COM }
17699126SWyllys.Ingersoll@Sun.COM
17709126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
17719126SWyllys.Ingersoll@Sun.COM if (! sess) {
17729126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
17739126SWyllys.Ingersoll@Sun.COM goto done;
17749126SWyllys.Ingersoll@Sun.COM }
17759126SWyllys.Ingersoll@Sun.COM
17769126SWyllys.Ingersoll@Sun.COM if (sess->sign_ctx.active == FALSE) {
17779126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
17789126SWyllys.Ingersoll@Sun.COM goto done;
17799126SWyllys.Ingersoll@Sun.COM }
17809126SWyllys.Ingersoll@Sun.COM
17819126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_sign_update(sess, &sess->sign_ctx, pPart, ulPartLen);
17829126SWyllys.Ingersoll@Sun.COM
17839126SWyllys.Ingersoll@Sun.COM done:
17849126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
17859126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&sess->sign_ctx);
17869126SWyllys.Ingersoll@Sun.COM
17879126SWyllys.Ingersoll@Sun.COM return (rc);
17889126SWyllys.Ingersoll@Sun.COM }
17899126SWyllys.Ingersoll@Sun.COM
17909126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SignFinal(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pSignature,CK_ULONG_PTR pulSignatureLen)17919126SWyllys.Ingersoll@Sun.COM SC_SignFinal(ST_SESSION_HANDLE sSession,
17929126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
17939126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSignatureLen)
17949126SWyllys.Ingersoll@Sun.COM {
17959126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
17969126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
17979126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
17989126SWyllys.Ingersoll@Sun.COM SESS_SET
17999126SWyllys.Ingersoll@Sun.COM
18009126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
18019126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
18029126SWyllys.Ingersoll@Sun.COM goto done;
18039126SWyllys.Ingersoll@Sun.COM }
18049126SWyllys.Ingersoll@Sun.COM
18059126SWyllys.Ingersoll@Sun.COM if (! pulSignatureLen) {
18069126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
18079126SWyllys.Ingersoll@Sun.COM goto done;
18089126SWyllys.Ingersoll@Sun.COM }
18099126SWyllys.Ingersoll@Sun.COM
18109126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
18119126SWyllys.Ingersoll@Sun.COM if (! sess) {
18129126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
18139126SWyllys.Ingersoll@Sun.COM goto done;
18149126SWyllys.Ingersoll@Sun.COM }
18159126SWyllys.Ingersoll@Sun.COM
18169126SWyllys.Ingersoll@Sun.COM if (sess->sign_ctx.active == FALSE) {
18179126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
18189126SWyllys.Ingersoll@Sun.COM goto done;
18199126SWyllys.Ingersoll@Sun.COM }
18209126SWyllys.Ingersoll@Sun.COM
18219126SWyllys.Ingersoll@Sun.COM if (! pSignature)
18229126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
18239126SWyllys.Ingersoll@Sun.COM
18249126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_sign_final(sess, length_only,
18259126SWyllys.Ingersoll@Sun.COM &sess->sign_ctx, pSignature, pulSignatureLen);
18269126SWyllys.Ingersoll@Sun.COM
18279126SWyllys.Ingersoll@Sun.COM done:
18289126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
18299126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&sess->sign_ctx);
18309126SWyllys.Ingersoll@Sun.COM
18319126SWyllys.Ingersoll@Sun.COM return (rc);
18329126SWyllys.Ingersoll@Sun.COM }
18339126SWyllys.Ingersoll@Sun.COM
18349126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SignRecoverInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)18359126SWyllys.Ingersoll@Sun.COM SC_SignRecoverInit(ST_SESSION_HANDLE sSession,
18369126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
18379126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
18389126SWyllys.Ingersoll@Sun.COM {
18399126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
18409126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
18419126SWyllys.Ingersoll@Sun.COM SESS_SET
18429126SWyllys.Ingersoll@Sun.COM
18439126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
18449126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
18459126SWyllys.Ingersoll@Sun.COM goto done;
18469126SWyllys.Ingersoll@Sun.COM }
18479126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
18489126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
18499126SWyllys.Ingersoll@Sun.COM goto done;
18509126SWyllys.Ingersoll@Sun.COM }
18519126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
18529126SWyllys.Ingersoll@Sun.COM
18539126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
18549126SWyllys.Ingersoll@Sun.COM if (! sess) {
18559126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
18569126SWyllys.Ingersoll@Sun.COM goto done;
18579126SWyllys.Ingersoll@Sun.COM }
18589126SWyllys.Ingersoll@Sun.COM
18599126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
18609126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
18619126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
18629126SWyllys.Ingersoll@Sun.COM goto done;
18639126SWyllys.Ingersoll@Sun.COM }
18649126SWyllys.Ingersoll@Sun.COM
18659126SWyllys.Ingersoll@Sun.COM if (sess->sign_ctx.active == TRUE) {
18669126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
18679126SWyllys.Ingersoll@Sun.COM goto done;
18689126SWyllys.Ingersoll@Sun.COM }
18699126SWyllys.Ingersoll@Sun.COM
18709126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_init(sess, &sess->sign_ctx, pMechanism, TRUE, hKey);
18719126SWyllys.Ingersoll@Sun.COM
18729126SWyllys.Ingersoll@Sun.COM done:
18739126SWyllys.Ingersoll@Sun.COM return (rc);
18749126SWyllys.Ingersoll@Sun.COM }
18759126SWyllys.Ingersoll@Sun.COM
18769126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SignRecover(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pSignature,CK_ULONG_PTR pulSignatureLen)18779126SWyllys.Ingersoll@Sun.COM SC_SignRecover(ST_SESSION_HANDLE sSession,
18789126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
18799126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
18809126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
18819126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSignatureLen)
18829126SWyllys.Ingersoll@Sun.COM {
18839126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
18849126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
18859126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
18869126SWyllys.Ingersoll@Sun.COM SESS_SET
18879126SWyllys.Ingersoll@Sun.COM
18889126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
18899126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
18909126SWyllys.Ingersoll@Sun.COM goto done;
18919126SWyllys.Ingersoll@Sun.COM }
18929126SWyllys.Ingersoll@Sun.COM
18939126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
18949126SWyllys.Ingersoll@Sun.COM if (! sess) {
18959126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
18969126SWyllys.Ingersoll@Sun.COM goto done;
18979126SWyllys.Ingersoll@Sun.COM }
18989453SWyllys.Ingersoll@Sun.COM if (!pData || !pulSignatureLen) {
18999453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
19009453SWyllys.Ingersoll@Sun.COM goto done;
19019453SWyllys.Ingersoll@Sun.COM }
19029126SWyllys.Ingersoll@Sun.COM if ((sess->sign_ctx.active == FALSE) ||
19039126SWyllys.Ingersoll@Sun.COM (sess->sign_ctx.recover == FALSE)) {
19049126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
19059126SWyllys.Ingersoll@Sun.COM goto done;
19069126SWyllys.Ingersoll@Sun.COM }
19079126SWyllys.Ingersoll@Sun.COM
19089126SWyllys.Ingersoll@Sun.COM if (! pSignature)
19099126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
19109126SWyllys.Ingersoll@Sun.COM
19119126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_sign_recover(sess, length_only,
19129126SWyllys.Ingersoll@Sun.COM &sess->sign_ctx, pData, ulDataLen,
19139126SWyllys.Ingersoll@Sun.COM pSignature, pulSignatureLen);
19149126SWyllys.Ingersoll@Sun.COM
19159126SWyllys.Ingersoll@Sun.COM done:
19169126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
19179126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&sess->sign_ctx);
19189126SWyllys.Ingersoll@Sun.COM
19199126SWyllys.Ingersoll@Sun.COM return (rc);
19209126SWyllys.Ingersoll@Sun.COM }
19219126SWyllys.Ingersoll@Sun.COM
19229126SWyllys.Ingersoll@Sun.COM CK_RV
SC_VerifyInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)19239126SWyllys.Ingersoll@Sun.COM SC_VerifyInit(ST_SESSION_HANDLE sSession,
19249126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
19259126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
19269126SWyllys.Ingersoll@Sun.COM {
19279126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
19289126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
19299126SWyllys.Ingersoll@Sun.COM SESS_SET
19309126SWyllys.Ingersoll@Sun.COM
19319126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
19329126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
19339126SWyllys.Ingersoll@Sun.COM goto done;
19349126SWyllys.Ingersoll@Sun.COM }
19359126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
19369126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
19379126SWyllys.Ingersoll@Sun.COM goto done;
19389126SWyllys.Ingersoll@Sun.COM }
19399126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
19409126SWyllys.Ingersoll@Sun.COM
19419126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
19429126SWyllys.Ingersoll@Sun.COM if (! sess) {
19439126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
19449126SWyllys.Ingersoll@Sun.COM goto done;
19459126SWyllys.Ingersoll@Sun.COM }
19469126SWyllys.Ingersoll@Sun.COM
19479126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
19489126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
19499126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
19509126SWyllys.Ingersoll@Sun.COM goto done;
19519126SWyllys.Ingersoll@Sun.COM }
19529126SWyllys.Ingersoll@Sun.COM
19539126SWyllys.Ingersoll@Sun.COM if (sess->verify_ctx.active == TRUE) {
19549126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
19559126SWyllys.Ingersoll@Sun.COM goto done;
19569126SWyllys.Ingersoll@Sun.COM }
19579126SWyllys.Ingersoll@Sun.COM
19589126SWyllys.Ingersoll@Sun.COM rc = verify_mgr_init(sess, &sess->verify_ctx, pMechanism, FALSE, hKey);
19599126SWyllys.Ingersoll@Sun.COM
19609126SWyllys.Ingersoll@Sun.COM done:
19619126SWyllys.Ingersoll@Sun.COM return (rc);
19629126SWyllys.Ingersoll@Sun.COM }
19639126SWyllys.Ingersoll@Sun.COM
19649126SWyllys.Ingersoll@Sun.COM CK_RV
SC_Verify(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pSignature,CK_ULONG ulSignatureLen)19659126SWyllys.Ingersoll@Sun.COM SC_Verify(ST_SESSION_HANDLE sSession,
19669126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
19679126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
19689126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
19699126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSignatureLen)
19709126SWyllys.Ingersoll@Sun.COM {
19719126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
19729126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
19739126SWyllys.Ingersoll@Sun.COM SESS_SET
19749126SWyllys.Ingersoll@Sun.COM
19759126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
19769126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
19779126SWyllys.Ingersoll@Sun.COM goto done;
19789126SWyllys.Ingersoll@Sun.COM }
19799453SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
19809453SWyllys.Ingersoll@Sun.COM if (! sess) {
19819453SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
19829453SWyllys.Ingersoll@Sun.COM goto done;
19839453SWyllys.Ingersoll@Sun.COM }
19849126SWyllys.Ingersoll@Sun.COM
19859126SWyllys.Ingersoll@Sun.COM if (! pData || ! pSignature) {
19869126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
19879126SWyllys.Ingersoll@Sun.COM goto done;
19889126SWyllys.Ingersoll@Sun.COM }
19899126SWyllys.Ingersoll@Sun.COM if (sess->verify_ctx.active == FALSE) {
19909126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
19919126SWyllys.Ingersoll@Sun.COM goto done;
19929126SWyllys.Ingersoll@Sun.COM }
19939126SWyllys.Ingersoll@Sun.COM
19949126SWyllys.Ingersoll@Sun.COM rc = verify_mgr_verify(sess,
19959126SWyllys.Ingersoll@Sun.COM &sess->verify_ctx, pData, ulDataLen,
19969126SWyllys.Ingersoll@Sun.COM pSignature, ulSignatureLen);
19979126SWyllys.Ingersoll@Sun.COM
19989126SWyllys.Ingersoll@Sun.COM done:
19999126SWyllys.Ingersoll@Sun.COM (void) verify_mgr_cleanup(&sess->verify_ctx);
20009126SWyllys.Ingersoll@Sun.COM
20019126SWyllys.Ingersoll@Sun.COM return (rc);
20029126SWyllys.Ingersoll@Sun.COM }
20039126SWyllys.Ingersoll@Sun.COM
20049126SWyllys.Ingersoll@Sun.COM CK_RV
SC_VerifyUpdate(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen)20059126SWyllys.Ingersoll@Sun.COM SC_VerifyUpdate(ST_SESSION_HANDLE sSession,
20069126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
20079126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen)
20089126SWyllys.Ingersoll@Sun.COM {
20099126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
20109126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
20119126SWyllys.Ingersoll@Sun.COM SESS_SET
20129126SWyllys.Ingersoll@Sun.COM
20139126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
20149126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
20159126SWyllys.Ingersoll@Sun.COM goto done;
20169126SWyllys.Ingersoll@Sun.COM }
20179126SWyllys.Ingersoll@Sun.COM
20189126SWyllys.Ingersoll@Sun.COM if (! pPart) {
20199126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
20209126SWyllys.Ingersoll@Sun.COM goto done;
20219126SWyllys.Ingersoll@Sun.COM }
20229126SWyllys.Ingersoll@Sun.COM
20239126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
20249126SWyllys.Ingersoll@Sun.COM if (! sess) {
20259126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
20269126SWyllys.Ingersoll@Sun.COM goto done;
20279126SWyllys.Ingersoll@Sun.COM }
20289126SWyllys.Ingersoll@Sun.COM
20299126SWyllys.Ingersoll@Sun.COM if (sess->verify_ctx.active == FALSE) {
20309126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
20319126SWyllys.Ingersoll@Sun.COM goto done;
20329126SWyllys.Ingersoll@Sun.COM }
20339126SWyllys.Ingersoll@Sun.COM
20349126SWyllys.Ingersoll@Sun.COM rc = verify_mgr_verify_update(sess, &sess->verify_ctx,
20359126SWyllys.Ingersoll@Sun.COM pPart, ulPartLen);
20369126SWyllys.Ingersoll@Sun.COM done:
20379126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
20389126SWyllys.Ingersoll@Sun.COM (void) verify_mgr_cleanup(&sess->verify_ctx);
20399126SWyllys.Ingersoll@Sun.COM
20409126SWyllys.Ingersoll@Sun.COM return (rc);
20419126SWyllys.Ingersoll@Sun.COM }
20429126SWyllys.Ingersoll@Sun.COM
20439126SWyllys.Ingersoll@Sun.COM CK_RV
SC_VerifyFinal(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pSignature,CK_ULONG ulSignatureLen)20449126SWyllys.Ingersoll@Sun.COM SC_VerifyFinal(ST_SESSION_HANDLE sSession,
20459126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
20469126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSignatureLen)
20479126SWyllys.Ingersoll@Sun.COM {
20489126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
20499126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
20509126SWyllys.Ingersoll@Sun.COM SESS_SET
20519126SWyllys.Ingersoll@Sun.COM
20529126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
20539126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
20549126SWyllys.Ingersoll@Sun.COM goto done;
20559126SWyllys.Ingersoll@Sun.COM }
20569126SWyllys.Ingersoll@Sun.COM
20579126SWyllys.Ingersoll@Sun.COM if (! pSignature) {
20589126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
20599126SWyllys.Ingersoll@Sun.COM goto done;
20609126SWyllys.Ingersoll@Sun.COM }
20619126SWyllys.Ingersoll@Sun.COM
20629126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
20639126SWyllys.Ingersoll@Sun.COM if (! sess) {
20649126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
20659126SWyllys.Ingersoll@Sun.COM goto done;
20669126SWyllys.Ingersoll@Sun.COM }
20679126SWyllys.Ingersoll@Sun.COM
20689126SWyllys.Ingersoll@Sun.COM if (sess->verify_ctx.active == FALSE) {
20699126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
20709126SWyllys.Ingersoll@Sun.COM goto done;
20719126SWyllys.Ingersoll@Sun.COM }
20729126SWyllys.Ingersoll@Sun.COM
20739126SWyllys.Ingersoll@Sun.COM rc = verify_mgr_verify_final(sess, &sess->verify_ctx,
20749126SWyllys.Ingersoll@Sun.COM pSignature, ulSignatureLen);
20759126SWyllys.Ingersoll@Sun.COM
20769126SWyllys.Ingersoll@Sun.COM done:
20779126SWyllys.Ingersoll@Sun.COM (void) verify_mgr_cleanup(&sess->verify_ctx);
20789126SWyllys.Ingersoll@Sun.COM
20799126SWyllys.Ingersoll@Sun.COM return (rc);
20809126SWyllys.Ingersoll@Sun.COM }
20819126SWyllys.Ingersoll@Sun.COM
20829126SWyllys.Ingersoll@Sun.COM CK_RV
SC_VerifyRecoverInit(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)20839126SWyllys.Ingersoll@Sun.COM SC_VerifyRecoverInit(ST_SESSION_HANDLE sSession,
20849126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
20859126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
20869126SWyllys.Ingersoll@Sun.COM {
20879126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
20889126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
20899126SWyllys.Ingersoll@Sun.COM SESS_SET
20909126SWyllys.Ingersoll@Sun.COM
20919126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
20929126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
20939126SWyllys.Ingersoll@Sun.COM goto done;
20949126SWyllys.Ingersoll@Sun.COM }
20959126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
20969126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
20979126SWyllys.Ingersoll@Sun.COM goto done;
20989126SWyllys.Ingersoll@Sun.COM }
20999126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
21009126SWyllys.Ingersoll@Sun.COM
21019126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
21029126SWyllys.Ingersoll@Sun.COM if (! sess) {
21039126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
21049126SWyllys.Ingersoll@Sun.COM goto done;
21059126SWyllys.Ingersoll@Sun.COM }
21069126SWyllys.Ingersoll@Sun.COM
21079126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
21089126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
21099126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
21109126SWyllys.Ingersoll@Sun.COM goto done;
21119126SWyllys.Ingersoll@Sun.COM }
21129126SWyllys.Ingersoll@Sun.COM
21139126SWyllys.Ingersoll@Sun.COM if (sess->verify_ctx.active == TRUE) {
21149126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_ACTIVE;
21159126SWyllys.Ingersoll@Sun.COM goto done;
21169126SWyllys.Ingersoll@Sun.COM }
21179126SWyllys.Ingersoll@Sun.COM
21189126SWyllys.Ingersoll@Sun.COM rc = verify_mgr_init(sess, &sess->verify_ctx, pMechanism, TRUE, hKey);
21199126SWyllys.Ingersoll@Sun.COM
21209126SWyllys.Ingersoll@Sun.COM done:
21219126SWyllys.Ingersoll@Sun.COM return (rc);
21229126SWyllys.Ingersoll@Sun.COM }
21239126SWyllys.Ingersoll@Sun.COM
21249126SWyllys.Ingersoll@Sun.COM CK_RV
SC_VerifyRecover(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pSignature,CK_ULONG ulSignatureLen,CK_BYTE_PTR pData,CK_ULONG_PTR pulDataLen)21259126SWyllys.Ingersoll@Sun.COM SC_VerifyRecover(ST_SESSION_HANDLE sSession,
21269126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
21279126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSignatureLen,
21289126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
21299126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDataLen)
21309126SWyllys.Ingersoll@Sun.COM {
21319126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
21329126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
21339126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
21349126SWyllys.Ingersoll@Sun.COM SESS_SET
21359126SWyllys.Ingersoll@Sun.COM
21369126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
21379126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
21389126SWyllys.Ingersoll@Sun.COM goto done;
21399126SWyllys.Ingersoll@Sun.COM }
21409126SWyllys.Ingersoll@Sun.COM
21419126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
21429126SWyllys.Ingersoll@Sun.COM if (! sess) {
21439126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
21449126SWyllys.Ingersoll@Sun.COM goto done;
21459126SWyllys.Ingersoll@Sun.COM }
21469453SWyllys.Ingersoll@Sun.COM if (!pSignature || !pulDataLen) {
21479453SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
21489453SWyllys.Ingersoll@Sun.COM goto done;
21499453SWyllys.Ingersoll@Sun.COM }
21509126SWyllys.Ingersoll@Sun.COM
21519126SWyllys.Ingersoll@Sun.COM if ((sess->verify_ctx.active == FALSE) ||
21529126SWyllys.Ingersoll@Sun.COM (sess->verify_ctx.recover == FALSE)) {
21539126SWyllys.Ingersoll@Sun.COM rc = CKR_OPERATION_NOT_INITIALIZED;
21549126SWyllys.Ingersoll@Sun.COM goto done;
21559126SWyllys.Ingersoll@Sun.COM }
21569126SWyllys.Ingersoll@Sun.COM if (! pData)
21579126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
21589126SWyllys.Ingersoll@Sun.COM
21599126SWyllys.Ingersoll@Sun.COM rc = verify_mgr_verify_recover(sess, length_only,
21609126SWyllys.Ingersoll@Sun.COM &sess->verify_ctx, pSignature, ulSignatureLen,
21619126SWyllys.Ingersoll@Sun.COM pData, pulDataLen);
21629126SWyllys.Ingersoll@Sun.COM
21639126SWyllys.Ingersoll@Sun.COM done:
21649126SWyllys.Ingersoll@Sun.COM if (rc != CKR_BUFFER_TOO_SMALL && (rc != CKR_OK || length_only != TRUE))
21659126SWyllys.Ingersoll@Sun.COM (void) verify_mgr_cleanup(&sess->verify_ctx);
21669126SWyllys.Ingersoll@Sun.COM
21679126SWyllys.Ingersoll@Sun.COM return (rc);
21689126SWyllys.Ingersoll@Sun.COM }
21699126SWyllys.Ingersoll@Sun.COM
21709126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GenerateKeyPair(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_ATTRIBUTE_PTR pPublicKeyTemplate,CK_ULONG ulPublicKeyAttributeCount,CK_ATTRIBUTE_PTR pPrivateKeyTemplate,CK_ULONG ulPrivateKeyAttributeCount,CK_OBJECT_HANDLE_PTR phPublicKey,CK_OBJECT_HANDLE_PTR phPrivateKey)21719126SWyllys.Ingersoll@Sun.COM SC_GenerateKeyPair(ST_SESSION_HANDLE sSession,
21729126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
21739126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pPublicKeyTemplate,
21749126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPublicKeyAttributeCount,
21759126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
21769126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPrivateKeyAttributeCount,
21779126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phPublicKey,
21789126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phPrivateKey)
21799126SWyllys.Ingersoll@Sun.COM {
21809126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
21819126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
21829126SWyllys.Ingersoll@Sun.COM SESS_SET
21839126SWyllys.Ingersoll@Sun.COM
21849126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
21859126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
21869126SWyllys.Ingersoll@Sun.COM goto done;
21879126SWyllys.Ingersoll@Sun.COM }
21889126SWyllys.Ingersoll@Sun.COM
21899126SWyllys.Ingersoll@Sun.COM if (! pMechanism || ! phPublicKey || ! phPrivateKey ||
21909126SWyllys.Ingersoll@Sun.COM (! pPublicKeyTemplate && (ulPublicKeyAttributeCount != 0)) ||
21919126SWyllys.Ingersoll@Sun.COM (! pPrivateKeyTemplate && (ulPrivateKeyAttributeCount != 0))) {
21929126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
21939126SWyllys.Ingersoll@Sun.COM goto done;
21949126SWyllys.Ingersoll@Sun.COM }
21959126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
21969126SWyllys.Ingersoll@Sun.COM
21979126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
21989126SWyllys.Ingersoll@Sun.COM if (! sess) {
21999126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
22009126SWyllys.Ingersoll@Sun.COM goto done;
22019126SWyllys.Ingersoll@Sun.COM }
22029126SWyllys.Ingersoll@Sun.COM
22039126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
22049126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
22059126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
22069126SWyllys.Ingersoll@Sun.COM goto done;
22079126SWyllys.Ingersoll@Sun.COM }
22089126SWyllys.Ingersoll@Sun.COM
22099126SWyllys.Ingersoll@Sun.COM rc = key_mgr_generate_key_pair(sess, pMechanism,
22109126SWyllys.Ingersoll@Sun.COM pPublicKeyTemplate, ulPublicKeyAttributeCount,
22119126SWyllys.Ingersoll@Sun.COM pPrivateKeyTemplate, ulPrivateKeyAttributeCount,
22129126SWyllys.Ingersoll@Sun.COM phPublicKey, phPrivateKey);
22139126SWyllys.Ingersoll@Sun.COM done:
22149126SWyllys.Ingersoll@Sun.COM return (rc);
22159126SWyllys.Ingersoll@Sun.COM }
22169126SWyllys.Ingersoll@Sun.COM
22179126SWyllys.Ingersoll@Sun.COM CK_RV
SC_WrapKey(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hWrappingKey,CK_OBJECT_HANDLE hKey,CK_BYTE_PTR pWrappedKey,CK_ULONG_PTR pulWrappedKeyLen)22189126SWyllys.Ingersoll@Sun.COM SC_WrapKey(ST_SESSION_HANDLE sSession,
22199126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
22209126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hWrappingKey,
22219126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey,
22229126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pWrappedKey,
22239126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulWrappedKeyLen)
22249126SWyllys.Ingersoll@Sun.COM {
22259126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
22269126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only = FALSE;
22279126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
22289126SWyllys.Ingersoll@Sun.COM SESS_SET
22299126SWyllys.Ingersoll@Sun.COM
22309126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
22319126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
22329126SWyllys.Ingersoll@Sun.COM goto done;
22339126SWyllys.Ingersoll@Sun.COM }
22349126SWyllys.Ingersoll@Sun.COM
22359126SWyllys.Ingersoll@Sun.COM if (! pMechanism || ! pulWrappedKeyLen) {
22369126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
22379126SWyllys.Ingersoll@Sun.COM goto done;
22389126SWyllys.Ingersoll@Sun.COM }
22399126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
22409126SWyllys.Ingersoll@Sun.COM
22419126SWyllys.Ingersoll@Sun.COM if (! pWrappedKey)
22429126SWyllys.Ingersoll@Sun.COM length_only = TRUE;
22439126SWyllys.Ingersoll@Sun.COM
22449126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
22459126SWyllys.Ingersoll@Sun.COM if (! sess) {
22469126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
22479126SWyllys.Ingersoll@Sun.COM goto done;
22489126SWyllys.Ingersoll@Sun.COM }
22499126SWyllys.Ingersoll@Sun.COM
22509126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
22519126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
22529126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
22539126SWyllys.Ingersoll@Sun.COM goto done;
22549126SWyllys.Ingersoll@Sun.COM }
22559126SWyllys.Ingersoll@Sun.COM
22569126SWyllys.Ingersoll@Sun.COM rc = key_mgr_wrap_key(sess, length_only,
22579126SWyllys.Ingersoll@Sun.COM pMechanism, hWrappingKey, hKey,
22589126SWyllys.Ingersoll@Sun.COM pWrappedKey, pulWrappedKeyLen);
22599126SWyllys.Ingersoll@Sun.COM
22609126SWyllys.Ingersoll@Sun.COM done:
22619126SWyllys.Ingersoll@Sun.COM return (rc);
22629126SWyllys.Ingersoll@Sun.COM }
22639126SWyllys.Ingersoll@Sun.COM
22649126SWyllys.Ingersoll@Sun.COM CK_RV
SC_UnwrapKey(ST_SESSION_HANDLE sSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hUnwrappingKey,CK_BYTE_PTR pWrappedKey,CK_ULONG ulWrappedKeyLen,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phKey)22659126SWyllys.Ingersoll@Sun.COM SC_UnwrapKey(ST_SESSION_HANDLE sSession,
22669126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
22679126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hUnwrappingKey,
22689126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pWrappedKey,
22699126SWyllys.Ingersoll@Sun.COM CK_ULONG ulWrappedKeyLen,
22709126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
22719126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount,
22729126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phKey)
22739126SWyllys.Ingersoll@Sun.COM {
22749126SWyllys.Ingersoll@Sun.COM SESSION * sess = NULL;
22759126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
22769126SWyllys.Ingersoll@Sun.COM SESS_SET
22779126SWyllys.Ingersoll@Sun.COM
22789126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
22799126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
22809126SWyllys.Ingersoll@Sun.COM goto done;
22819126SWyllys.Ingersoll@Sun.COM }
22829126SWyllys.Ingersoll@Sun.COM
22839126SWyllys.Ingersoll@Sun.COM if (! pMechanism || ! pWrappedKey ||
22849126SWyllys.Ingersoll@Sun.COM (! pTemplate && ulCount != 0) || ! phKey) {
22859126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
22869126SWyllys.Ingersoll@Sun.COM goto done;
22879126SWyllys.Ingersoll@Sun.COM }
22889126SWyllys.Ingersoll@Sun.COM VALID_MECH(pMechanism);
22899126SWyllys.Ingersoll@Sun.COM
22909126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
22919126SWyllys.Ingersoll@Sun.COM if (! sess) {
22929126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
22939126SWyllys.Ingersoll@Sun.COM goto done;
22949126SWyllys.Ingersoll@Sun.COM }
22959126SWyllys.Ingersoll@Sun.COM
22969126SWyllys.Ingersoll@Sun.COM if (pin_expired(&sess->session_info,
22979126SWyllys.Ingersoll@Sun.COM nv_token_data->token_info.flags) == TRUE) {
22989126SWyllys.Ingersoll@Sun.COM rc = CKR_PIN_EXPIRED;
22999126SWyllys.Ingersoll@Sun.COM goto done;
23009126SWyllys.Ingersoll@Sun.COM }
23019126SWyllys.Ingersoll@Sun.COM
23029126SWyllys.Ingersoll@Sun.COM rc = key_mgr_unwrap_key(sess, pMechanism,
23039126SWyllys.Ingersoll@Sun.COM pTemplate, ulCount,
23049126SWyllys.Ingersoll@Sun.COM pWrappedKey, ulWrappedKeyLen,
23059126SWyllys.Ingersoll@Sun.COM hUnwrappingKey, phKey);
23069126SWyllys.Ingersoll@Sun.COM
23079126SWyllys.Ingersoll@Sun.COM done:
23089126SWyllys.Ingersoll@Sun.COM return (rc);
23099126SWyllys.Ingersoll@Sun.COM }
23109126SWyllys.Ingersoll@Sun.COM
23119126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
23129126SWyllys.Ingersoll@Sun.COM CK_RV
SC_SeedRandom(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pSeed,CK_ULONG ulSeedLen)23139126SWyllys.Ingersoll@Sun.COM SC_SeedRandom(ST_SESSION_HANDLE sSession,
23149126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSeed,
23159126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSeedLen)
23169126SWyllys.Ingersoll@Sun.COM {
23179126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
23189126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
23199126SWyllys.Ingersoll@Sun.COM }
23209453SWyllys.Ingersoll@Sun.COM if (pSeed == NULL || ulSeedLen == NULL)
23219453SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
23229453SWyllys.Ingersoll@Sun.COM
23239126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
23249126SWyllys.Ingersoll@Sun.COM }
23259126SWyllys.Ingersoll@Sun.COM
23269126SWyllys.Ingersoll@Sun.COM CK_RV
SC_GenerateRandom(ST_SESSION_HANDLE sSession,CK_BYTE_PTR pRandomData,CK_ULONG ulRandomLen)23279126SWyllys.Ingersoll@Sun.COM SC_GenerateRandom(ST_SESSION_HANDLE sSession,
23289126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pRandomData,
23299126SWyllys.Ingersoll@Sun.COM CK_ULONG ulRandomLen)
23309126SWyllys.Ingersoll@Sun.COM {
23319126SWyllys.Ingersoll@Sun.COM SESSION *sess = NULL;
23329126SWyllys.Ingersoll@Sun.COM CK_RV rc = CKR_OK;
23339126SWyllys.Ingersoll@Sun.COM SESS_SET
23349126SWyllys.Ingersoll@Sun.COM
23359126SWyllys.Ingersoll@Sun.COM if (st_Initialized() == FALSE) {
23369126SWyllys.Ingersoll@Sun.COM rc = CKR_CRYPTOKI_NOT_INITIALIZED;
23379126SWyllys.Ingersoll@Sun.COM goto done;
23389126SWyllys.Ingersoll@Sun.COM }
23399126SWyllys.Ingersoll@Sun.COM
23409126SWyllys.Ingersoll@Sun.COM if (! pRandomData && ulRandomLen != 0) {
23419126SWyllys.Ingersoll@Sun.COM rc = CKR_ARGUMENTS_BAD;
23429126SWyllys.Ingersoll@Sun.COM goto done;
23439126SWyllys.Ingersoll@Sun.COM }
23449126SWyllys.Ingersoll@Sun.COM
23459126SWyllys.Ingersoll@Sun.COM sess = session_mgr_find(hSession);
23469126SWyllys.Ingersoll@Sun.COM if (! sess) {
23479126SWyllys.Ingersoll@Sun.COM rc = CKR_SESSION_HANDLE_INVALID;
23489126SWyllys.Ingersoll@Sun.COM goto done;
23499126SWyllys.Ingersoll@Sun.COM }
23509126SWyllys.Ingersoll@Sun.COM
23519126SWyllys.Ingersoll@Sun.COM rc = token_rng(sess->hContext, pRandomData, ulRandomLen);
23529126SWyllys.Ingersoll@Sun.COM
23539126SWyllys.Ingersoll@Sun.COM done:
23549126SWyllys.Ingersoll@Sun.COM return (rc);
23559126SWyllys.Ingersoll@Sun.COM }
23569126SWyllys.Ingersoll@Sun.COM
23579126SWyllys.Ingersoll@Sun.COM void
SC_SetFunctionList(void)23589126SWyllys.Ingersoll@Sun.COM SC_SetFunctionList(void) {
23599126SWyllys.Ingersoll@Sun.COM function_list.ST_Initialize = ST_Initialize;
23609126SWyllys.Ingersoll@Sun.COM function_list.ST_Finalize = SC_Finalize;
23619126SWyllys.Ingersoll@Sun.COM function_list.ST_GetTokenInfo = SC_GetTokenInfo;
23629126SWyllys.Ingersoll@Sun.COM function_list.ST_GetMechanismList = SC_GetMechanismList;
23639126SWyllys.Ingersoll@Sun.COM function_list.ST_GetMechanismInfo = SC_GetMechanismInfo;
23649126SWyllys.Ingersoll@Sun.COM function_list.ST_InitToken = SC_InitToken;
23659126SWyllys.Ingersoll@Sun.COM function_list.ST_InitPIN = SC_InitPIN;
23669126SWyllys.Ingersoll@Sun.COM function_list.ST_SetPIN = SC_SetPIN;
23679126SWyllys.Ingersoll@Sun.COM function_list.ST_OpenSession = SC_OpenSession;
23689126SWyllys.Ingersoll@Sun.COM function_list.ST_CloseSession = SC_CloseSession;
23699126SWyllys.Ingersoll@Sun.COM function_list.ST_GetSessionInfo = SC_GetSessionInfo;
23709126SWyllys.Ingersoll@Sun.COM function_list.ST_GetOperationState = SC_GetOperationState;
23719126SWyllys.Ingersoll@Sun.COM function_list.ST_SetOperationState = SC_SetOperationState;
23729126SWyllys.Ingersoll@Sun.COM function_list.ST_Login = SC_Login;
23739126SWyllys.Ingersoll@Sun.COM function_list.ST_Logout = SC_Logout;
23749126SWyllys.Ingersoll@Sun.COM function_list.ST_CreateObject = SC_CreateObject;
23759126SWyllys.Ingersoll@Sun.COM function_list.ST_CopyObject = SC_CopyObject;
23769126SWyllys.Ingersoll@Sun.COM function_list.ST_DestroyObject = SC_DestroyObject;
23779126SWyllys.Ingersoll@Sun.COM function_list.ST_GetObjectSize = SC_GetObjectSize;
23789126SWyllys.Ingersoll@Sun.COM function_list.ST_GetAttributeValue = SC_GetAttributeValue;
23799126SWyllys.Ingersoll@Sun.COM function_list.ST_SetAttributeValue = SC_SetAttributeValue;
23809126SWyllys.Ingersoll@Sun.COM function_list.ST_FindObjectsInit = SC_FindObjectsInit;
23819126SWyllys.Ingersoll@Sun.COM function_list.ST_FindObjects = SC_FindObjects;
23829126SWyllys.Ingersoll@Sun.COM function_list.ST_FindObjectsFinal = SC_FindObjectsFinal;
23839126SWyllys.Ingersoll@Sun.COM function_list.ST_EncryptInit = SC_EncryptInit;
23849126SWyllys.Ingersoll@Sun.COM function_list.ST_Encrypt = SC_Encrypt;
23859126SWyllys.Ingersoll@Sun.COM function_list.ST_EncryptUpdate = NULL /* SC_EncryptUpdate */;
23869126SWyllys.Ingersoll@Sun.COM function_list.ST_EncryptFinal = NULL /* SC_EncryptFinal */;
23879126SWyllys.Ingersoll@Sun.COM function_list.ST_DecryptInit = SC_DecryptInit;
23889126SWyllys.Ingersoll@Sun.COM function_list.ST_Decrypt = SC_Decrypt;
23899126SWyllys.Ingersoll@Sun.COM function_list.ST_DecryptUpdate = NULL /* SC_DecryptUpdate */;
23909126SWyllys.Ingersoll@Sun.COM function_list.ST_DecryptFinal = NULL /* SC_DecryptFinal */;
23919126SWyllys.Ingersoll@Sun.COM function_list.ST_DigestInit = SC_DigestInit;
23929126SWyllys.Ingersoll@Sun.COM function_list.ST_Digest = SC_Digest;
23939126SWyllys.Ingersoll@Sun.COM function_list.ST_DigestUpdate = SC_DigestUpdate;
23949126SWyllys.Ingersoll@Sun.COM function_list.ST_DigestKey = SC_DigestKey;
23959126SWyllys.Ingersoll@Sun.COM function_list.ST_DigestFinal = SC_DigestFinal;
23969126SWyllys.Ingersoll@Sun.COM function_list.ST_SignInit = SC_SignInit;
23979126SWyllys.Ingersoll@Sun.COM function_list.ST_Sign = SC_Sign;
23989126SWyllys.Ingersoll@Sun.COM function_list.ST_SignUpdate = SC_SignUpdate;
23999126SWyllys.Ingersoll@Sun.COM function_list.ST_SignFinal = SC_SignFinal;
24009126SWyllys.Ingersoll@Sun.COM function_list.ST_SignRecoverInit = SC_SignRecoverInit;
24019126SWyllys.Ingersoll@Sun.COM function_list.ST_SignRecover = SC_SignRecover;
24029126SWyllys.Ingersoll@Sun.COM function_list.ST_VerifyInit = SC_VerifyInit;
24039126SWyllys.Ingersoll@Sun.COM function_list.ST_Verify = SC_Verify;
24049126SWyllys.Ingersoll@Sun.COM function_list.ST_VerifyUpdate = SC_VerifyUpdate;
24059126SWyllys.Ingersoll@Sun.COM function_list.ST_VerifyFinal = SC_VerifyFinal;
24069126SWyllys.Ingersoll@Sun.COM function_list.ST_VerifyRecoverInit = SC_VerifyRecoverInit;
24079126SWyllys.Ingersoll@Sun.COM function_list.ST_VerifyRecover = SC_VerifyRecover;
24089126SWyllys.Ingersoll@Sun.COM function_list.ST_DigestEncryptUpdate = NULL;
24099126SWyllys.Ingersoll@Sun.COM function_list.ST_DecryptDigestUpdate = NULL;
24109126SWyllys.Ingersoll@Sun.COM function_list.ST_SignEncryptUpdate = NULL;
24119126SWyllys.Ingersoll@Sun.COM function_list.ST_DecryptVerifyUpdate = NULL;
24129126SWyllys.Ingersoll@Sun.COM function_list.ST_GenerateKey = NULL;
24139126SWyllys.Ingersoll@Sun.COM function_list.ST_GenerateKeyPair = SC_GenerateKeyPair;
24149126SWyllys.Ingersoll@Sun.COM function_list.ST_WrapKey = SC_WrapKey;
24159126SWyllys.Ingersoll@Sun.COM function_list.ST_UnwrapKey = SC_UnwrapKey;
24169126SWyllys.Ingersoll@Sun.COM function_list.ST_DeriveKey = NULL;
24179126SWyllys.Ingersoll@Sun.COM function_list.ST_SeedRandom = SC_SeedRandom;
24189126SWyllys.Ingersoll@Sun.COM function_list.ST_GenerateRandom = SC_GenerateRandom;
24199126SWyllys.Ingersoll@Sun.COM function_list.ST_GetFunctionStatus = NULL;
24209126SWyllys.Ingersoll@Sun.COM function_list.ST_CancelFunction = NULL;
24219126SWyllys.Ingersoll@Sun.COM }
2422