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