pk11_api.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2014  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id$ */
00018 
00019 /*! \file */
00020 
00021 #include <config.h>
00022 
00023 #include <string.h>
00024 #include <dlfcn.h>
00025 
00026 #include <isc/log.h>
00027 #include <isc/mem.h>
00028 #include <isc/once.h>
00029 #include <isc/stdio.h>
00030 #include <isc/thread.h>
00031 #include <isc/util.h>
00032 
00033 #include <pkcs11/cryptoki.h>
00034 #include <pkcs11/pkcs11.h>
00035 
00036 #define KEEP_PKCS11_NAMES
00037 #include <pk11/pk11.h>
00038 #include <pk11/internal.h>
00039 
00040 static void *hPK11 = NULL;
00041 
00042 CK_RV
00043 pkcs_C_Initialize(CK_VOID_PTR pReserved) {
00044         CK_C_Initialize sym;
00045 
00046         if (hPK11 != NULL)
00047                 return (CKR_LIBRARY_ALREADY_INITIALIZED);
00048 
00049         hPK11 = dlopen(pk11_get_lib_name(), RTLD_NOW);
00050 
00051         if (hPK11 == NULL)
00052                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00053         sym = (CK_C_Initialize)dlsym(hPK11, "C_Initialize");
00054         if (sym == NULL)
00055                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00056         return (*sym)(pReserved);
00057 }
00058 
00059 CK_RV
00060 pkcs_C_Finalize(CK_VOID_PTR pReserved) {
00061         CK_C_Finalize sym;
00062         CK_RV rv;
00063 
00064         if (hPK11 == NULL)
00065                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00066         sym = (CK_C_Finalize)dlsym(hPK11, "C_Finalize");
00067         if (sym == NULL)
00068                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00069         rv = (*sym)(pReserved);
00070         if ((rv == CKR_OK) && (dlclose(hPK11) != 0))
00071                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00072         hPK11 = NULL;
00073         return (rv);
00074 }
00075 
00076 CK_RV
00077 pkcs_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList,
00078                    CK_ULONG_PTR pulCount)
00079 {
00080         static CK_C_GetSlotList sym = NULL;
00081         static void *pPK11 = NULL;
00082 
00083         if (hPK11 == NULL)
00084                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00085         if ((sym == NULL) || (hPK11 != pPK11)) {
00086                 pPK11 = hPK11;
00087                 sym = (CK_C_GetSlotList)dlsym(hPK11, "C_GetSlotList");
00088         }
00089         if (sym == NULL)
00090                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00091         return (*sym)(tokenPresent, pSlotList, pulCount);
00092 }
00093 
00094 CK_RV
00095 pkcs_C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo) {
00096         static CK_C_GetTokenInfo sym = NULL;
00097         static void *pPK11 = NULL;
00098 
00099         if (hPK11 == NULL)
00100                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00101         if ((sym == NULL) || (hPK11 != pPK11)) {
00102                 pPK11 = hPK11;
00103                 sym = (CK_C_GetTokenInfo)dlsym(hPK11, "C_GetTokenInfo");
00104         }
00105         if (sym == NULL)
00106                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00107         return (*sym)(slotID, pInfo);
00108 }
00109 
00110 CK_RV
00111 pkcs_C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type,
00112                         CK_MECHANISM_INFO_PTR pInfo)
00113 {
00114         static CK_C_GetMechanismInfo sym = NULL;
00115         static void *pPK11 = NULL;
00116 
00117         if (hPK11 == NULL)
00118                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00119         if ((sym == NULL) || (hPK11 != pPK11)) {
00120                 pPK11 = hPK11;
00121                 sym = (CK_C_GetMechanismInfo)dlsym(hPK11,
00122                                                    "C_GetMechanismInfo");
00123         }
00124         if (sym == NULL)
00125                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00126         return (*sym)(slotID, type, pInfo);
00127 }
00128 
00129 CK_RV
00130 pkcs_C_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags,
00131                    CK_VOID_PTR pApplication,
00132                    CK_RV  (*Notify) (CK_SESSION_HANDLE hSession,
00133                                      CK_NOTIFICATION event,
00134                                      CK_VOID_PTR pApplication),
00135                    CK_SESSION_HANDLE_PTR phSession)
00136 {
00137         static CK_C_OpenSession sym = NULL;
00138         static void *pPK11 = NULL;
00139 
00140         if (hPK11 == NULL)
00141                 hPK11 = dlopen(pk11_get_lib_name(), RTLD_NOW);
00142         if (hPK11 == NULL)
00143                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00144         if ((sym == NULL) || (hPK11 != pPK11)) {
00145                 pPK11 = hPK11;
00146                 sym = (CK_C_OpenSession)dlsym(hPK11, "C_OpenSession");
00147         }
00148         if (sym == NULL)
00149                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00150         return (*sym)(slotID, flags, pApplication, Notify, phSession);
00151 }
00152 
00153 CK_RV
00154 pkcs_C_CloseSession(CK_SESSION_HANDLE hSession) {
00155         static CK_C_CloseSession sym = NULL;
00156         static void *pPK11 = NULL;
00157 
00158         if (hPK11 == NULL)
00159                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00160         if ((sym == NULL) || (hPK11 != pPK11)) {
00161                 pPK11 = hPK11;
00162                 sym = (CK_C_CloseSession)dlsym(hPK11, "C_CloseSession");
00163         }
00164         if (sym == NULL)
00165                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00166         return (*sym)(hSession);
00167 }
00168 
00169 CK_RV
00170 pkcs_C_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType,
00171              CK_CHAR_PTR pPin, CK_ULONG usPinLen)
00172 {
00173         static CK_C_Login sym = NULL;
00174         static void *pPK11 = NULL;
00175 
00176         if (hPK11 == NULL)
00177                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00178         if ((sym == NULL) || (hPK11 != pPK11)) {
00179                 pPK11 = hPK11;
00180                 sym = (CK_C_Login)dlsym(hPK11, "C_Login");
00181         }
00182         if (sym == NULL)
00183                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00184         return (*sym)(hSession, userType, pPin, usPinLen);
00185 }
00186 
00187 CK_RV
00188 pkcs_C_Logout(CK_SESSION_HANDLE hSession) {
00189         static CK_C_Logout sym = NULL;
00190         static void *pPK11 = NULL;
00191 
00192         if (hPK11 == NULL)
00193                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00194         if ((sym == NULL) || (hPK11 != pPK11)) {
00195                 pPK11 = hPK11;
00196                 sym = (CK_C_Logout)dlsym(hPK11, "C_Logout");
00197         }
00198         if (sym == NULL)
00199                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00200         return (*sym)(hSession);
00201 }
00202 
00203 CK_RV
00204 pkcs_C_CreateObject(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
00205                     CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phObject)
00206 {
00207         static CK_C_CreateObject sym = NULL;
00208         static void *pPK11 = NULL;
00209 
00210         if (hPK11 == NULL)
00211                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00212         if ((sym == NULL) || (hPK11 != pPK11)) {
00213                 pPK11 = hPK11;
00214                 sym = (CK_C_CreateObject)dlsym(hPK11, "C_CreateObject");
00215         }
00216         if (sym == NULL)
00217                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00218         return (*sym)(hSession, pTemplate, usCount, phObject);
00219 }
00220 
00221 CK_RV
00222 pkcs_C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject) {
00223         static CK_C_DestroyObject sym = NULL;
00224         static void *pPK11 = NULL;
00225 
00226         if (hPK11 == NULL)
00227                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00228         if ((sym == NULL) || (hPK11 != pPK11)) {
00229                 pPK11 = hPK11;
00230                 sym = (CK_C_DestroyObject)dlsym(hPK11, "C_DestroyObject");
00231         }
00232         if (sym == NULL)
00233                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00234         return (*sym)(hSession, hObject);
00235 }
00236 
00237 CK_RV
00238 pkcs_C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
00239                          CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount)
00240 {
00241         static CK_C_GetAttributeValue sym = NULL;
00242         static void *pPK11 = NULL;
00243 
00244         if (hPK11 == NULL)
00245                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00246         if ((sym == NULL) || (hPK11 != pPK11)) {
00247                 pPK11 = hPK11;
00248                 sym = (CK_C_GetAttributeValue)dlsym(hPK11,
00249                                                     "C_GetAttributeValue");
00250         }
00251         if (sym == NULL)
00252                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00253         return (*sym)(hSession, hObject, pTemplate, usCount);
00254 }
00255 
00256 CK_RV
00257 pkcs_C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
00258                          CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount)
00259 {
00260         static CK_C_SetAttributeValue sym = NULL;
00261         static void *pPK11 = NULL;
00262 
00263         if (hPK11 == NULL)
00264                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00265         if ((sym == NULL) || (hPK11 != pPK11)) {
00266                 pPK11 = hPK11;
00267                 sym = (CK_C_SetAttributeValue)dlsym(hPK11,
00268                                                     "C_SetAttributeValue");
00269         }
00270         if (sym == NULL)
00271                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00272         return (*sym)(hSession, hObject, pTemplate, usCount);
00273 }
00274 
00275 CK_RV
00276 pkcs_C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
00277                        CK_ULONG usCount)
00278 {
00279         static CK_C_FindObjectsInit sym = NULL;
00280         static void *pPK11 = NULL;
00281 
00282         if (hPK11 == NULL)
00283                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00284         if ((sym == NULL) || (hPK11 != pPK11)) {
00285                 pPK11 = hPK11;
00286                 sym = (CK_C_FindObjectsInit)dlsym(hPK11, "C_FindObjectsInit");
00287         }
00288         if (sym == NULL)
00289                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00290         return (*sym)(hSession, pTemplate, usCount);
00291 }
00292 
00293 CK_RV
00294 pkcs_C_FindObjects(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject,
00295                    CK_ULONG usMaxObjectCount, CK_ULONG_PTR pusObjectCount)
00296 {
00297         static CK_C_FindObjects sym = NULL;
00298         static void *pPK11 = NULL;
00299 
00300         if (hPK11 == NULL)
00301                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00302         if ((sym == NULL) || (hPK11 != pPK11)) {
00303                 pPK11 = hPK11;
00304                 sym = (CK_C_FindObjects)dlsym(hPK11, "C_FindObjects");
00305         }
00306         if (sym == NULL)
00307                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00308         return (*sym)(hSession, phObject, usMaxObjectCount, pusObjectCount);
00309 }
00310 
00311 CK_RV
00312 pkcs_C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
00313 {
00314         static CK_C_FindObjectsFinal sym = NULL;
00315         static void *pPK11 = NULL;
00316 
00317         if (hPK11 == NULL)
00318                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00319         if ((sym == NULL) || (hPK11 != pPK11)) {
00320                 pPK11 = hPK11;
00321                 sym = (CK_C_FindObjectsFinal)dlsym(hPK11,
00322                                                    "C_FindObjectsFinal");
00323         }
00324         if (sym == NULL)
00325                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00326         return (*sym)(hSession);
00327 }
00328 
00329 CK_RV
00330 pkcs_C_EncryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
00331                    CK_OBJECT_HANDLE hKey)
00332 {
00333         static CK_C_EncryptInit sym = NULL;
00334         static void *pPK11 = NULL;
00335 
00336         if (hPK11 == NULL)
00337                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00338         if ((sym == NULL) || (hPK11 != pPK11)) {
00339                 pPK11 = hPK11;
00340                 sym = (CK_C_EncryptInit)dlsym(hPK11, "C_EncryptInit");
00341         }
00342         if (sym == NULL)
00343                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00344         return (*sym)(hSession, pMechanism, hKey);
00345 }
00346 
00347 CK_RV
00348 pkcs_C_Encrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
00349                CK_ULONG ulDataLen, CK_BYTE_PTR pEncryptedData,
00350                CK_ULONG_PTR pulEncryptedDataLen)
00351 {
00352         static CK_C_Encrypt sym = NULL;
00353         static void *pPK11 = NULL;
00354 
00355         if (hPK11 == NULL)
00356                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00357         if ((sym == NULL) || (hPK11 != pPK11)) {
00358                 pPK11 = hPK11;
00359                 sym = (CK_C_Encrypt)dlsym(hPK11, "C_Encrypt");
00360         }
00361         if (sym == NULL)
00362                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00363         return (*sym)(hSession, pData, ulDataLen,
00364                       pEncryptedData, pulEncryptedDataLen);
00365 }
00366 
00367 CK_RV
00368 pkcs_C_DigestInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism) {
00369         static CK_C_DigestInit sym = NULL;
00370         static void *pPK11 = NULL;
00371 
00372         if (hPK11 == NULL)
00373                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00374         if ((sym == NULL) || (hPK11 != pPK11)) {
00375                 pPK11 = hPK11;
00376                 sym = (CK_C_DigestInit)dlsym(hPK11, "C_DigestInit");
00377         }
00378         if (sym == NULL)
00379                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00380         return (*sym)(hSession, pMechanism);
00381 }
00382 
00383 CK_RV
00384 pkcs_C_DigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
00385                     CK_ULONG ulPartLen)
00386 {
00387         static CK_C_DigestUpdate sym = NULL;
00388         static void *pPK11 = NULL;
00389 
00390         if (hPK11 == NULL)
00391                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00392         if ((sym == NULL) || (hPK11 != pPK11)) {
00393                 pPK11 = hPK11;
00394                 sym = (CK_C_DigestUpdate)dlsym(hPK11, "C_DigestUpdate");
00395         }
00396         if (sym == NULL)
00397                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00398         return (*sym)(hSession, pPart, ulPartLen);
00399 }
00400 
00401 CK_RV
00402 pkcs_C_DigestFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pDigest,
00403                    CK_ULONG_PTR pulDigestLen)
00404 {
00405         static CK_C_DigestFinal sym = NULL;
00406         static void *pPK11 = NULL;
00407 
00408         if (hPK11 == NULL)
00409                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00410         if ((sym == NULL) || (hPK11 != pPK11)) {
00411                 pPK11 = hPK11;
00412                 sym = (CK_C_DigestFinal)dlsym(hPK11, "C_DigestFinal");
00413         }
00414         if (sym == NULL)
00415                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00416         return (*sym)(hSession, pDigest, pulDigestLen);
00417 }
00418 
00419 CK_RV
00420 pkcs_C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
00421                 CK_OBJECT_HANDLE hKey)
00422 {
00423         static CK_C_SignInit sym = NULL;
00424         static void *pPK11 = NULL;
00425 
00426         if (hPK11 == NULL)
00427                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00428         if ((sym == NULL) || (hPK11 != pPK11)) {
00429                 pPK11 = hPK11;
00430                 sym = (CK_C_SignInit)dlsym(hPK11, "C_SignInit");
00431         }
00432         if (sym == NULL)
00433                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00434         return (*sym)(hSession, pMechanism, hKey);
00435 }
00436 
00437 CK_RV
00438 pkcs_C_Sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
00439             CK_ULONG ulDataLen, CK_BYTE_PTR pSignature,
00440             CK_ULONG_PTR pulSignatureLen)
00441 {
00442         static CK_C_Sign sym = NULL;
00443         static void *pPK11 = NULL;
00444 
00445         if (hPK11 == NULL)
00446                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00447         if ((sym == NULL) || (hPK11 != pPK11)) {
00448                 pPK11 = hPK11;
00449                 sym = (CK_C_Sign)dlsym(hPK11, "C_Sign");
00450         }
00451         if (sym == NULL)
00452                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00453         return (*sym)(hSession, pData, ulDataLen, pSignature, pulSignatureLen);
00454 }
00455 
00456 CK_RV
00457 pkcs_C_SignUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
00458                   CK_ULONG ulPartLen)
00459 {
00460         static CK_C_SignUpdate sym = NULL;
00461         static void *pPK11 = NULL;
00462 
00463         if (hPK11 == NULL)
00464                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00465         if ((sym == NULL) || (hPK11 != pPK11)) {
00466                 pPK11 = hPK11;
00467                 sym = (CK_C_SignUpdate)dlsym(hPK11, "C_SignUpdate");
00468         }
00469         if (sym == NULL)
00470                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00471         return (*sym)(hSession, pPart, ulPartLen);
00472 }
00473 
00474 CK_RV
00475 pkcs_C_SignFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
00476                  CK_ULONG_PTR pulSignatureLen)
00477 {
00478         static CK_C_SignFinal sym = NULL;
00479         static void *pPK11 = NULL;
00480 
00481         if (hPK11 == NULL)
00482                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00483         if ((sym == NULL) || (hPK11 != pPK11)) {
00484                 pPK11 = hPK11;
00485                 sym = (CK_C_SignFinal)dlsym(hPK11, "C_SignFinal");
00486         }
00487         if (sym == NULL)
00488                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00489         return (*sym)(hSession, pSignature, pulSignatureLen);
00490 }
00491 
00492 CK_RV
00493 pkcs_C_VerifyInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
00494                   CK_OBJECT_HANDLE hKey)
00495 {
00496         static CK_C_VerifyInit sym = NULL;
00497         static void *pPK11 = NULL;
00498 
00499         if (hPK11 == NULL)
00500                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00501         if ((sym == NULL) || (hPK11 != pPK11)) {
00502                 pPK11 = hPK11;
00503                 sym = (CK_C_VerifyInit)dlsym(hPK11, "C_VerifyInit");
00504         }
00505         if (sym == NULL)
00506                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00507         return (*sym)(hSession, pMechanism, hKey);
00508 }
00509 
00510 CK_RV
00511 pkcs_C_Verify(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
00512               CK_ULONG ulDataLen, CK_BYTE_PTR pSignature,
00513               CK_ULONG ulSignatureLen)
00514 {
00515         static CK_C_Verify sym = NULL;
00516         static void *pPK11 = NULL;
00517 
00518         if (hPK11 == NULL)
00519                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00520         if ((sym == NULL) || (hPK11 != pPK11)) {
00521                 pPK11 = hPK11;
00522                 sym = (CK_C_Verify)dlsym(hPK11, "C_Verify");
00523         }
00524         if (sym == NULL)
00525                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00526         return (*sym)(hSession, pData, ulDataLen, pSignature, ulSignatureLen);
00527 }
00528 
00529 CK_RV
00530 pkcs_C_VerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
00531                     CK_ULONG ulPartLen)
00532 {
00533         static CK_C_VerifyUpdate sym = NULL;
00534         static void *pPK11 = NULL;
00535 
00536         if (hPK11 == NULL)
00537                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00538         if ((sym == NULL) || (hPK11 != pPK11)) {
00539                 pPK11 = hPK11;
00540                 sym = (CK_C_VerifyUpdate)dlsym(hPK11, "C_VerifyUpdate");
00541         }
00542         if (sym == NULL)
00543                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00544         return (*sym)(hSession, pPart, ulPartLen);
00545 }
00546 
00547 CK_RV
00548 pkcs_C_VerifyFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
00549                    CK_ULONG ulSignatureLen)
00550 {
00551         static CK_C_VerifyFinal sym = NULL;
00552         static void *pPK11 = NULL;
00553 
00554         if (hPK11 == NULL)
00555                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00556         if ((sym == NULL) || (hPK11 != pPK11)) {
00557                 pPK11 = hPK11;
00558                 sym = (CK_C_VerifyFinal)dlsym(hPK11, "C_VerifyFinal");
00559         }
00560         if (sym == NULL)
00561                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00562         return (*sym)(hSession, pSignature, ulSignatureLen);
00563 }
00564 
00565 CK_RV
00566 pkcs_C_GenerateKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
00567                    CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
00568                    CK_OBJECT_HANDLE_PTR phKey)
00569 {
00570         static CK_C_GenerateKey sym = NULL;
00571         static void *pPK11 = NULL;
00572 
00573         if (hPK11 == NULL)
00574                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00575         if ((sym == NULL) || (hPK11 != pPK11)) {
00576                 pPK11 = hPK11;
00577                 sym = (CK_C_GenerateKey)dlsym(hPK11, "C_GenerateKey");
00578         }
00579         if (sym == NULL)
00580                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00581         return (*sym)(hSession, pMechanism, pTemplate, ulCount, phKey);
00582 }
00583 
00584 CK_RV
00585 pkcs_C_GenerateKeyPair(CK_SESSION_HANDLE hSession,
00586                        CK_MECHANISM_PTR pMechanism,
00587                        CK_ATTRIBUTE_PTR pPublicKeyTemplate,
00588                        CK_ULONG usPublicKeyAttributeCount,
00589                        CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
00590                        CK_ULONG usPrivateKeyAttributeCount,
00591                        CK_OBJECT_HANDLE_PTR phPrivateKey,
00592                        CK_OBJECT_HANDLE_PTR phPublicKey)
00593 {
00594         static CK_C_GenerateKeyPair sym = NULL;
00595         static void *pPK11 = NULL;
00596 
00597         if (hPK11 == NULL)
00598                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00599         if ((sym == NULL) || (hPK11 != pPK11)) {
00600                 pPK11 = hPK11;
00601                 sym = (CK_C_GenerateKeyPair)dlsym(hPK11, "C_GenerateKeyPair");
00602         }
00603         if (sym == NULL)
00604                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00605         return (*sym)(hSession,
00606                       pMechanism,
00607                       pPublicKeyTemplate,
00608                       usPublicKeyAttributeCount,
00609                       pPrivateKeyTemplate,
00610                       usPrivateKeyAttributeCount,
00611                       phPrivateKey,
00612                       phPublicKey);
00613 }
00614 
00615 CK_RV
00616 pkcs_C_DeriveKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
00617                  CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate,
00618                  CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey)
00619 {
00620         static CK_C_DeriveKey sym = NULL;
00621         static void *pPK11 = NULL;
00622 
00623         if (hPK11 == NULL)
00624                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00625         if ((sym == NULL) || (hPK11 != pPK11)) {
00626                 pPK11 = hPK11;
00627                 sym = (CK_C_DeriveKey)dlsym(hPK11, "C_DeriveKey");
00628         }
00629         if (sym == NULL)
00630                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00631         return (*sym)(hSession,
00632                       pMechanism,
00633                       hBaseKey,
00634                       pTemplate,
00635                       ulAttributeCount,
00636                       phKey);
00637 }
00638 
00639 CK_RV
00640 pkcs_C_SeedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed,
00641                   CK_ULONG ulSeedLen)
00642 {
00643         static CK_C_SeedRandom sym = NULL;
00644         static void *pPK11 = NULL;
00645 
00646         if (hPK11 == NULL)
00647                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00648         if ((sym == NULL) || (hPK11 != pPK11)) {
00649                 pPK11 = hPK11;
00650                 sym = (CK_C_SeedRandom)dlsym(hPK11, "C_SeedRandom");
00651         }
00652         if (sym == NULL)
00653                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00654         return (*sym)(hSession, pSeed, ulSeedLen);
00655 }
00656 
00657 CK_RV
00658 pkcs_C_GenerateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR RandomData,
00659                       CK_ULONG ulRandomLen)
00660 {
00661         static CK_C_GenerateRandom sym = NULL;
00662         static void *pPK11 = NULL;
00663 
00664         if (hPK11 == NULL)
00665                 return (CKR_LIBRARY_FAILED_TO_LOAD);
00666         if ((sym == NULL) || (hPK11 != pPK11)) {
00667                 pPK11 = hPK11;
00668                 sym = (CK_C_GenerateRandom)dlsym(hPK11, "C_GenerateRandom");
00669         }
00670         if (sym == NULL)
00671                 return (CKR_SYMBOL_RESOLUTION_FAILED);
00672         return (*sym)(hSession, RandomData, ulRandomLen);
00673 }

Generated on Tue Apr 28 17:41:05 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha