Differences From Artifact [426f7e236e]:
- File
cackey.c
— part of check-in
[ec1f93c869]
at
2010-10-15 09:53:09
on branch trunk
— Added mostly-compiling Win32 support
Added local copy of RSA PKCS#11 (user: rkeene, size: 172485) [annotate] [blame] [check-ins using]
To Artifact [375972947e]:
- File cackey.c — part of check-in [80df9c1ff5] at 2011-06-17 06:26:32 on branch trunk — Corrected small issues (user: rkeene, size: 172521) [annotate] [blame] [check-ins using]
3168 3168 3169 3169 CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(CK_VOID_PTR pInitArgs) { 3170 3170 CK_C_INITIALIZE_ARGS CK_PTR args; 3171 3171 uint32_t idx; 3172 3172 int mutex_init_ret; 3173 3173 3174 3174 CACKEY_DEBUG_PRINTF("Called."); 3175 + 3176 + if (cackey_initialized) { 3177 + CACKEY_DEBUG_PRINTF("Error. Already initialized."); 3178 + 3179 + return(CKR_CRYPTOKI_ALREADY_INITIALIZED); 3180 + } 3175 3181 3176 3182 if (pInitArgs != NULL) { 3177 3183 args = pInitArgs; 3178 3184 memcpy(&cackey_args, args, sizeof(cackey_args)); 3179 3185 3180 3186 if (args->CreateMutex == NULL || args->DestroyMutex == NULL || args->LockMutex == NULL || args->UnlockMutex == NULL) { 3181 3187 if (args->CreateMutex != NULL || args->DestroyMutex != NULL || args->LockMutex != NULL || args->UnlockMutex != NULL) { ................................................................................ 3188 3194 cackey_args.CreateMutex = NULL; 3189 3195 cackey_args.DestroyMutex = NULL; 3190 3196 cackey_args.LockMutex = NULL; 3191 3197 cackey_args.UnlockMutex = NULL; 3192 3198 cackey_args.flags = 0; 3193 3199 } 3194 3200 3195 - if (cackey_initialized) { 3196 - CACKEY_DEBUG_PRINTF("Error. Already initialized."); 3197 - 3198 - return(CKR_CRYPTOKI_ALREADY_INITIALIZED); 3199 - } 3200 - 3201 3201 for (idx = 0; idx < (sizeof(cackey_sessions) / sizeof(cackey_sessions[0])); idx++) { 3202 3202 cackey_sessions[idx].active = 0; 3203 3203 } 3204 3204 3205 3205 for (idx = 0; idx < (sizeof(cackey_slots) / sizeof(cackey_slots[0])); idx++) { 3206 3206 cackey_slots[idx].active = 0; 3207 3207 cackey_slots[idx].pcsc_reader = NULL; ................................................................................ 3698 3698 3699 3699 if (!cackey_initialized) { 3700 3700 CACKEY_DEBUG_PRINTF("Error. Not initialized."); 3701 3701 3702 3702 return(CKR_CRYPTOKI_NOT_INITIALIZED); 3703 3703 } 3704 3704 3705 + /* XXX: TODO: Implement this... */ 3705 3706 CACKEY_DEBUG_PRINTF("Returning CKR_FUNCTION_NOT_SUPPORTED (%i)", CKR_FUNCTION_NOT_SUPPORTED); 3706 3707 3707 3708 return(CKR_FUNCTION_NOT_SUPPORTED); 3708 3709 } 3709 3710 3710 3711 CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismList)(CK_SLOT_ID slotID, CK_MECHANISM_TYPE_PTR pMechanismList, CK_ULONG_PTR pulCount) { 3711 3712 CACKEY_DEBUG_PRINTF("Called."); ................................................................................ 3719 3720 if (pulCount == NULL) { 3720 3721 CACKEY_DEBUG_PRINTF("Error. pulCount is NULL."); 3721 3722 3722 3723 return(CKR_ARGUMENTS_BAD); 3723 3724 } 3724 3725 3725 3726 if (pMechanismList == NULL) { 3726 - *pulCount = 3; 3727 + *pulCount = 2; 3727 3728 3728 3729 CACKEY_DEBUG_PRINTF("Returning CKR_OK (%i)", CKR_OK); 3729 3730 3730 3731 return(CKR_OK); 3731 3732 } 3732 3733 3733 - if (*pulCount < 3) { 3734 + if (*pulCount < 2) { 3734 3735 CACKEY_DEBUG_PRINTF("Error. Buffer too small."); 3735 3736 3736 3737 return(CKR_BUFFER_TOO_SMALL); 3737 3738 } 3738 3739 3739 3740 pMechanismList[0] = CKM_RSA_PKCS; 3740 3741 pMechanismList[1] = CKM_SHA1_RSA_PKCS;