CK_RV C_GetInfo(CK_INFO_PTR pInfo) { CK_RV rv = CKR_OK; if (pInfo == NULL_PTR) return CKR_ARGUMENTS_BAD; rv = sc_pkcs11_lock(); if (rv != CKR_OK) return rv; sc_log(context, "C_GetInfo()"); memset(pInfo, 0, sizeof(CK_INFO)); pInfo->cryptokiVersion.major = 2; pInfo->cryptokiVersion.minor = 20; strcpy_bp(pInfo->manufacturerID, OPENSC_VS_FF_COMPANY_NAME, sizeof(pInfo->manufacturerID)); strcpy_bp(pInfo->libraryDescription, OPENSC_VS_FF_PRODUCT_NAME, sizeof(pInfo->libraryDescription)); pInfo->libraryVersion.major = OPENSC_VERSION_MAJOR; pInfo->libraryVersion.minor = OPENSC_VERSION_MINOR; sc_pkcs11_unlock(); return rv; }
CK_RV C_GetInfo(CK_INFO_PTR pInfo) { CK_RV rv = CKR_OK; if (pInfo == NULL_PTR) return CKR_ARGUMENTS_BAD; rv = sc_pkcs11_lock(); if (rv != CKR_OK) return rv; sc_log(context, "C_GetInfo()"); memset(pInfo, 0, sizeof(CK_INFO)); pInfo->cryptokiVersion.major = 2; if (sc_pkcs11_conf.plug_and_play) { pInfo->cryptokiVersion.minor = 20; } else { pInfo->cryptokiVersion.minor = 11; } strcpy_bp(pInfo->manufacturerID, "OpenSC (www.opensc-project.org)", sizeof(pInfo->manufacturerID)); strcpy_bp(pInfo->libraryDescription, "Smart card PKCS#11 API", sizeof(pInfo->libraryDescription)); pInfo->libraryVersion.major = 0; pInfo->libraryVersion.minor = 0; /* FIXME: use 0.116 for 0.11.6 from autoconf */ sc_pkcs11_unlock(); return rv; }
static void init_slot_info(CK_SLOT_INFO_PTR pInfo) { strcpy_bp(pInfo->slotDescription, "Virtual hotplug slot", 64); strcpy_bp(pInfo->manufacturerID, "OpenSC (www.opensc-project.org)", 32); pInfo->flags = CKF_REMOVABLE_DEVICE | CKF_HW_SLOT; pInfo->hardwareVersion.major = 0; pInfo->hardwareVersion.minor = 0; pInfo->firmwareVersion.major = 0; pInfo->firmwareVersion.minor = 0; }
CK_RV create_slot(sc_reader_t *reader) { /* find unused virtual hotplug slots */ struct sc_pkcs11_slot *slot = reader_get_slot(NULL); /* create a new slot if no empty slot is available */ if (!slot) { if (list_size(&virtual_slots) >= sc_pkcs11_conf.max_virtual_slots) return CKR_FUNCTION_FAILED; slot = (struct sc_pkcs11_slot *)calloc(1, sizeof(struct sc_pkcs11_slot)); if (!slot) return CKR_HOST_MEMORY; list_append(&virtual_slots, slot); if (0 != list_init(&slot->objects)) { return CKR_HOST_MEMORY; } list_attributes_seeker(&slot->objects, object_list_seeker); if (0 != list_init(&slot->logins)) { return CKR_HOST_MEMORY; } } else { /* reuse the old list of logins/objects since they should be empty */ list_t logins = slot->logins; list_t objects = slot->objects; memset(slot, 0, sizeof *slot); slot->logins = logins; slot->objects = objects; } slot->login_user = -1; slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot); init_slot_info(&slot->slot_info, reader); sc_log(context, "Initializing slot with id 0x%lx", slot->id); if (reader != NULL) { slot->reader = reader; strcpy_bp(slot->slot_info.manufacturerID, reader->vendor, 32); strcpy_bp(slot->slot_info.slotDescription, reader->name, 64); slot->slot_info.hardwareVersion.major = reader->version_major; slot->slot_info.hardwareVersion.minor = reader->version_minor; } return CKR_OK; }
CK_RV create_slot(sc_reader_t *reader) { struct sc_pkcs11_slot *slot; if (list_size(&virtual_slots) >= sc_pkcs11_conf.max_virtual_slots) return CKR_FUNCTION_FAILED; slot = (struct sc_pkcs11_slot *)calloc(1, sizeof(struct sc_pkcs11_slot)); if (!slot) return CKR_HOST_MEMORY; list_append(&virtual_slots, slot); slot->login_user = -1; slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot); sc_debug(context, SC_LOG_DEBUG_NORMAL, "Creating slot with id 0x%lx", slot->id); list_init(&slot->objects); list_attributes_seeker(&slot->objects, object_list_seeker); init_slot_info(&slot->slot_info); if (reader != NULL) { slot->reader = reader; strcpy_bp(slot->slot_info.slotDescription, reader->name, 64); } return CKR_OK; }
static void init_slot_info(CK_SLOT_INFO_PTR pInfo, sc_reader_t *reader) { if (reader) { strcpy_bp(pInfo->slotDescription, reader->name, 64); strcpy_bp(pInfo->manufacturerID, reader->vendor, 32); pInfo->hardwareVersion.major = reader->version_major; pInfo->hardwareVersion.minor = reader->version_minor; } else { strcpy_bp(pInfo->slotDescription, "Virtual hotplug slot", 64); strcpy_bp(pInfo->manufacturerID, OPENSC_VS_FF_COMPANY_NAME, 32); pInfo->hardwareVersion.major = OPENSC_VERSION_MAJOR; pInfo->hardwareVersion.minor = OPENSC_VERSION_MINOR; } pInfo->flags = CKF_REMOVABLE_DEVICE | CKF_HW_SLOT; pInfo->firmwareVersion.major = 0; pInfo->firmwareVersion.minor = 0; }
static CK_RV pkcs15init_create_tokens(struct sc_pkcs11_card *p11card, struct sc_app_info *app_info, struct sc_pkcs11_slot **first_slot) { struct sc_profile *profile; struct sc_pkcs11_slot *slot; int rc; profile = (struct sc_profile *) p11card->fws_data[0]; rc = slot_allocate(&slot, p11card); if (rc == CKR_OK) { CK_TOKEN_INFO_PTR pToken = &slot->token_info; const char *string; slot->slot_info.flags |= CKF_TOKEN_PRESENT; strcpy_bp(pToken->model, "PKCS #15 SCard", 16); sc_pkcs15init_get_manufacturer(profile, &string); if (!string) string = "Unknown"; strcpy_bp(pToken->manufacturerID, string, 32); sc_pkcs15init_get_serial(profile, &string); if (!string) string = ""; strcpy_bp(pToken->serialNumber, string, 16); pToken->ulMaxSessionCount = CK_EFFECTIVELY_INFINITE; pToken->ulSessionCount = 0; /* FIXME */ pToken->ulMaxRwSessionCount = CK_EFFECTIVELY_INFINITE; pToken->ulRwSessionCount = 0; /* FIXME */ pToken->ulTotalPublicMemory = CK_UNAVAILABLE_INFORMATION; pToken->ulFreePublicMemory = CK_UNAVAILABLE_INFORMATION; pToken->ulTotalPrivateMemory = CK_UNAVAILABLE_INFORMATION; pToken->ulFreePrivateMemory = CK_UNAVAILABLE_INFORMATION; pToken->hardwareVersion.major = 0; pToken->hardwareVersion.minor = 0; pToken->firmwareVersion.major = 0; pToken->firmwareVersion.minor = 0; } return CKR_OK; }