diff options
Diffstat (limited to 'ckcapi.c')
-rw-r--r-- | ckcapi.c | 32 |
1 files changed, 20 insertions, 12 deletions
@@ -24,6 +24,7 @@ #include "ckcapi.h" #include "ckcapi-object.h" #include "ckcapi-session.h" +#include "ckcapi-rsa.h" #include "ckcapi-token.h" /* Warns about all the raw string usage in this file */ @@ -49,6 +50,10 @@ static HANDLE global_mutex = NULL; #define MAX_PIN_LEN 256 #define MIN_PIN_LEN 1 +static CK_MECHANISM_TYPE all_mechanisms[] = { + CKM_RSA_PKCS +}; + /* ------------------------------------------------------------------- * MODULE GLOBAL FUNCTIONS */ @@ -491,6 +496,8 @@ static CK_RV CC_C_GetMechanismList(CK_SLOT_ID id, CK_MECHANISM_TYPE_PTR mechanism_list, CK_ULONG_PTR count) { + CK_ULONG n_mechs; + ENTER(C_GetMechanismList); PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED); PREREQ(count, CKR_ARGUMENTS_BAD); @@ -498,22 +505,23 @@ CC_C_GetMechanismList(CK_SLOT_ID id, CK_MECHANISM_TYPE_PTR mechanism_list, if(!ckcapi_token_is_valid(id)) RETURN(CKR_SLOT_ID_INVALID); - /* TODO: Eventually we'll return stuff here */ - /* mechanism_list[0] = CKM_RSA_PKCS; */ + n_mechs = sizeof(all_mechanisms) / sizeof(all_mechanisms[0]); if(mechanism_list == NULL) { - *count = 0; + *count = n_mechs; RETURN(CKR_OK); } - if(*count < 0) + if(*count < n_mechs) { - *count = 0; + *count = n_mechs; RETURN(CKR_BUFFER_TOO_SMALL); } - *count = 0; + memcpy(mechanism_list, all_mechanisms, + n_mechs * sizeof(CK_MECHANISM_TYPE)); + *count = n_mechs; RETURN(CKR_OK); } @@ -528,13 +536,13 @@ CC_C_GetMechanismInfo(CK_SLOT_ID id, CK_MECHANISM_TYPE type, if(!ckcapi_token_is_valid(id)) RETURN(CKR_SLOT_ID_INVALID); - /* TODO: Eventually we'll return stuff here */ - RETURN(CKR_MECHANISM_INVALID); + if(type == CKM_RSA_PKCS) + { + ckcapi_rsa_pkcs_get_info(type, info); + RETURN(CKR_OK); + } - /* info->ulMinKeySize = 384; - info->ulMaxKeySize = 16384; - info->flags = 0; - RETURN(CKR_OK);*/ + RETURN(CKR_MECHANISM_INVALID); } static CK_RV |