Check-in [ab28e9b926]
Overview
Comment:Updated to support linking to PKCS#11 providers that export the minimal PKCS#11 symbols
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ab28e9b926c2d356618eeee43d0a5dd0b92b0c01
User & Date: rkeene on 2011-08-26 03:59:20
Other Links: manifest | tags
Context
2011-08-26
05:29
Updated to include DoD root CAs as objects in the PKCS#11 module

Updated to include Netscape Trust Objects (https://developer.mozilla.org/index.php?title=en/NSS/PKCS_%2311_Netscape_Trust) in PKCS#11 module

Added more attributes to scan for to test driver check-in: 5027cbae9b user: rkeene tags: trunk

03:59
Updated to support linking to PKCS#11 providers that export the minimal PKCS#11 symbols check-in: ab28e9b926 user: rkeene tags: trunk
2011-08-25
04:01
CACKey 0.6.0 check-in: 21d6e16ab8 user: rkeene tags: trunk, 0.6.0
Changes

Modified test.c from [24213eb4b1] to [7200c62d18].

     1      1   #include "mypkcs11.h"
     2      2   
     3      3   #include <sys/types.h>
     4      4   #include <string.h>
     5      5   #include <unistd.h>
     6      6   #include <stdlib.h>
     7      7   #include <stdio.h>
            8  +
     8      9   
     9     10   static char *pkcs11_attribute_to_name(CK_ATTRIBUTE_TYPE attrib) {
    10     11   	static char retbuf[1024];
    11     12   
    12     13   	switch (attrib) {
    13     14   		case 0x00000000: return "CKA_CLASS";
    14     15   		case 0x00000001: return "CKA_TOKEN";
................................................................................
    73     74   	snprintf(retbuf, sizeof(retbuf), "0x%08lx", (unsigned long) attrib);
    74     75   	retbuf[sizeof(retbuf) - 1] = '\0';
    75     76   
    76     77   	return(retbuf);
    77     78   }
    78     79   
    79     80   int main_pkcs11(void) {
           81  +	CK_FUNCTION_LIST_PTR pFunctionList;
           82  +	CK_RV (*C_CloseSession)(CK_SESSION_HANDLE hSession) = NULL;
           83  +	CK_RV (*C_Decrypt)(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedData, CK_ULONG ulEncryptedDataLen, CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen) = NULL;
           84  +	CK_RV (*C_DecryptInit)(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) = NULL;
           85  +	CK_RV (*C_Encrypt)(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pEncryptedData, CK_ULONG_PTR pulEncryptedDataLen) = NULL;
           86  +	CK_RV (*C_EncryptInit)(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) = NULL;
           87  +	CK_RV (*C_Finalize)(CK_VOID_PTR pReserved) = NULL;
           88  +	CK_RV (*C_FindObjects)(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount) = NULL;
           89  +	CK_RV (*C_FindObjectsFinal)(CK_SESSION_HANDLE hSession) = NULL;
           90  +	CK_RV (*C_FindObjectsInit)(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) = NULL;
           91  +	CK_RV (*C_GetAttributeValue)(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) = NULL;
           92  +	CK_RV (*C_GetInfo)(CK_INFO_PTR pInfo) = NULL;
           93  +	CK_RV (*C_GetSessionInfo)(CK_SESSION_HANDLE hSession, CK_SESSION_INFO_PTR pInfo) = NULL;
           94  +	CK_RV (*C_GetSlotInfo)(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) = NULL;
           95  +	CK_RV (*C_GetSlotList)(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount) = NULL;
           96  +	CK_RV (*C_GetTokenInfo)(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo) = NULL;
           97  +	CK_RV (*C_Initialize)(CK_VOID_PTR pInitArgs) = NULL;
           98  +	CK_RV (*C_Login)(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen) = NULL;
           99  +	CK_RV (*C_OpenSession)(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication, CK_NOTIFY notify, CK_SESSION_HANDLE_PTR phSession) = NULL;
          100  +	CK_RV (*C_Sign)(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen) = NULL;
          101  +	CK_RV (*C_SignInit)(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) = NULL;
    80    102   	CK_C_INITIALIZE_ARGS initargs;
    81    103   	CK_INFO clientinfo;
    82    104   	CK_ULONG numSlots, currSlot;
    83    105   	CK_SLOT_ID_PTR slots;
    84    106   	CK_SLOT_INFO slotInfo;
    85    107   	CK_TOKEN_INFO tokenInfo;
    86    108   	CK_SESSION_HANDLE hSession;
................................................................................
   108    130   	CK_OBJECT_CLASS objectClass;
   109    131   	CK_BYTE signature[1024], encrypted_buf[16384], decrypted_buf[16384];
   110    132   	CK_ULONG signature_len, encrypted_buflen, decrypted_buflen;
   111    133   	CK_MECHANISM mechanism = {CKM_RSA_PKCS, NULL, 0};
   112    134   	CK_RV chk_rv;
   113    135   	char *fgets_ret;
   114    136   	int i;
          137  +
          138  +	chk_rv = C_GetFunctionList(&pFunctionList);
          139  +	if (chk_rv != CKR_OK) {
          140  +		printf("C_GetFunctionList() failed.");
          141  +
          142  +		return(1);
          143  +	}
          144  +
          145  +
          146  +	C_CloseSession = pFunctionList->C_CloseSession;
          147  +	C_Decrypt = pFunctionList->C_Decrypt;
          148  +	C_DecryptInit = pFunctionList->C_DecryptInit;
          149  +	C_Encrypt = pFunctionList->C_Encrypt;
          150  +	C_EncryptInit = pFunctionList->C_EncryptInit;
          151  +	C_Finalize = pFunctionList->C_Finalize;
          152  +	C_FindObjects = pFunctionList->C_FindObjects;
          153  +	C_FindObjectsFinal = pFunctionList->C_FindObjectsFinal;
          154  +	C_FindObjectsInit = pFunctionList->C_FindObjectsInit;
          155  +	C_GetAttributeValue = pFunctionList->C_GetAttributeValue;
          156  +	C_GetInfo = pFunctionList->C_GetInfo;
          157  +	C_GetSessionInfo = pFunctionList->C_GetSessionInfo;
          158  +	C_GetSlotInfo = pFunctionList->C_GetSlotInfo;
          159  +	C_GetSlotList = pFunctionList->C_GetSlotList;
          160  +	C_GetTokenInfo = pFunctionList->C_GetTokenInfo;
          161  +	C_Initialize = pFunctionList->C_Initialize;
          162  +	C_Login = pFunctionList->C_Login;
          163  +	C_OpenSession = pFunctionList->C_OpenSession;
          164  +	C_Sign = pFunctionList->C_Sign;
          165  +	C_SignInit = pFunctionList->C_SignInit;
   115    166   
   116    167   	privateKeyObjects = malloc(sizeof(*privateKeyObjects) * 1024);
   117    168   	privateKeyObjects_root = privateKeyObjects;
   118    169   	for (i = 0; i < 1024; i++) {
   119    170   		privateKeyObjects[i] = CK_INVALID_HANDLE;
   120    171   	}
   121    172