Separated slot vendors and token vendors.
This commit is contained in:
+4
-1
@@ -34,7 +34,10 @@ AM_CPPFLAGS += -I$(top_srcdir)/lib -I$(top_builddir)/lib
|
||||
lib_LTLIBRARIES = libykcs11.la
|
||||
|
||||
libykcs11_la_SOURCES = ykcs11.c version.c ykcs11.pc.in ykcs11.map
|
||||
libykcs11_la_SOURCES += vendors.c vendor.h yubico.c yubico.h
|
||||
libykcs11_la_SOURCES += vendors.c vendor.h vendor_ids.h
|
||||
libykcs11_la_SOURCES += slot_vendors.c slot_vendor.h
|
||||
libykcs11_la_SOURCES += token_vendors.c token_vendor.h
|
||||
libykcs11_la_SOURCES += yubico_slot.c yubico_slot.h yubico_token.c yubico_token.h
|
||||
libykcs11_la_SOURCES += utils.h utils.c
|
||||
libykcs11_la_SOURCES += obj_types.h objects.h objects.c
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "slot_vendors.h"
|
||||
#include "yubico_slot.h"
|
||||
|
||||
slot_vendor_t get_slot_vendor(vendor_id_t vid) {
|
||||
slot_vendor_t v;
|
||||
|
||||
switch (vid) {
|
||||
case YUBICO:
|
||||
v.get_slot_description = YUBICO_get_slot_description;
|
||||
v.get_slot_manufacturer = YUBICO_get_slot_manufacturer;
|
||||
v.get_slot_flags = YUBICO_get_slot_flags;
|
||||
v.get_slot_version = YUBICO_get_slot_version;
|
||||
break;
|
||||
|
||||
case UNKNOWN:
|
||||
default:
|
||||
v.get_slot_description = NULL;
|
||||
v.get_slot_manufacturer = NULL;
|
||||
v.get_slot_flags = NULL;
|
||||
v.get_slot_version = NULL;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef SLOT_VENDORS_H
|
||||
#define SLOT_VENDORS_H
|
||||
|
||||
#include "pkcs11.h"
|
||||
#include "vendor_ids.h"
|
||||
|
||||
typedef CK_RV (*get_s_description_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_s_manufacturer_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_s_flags_f)(CK_FLAGS_PTR);
|
||||
typedef CK_RV (*get_s_version_f)(CK_VERSION_PTR);
|
||||
|
||||
|
||||
typedef struct {
|
||||
get_s_description_f get_slot_description;
|
||||
get_s_manufacturer_f get_slot_manufacturer;
|
||||
get_s_flags_f get_slot_flags;
|
||||
get_s_version_f get_slot_version;
|
||||
} slot_vendor_t;
|
||||
|
||||
slot_vendor_t get_slot_vendor(vendor_id_t vid);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "token_vendors.h"
|
||||
#include "yubico_token.h"
|
||||
|
||||
token_vendor_t get_token_vendor(vendor_id_t vid) {
|
||||
token_vendor_t v;
|
||||
|
||||
switch (vid) {
|
||||
case YUBICO:
|
||||
v.get_token_label = YUBICO_get_token_label;
|
||||
v.get_token_manufacturer = YUBICO_get_token_manufacturer;
|
||||
v.get_token_model = YUBICO_get_token_model;
|
||||
v.get_token_flags = YUBICO_get_token_flags;
|
||||
v.get_token_version = YUBICO_get_token_version;
|
||||
v.get_token_serial = YUBICO_get_token_serial;
|
||||
v.get_token_mechanisms_num = YUBICO_get_token_mechanisms_num;
|
||||
v.get_token_mechanism_list = YUBICO_get_token_mechanism_list;
|
||||
v.get_token_mechanism_info = YUBICO_get_token_mechanism_info;
|
||||
v.get_token_objects_num = YUBICO_get_token_objects_num;
|
||||
v.get_token_object_list = YUBICO_get_token_object_list;
|
||||
break;
|
||||
|
||||
case UNKNOWN:
|
||||
default:
|
||||
v.get_token_label = NULL;
|
||||
v.get_token_manufacturer = NULL;
|
||||
v.get_token_model = NULL;
|
||||
v.get_token_flags = NULL;
|
||||
v.get_token_version = NULL;
|
||||
v.get_token_serial = NULL;
|
||||
v.get_token_mechanisms_num = NULL;
|
||||
v.get_token_mechanism_list = NULL;
|
||||
v.get_token_mechanism_info = NULL;
|
||||
v.get_token_objects_num = NULL;
|
||||
v.get_token_object_list = NULL;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef TOKEN_VENDORS_H
|
||||
#define TOKEN_VENDORS_H
|
||||
|
||||
#include "pkcs11.h"
|
||||
#include "vendor_ids.h"
|
||||
#include "objects.h"
|
||||
#include <ykpiv.h>
|
||||
|
||||
typedef CK_RV (*get_t_label_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_manufacturer_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_model_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_flags_f)(CK_FLAGS_PTR);
|
||||
typedef CK_RV (*get_t_version_f)(CK_UTF8CHAR_PTR, CK_ULONG, CK_VERSION_PTR);
|
||||
typedef CK_RV (*get_t_serial_f)(CK_CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_mechanisms_num_f)(CK_ULONG_PTR);
|
||||
typedef CK_RV (*get_t_mechanism_list_f)(CK_MECHANISM_TYPE_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_mechanism_info_f)(CK_MECHANISM_TYPE, CK_MECHANISM_INFO_PTR);
|
||||
typedef CK_RV (*get_t_objects_num_f)(ykpiv_state *, CK_ULONG_PTR);
|
||||
typedef CK_RV (*get_t_object_list_f)(ykpiv_state *, piv_obj_id_t *, CK_ULONG);
|
||||
|
||||
typedef struct {
|
||||
get_t_label_f get_token_label;
|
||||
get_t_manufacturer_f get_token_manufacturer;
|
||||
get_t_model_f get_token_model;
|
||||
get_t_flags_f get_token_flags;
|
||||
get_t_version_f get_token_version;
|
||||
get_t_serial_f get_token_serial;
|
||||
get_t_mechanisms_num_f get_token_mechanisms_num;
|
||||
get_t_mechanism_list_f get_token_mechanism_list;
|
||||
get_t_mechanism_info_f get_token_mechanism_info;
|
||||
get_t_objects_num_f get_token_objects_num;
|
||||
get_t_object_list_f get_token_object_list;
|
||||
} token_vendor_t;
|
||||
|
||||
token_vendor_t get_token_vendor(vendor_id_t vid);
|
||||
|
||||
#endif
|
||||
+15
-14
@@ -15,7 +15,7 @@ CK_RV parse_readers(const CK_BYTE_PTR readers, const CK_ULONG len,
|
||||
CK_BYTE_PTR p;
|
||||
CK_BYTE_PTR s;
|
||||
CK_ULONG l;
|
||||
vendor_t vendor;
|
||||
slot_vendor_t slot;
|
||||
|
||||
*n_slots = 0;
|
||||
*n_with_token = 0;
|
||||
@@ -42,30 +42,30 @@ CK_RV parse_readers(const CK_BYTE_PTR readers, const CK_ULONG len,
|
||||
}
|
||||
else {
|
||||
// Supported slot
|
||||
vendor = get_vendor(slots[*n_slots].vid);
|
||||
slot = get_slot_vendor(slots[*n_slots].vid);
|
||||
|
||||
// Values must NOT be null terminated and ' ' padded
|
||||
|
||||
memset(slots[*n_slots].info.slotDescription, ' ', sizeof(slots[*n_slots].info.slotDescription));
|
||||
s = slots[*n_slots].info.slotDescription;
|
||||
l = sizeof(slots[*n_slots].info.slotDescription);
|
||||
if (vendor.get_slot_description(s, l) != CKR_OK)
|
||||
if (slot.get_slot_description(s, l) != CKR_OK)
|
||||
goto failure;
|
||||
|
||||
memset(slots[*n_slots].info.manufacturerID, ' ', sizeof(slots[*n_slots].info.manufacturerID));
|
||||
s = slots[*n_slots].info.manufacturerID;
|
||||
l = sizeof(slots[*n_slots].info.manufacturerID);
|
||||
if(vendor.get_slot_manufacturer(s, l) != CKR_OK)
|
||||
if(slot.get_slot_manufacturer(s, l) != CKR_OK)
|
||||
goto failure;
|
||||
|
||||
if (vendor.get_slot_flags(&slots[*n_slots].info.flags) != CKR_OK)
|
||||
if (slot.get_slot_flags(&slots[*n_slots].info.flags) != CKR_OK)
|
||||
goto failure;
|
||||
|
||||
// Treating hw and fw version the same
|
||||
if (vendor.get_slot_version(&slots[*n_slots].info.hardwareVersion) != CKR_OK)
|
||||
if (slot.get_slot_version(&slots[*n_slots].info.hardwareVersion) != CKR_OK)
|
||||
goto failure;
|
||||
|
||||
if (vendor.get_slot_version(&slots[*n_slots].info.firmwareVersion) != CKR_OK)
|
||||
if (slot.get_slot_version(&slots[*n_slots].info.firmwareVersion) != CKR_OK)
|
||||
goto failure;
|
||||
|
||||
if (has_token(slots + *n_slots)) {
|
||||
@@ -92,7 +92,8 @@ failure:
|
||||
}
|
||||
|
||||
CK_RV create_token(CK_BYTE_PTR p, ykcs11_slot_t *slot) {
|
||||
vendor_t token_vendor;
|
||||
|
||||
token_vendor_t token;
|
||||
CK_TOKEN_INFO_PTR t_info;
|
||||
fprintf(stderr, "Now trying to get token info from %s\n", p); // TODO: is p needed?
|
||||
|
||||
@@ -101,27 +102,27 @@ CK_RV create_token(CK_BYTE_PTR p, ykcs11_slot_t *slot) {
|
||||
return CKR_HOST_MEMORY;
|
||||
|
||||
slot->token->vid = YUBICO; // TODO: this must become "slot_vendor.get_token_vid()"
|
||||
token_vendor = get_vendor(slot->token->vid);
|
||||
token = get_token_vendor(slot->token->vid);
|
||||
|
||||
t_info = &slot->token->info;
|
||||
|
||||
memset(t_info->label, ' ', sizeof(t_info->label));
|
||||
if (token_vendor.get_token_label(t_info->label, sizeof(t_info->label)) != CKR_OK)
|
||||
if (token.get_token_label(t_info->label, sizeof(t_info->label)) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
memset(t_info->manufacturerID, ' ', sizeof(t_info->manufacturerID));
|
||||
if(token_vendor.get_token_manufacturer(t_info->manufacturerID, sizeof(t_info->manufacturerID)) != CKR_OK)
|
||||
if(token.get_token_manufacturer(t_info->manufacturerID, sizeof(t_info->manufacturerID)) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
memset(t_info->model, ' ', sizeof(t_info->model));
|
||||
if(token_vendor.get_token_model(t_info->model, sizeof(t_info->model)) != CKR_OK)
|
||||
if(token.get_token_model(t_info->model, sizeof(t_info->model)) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
memset(t_info->serialNumber, ' ', sizeof(t_info->serialNumber));
|
||||
if(token_vendor.get_token_serial(t_info->serialNumber, sizeof(t_info->serialNumber)) != CKR_OK)
|
||||
if(token.get_token_serial(t_info->serialNumber, sizeof(t_info->serialNumber)) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
if (token_vendor.get_token_flags(&t_info->flags) != CKR_OK)
|
||||
if (token.get_token_flags(&t_info->flags) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
t_info->ulMaxSessionCount = CK_UNAVAILABLE_INFORMATION;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef VENDOR_IDS_H
|
||||
#define VENDOR_IDS_H
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN = 0x00,
|
||||
YUBICO = 0x01
|
||||
} vendor_id_t;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "vendors.h"
|
||||
#include "yubico.h"
|
||||
#include <string.h>
|
||||
|
||||
vendor_id_t get_vendor_id(char *vendor_name) {
|
||||
@@ -10,48 +9,3 @@ vendor_id_t get_vendor_id(char *vendor_name) {
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
vendor_t get_vendor(vendor_id_t vid) {
|
||||
vendor_t v;
|
||||
|
||||
switch (vid) {
|
||||
case YUBICO:
|
||||
v.get_slot_description = YUBICO_get_slot_description;
|
||||
v.get_slot_manufacturer = YUBICO_get_slot_manufacturer;
|
||||
v.get_slot_flags = YUBICO_get_slot_flags;
|
||||
v.get_slot_version = YUBICO_get_slot_version;
|
||||
v.get_token_label = YUBICO_get_token_label;
|
||||
v.get_token_manufacturer = YUBICO_get_token_manufacturer;
|
||||
v.get_token_model = YUBICO_get_token_model;
|
||||
v.get_token_flags = YUBICO_get_token_flags;
|
||||
v.get_token_version = YUBICO_get_token_version;
|
||||
v.get_token_serial = YUBICO_get_token_serial;
|
||||
v.get_token_mechanisms_num = YUBICO_get_token_mechanisms_num;
|
||||
v.get_token_mechanism_list = YUBICO_get_token_mechanism_list;
|
||||
v.get_token_mechanism_info = YUBICO_get_token_mechanism_info;
|
||||
v.get_token_objects_num = YUBICO_get_token_objects_num;
|
||||
v.get_token_object_list = YUBICO_get_token_object_list;
|
||||
break;
|
||||
|
||||
case UNKNOWN:
|
||||
default:
|
||||
v.get_slot_description = NULL;
|
||||
v.get_slot_manufacturer = NULL;
|
||||
v.get_slot_flags = NULL;
|
||||
v.get_slot_version = NULL;
|
||||
v.get_token_label = NULL;
|
||||
v.get_token_manufacturer = NULL;
|
||||
v.get_token_model = NULL;
|
||||
v.get_token_flags = NULL;
|
||||
v.get_token_version = NULL;
|
||||
v.get_token_serial = NULL;
|
||||
v.get_token_mechanisms_num = NULL;
|
||||
v.get_token_mechanism_list = NULL;
|
||||
v.get_token_mechanism_info = NULL;
|
||||
v.get_token_objects_num = NULL;
|
||||
v.get_token_object_list = NULL;
|
||||
}
|
||||
|
||||
return v;
|
||||
|
||||
}
|
||||
|
||||
+3
-44
@@ -1,51 +1,10 @@
|
||||
#ifndef VENDORS_H
|
||||
#define VENDORS_H
|
||||
|
||||
#include "pkcs11.h"
|
||||
#include "objects.h"
|
||||
#include <ykpiv.h>
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN = 0x00,
|
||||
YUBICO = 0x01
|
||||
} vendor_id_t;
|
||||
|
||||
typedef CK_RV (*get_s_description_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_s_manufacturer_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_s_flags_f)(CK_FLAGS_PTR);
|
||||
typedef CK_RV (*get_s_version_f)(CK_VERSION_PTR);
|
||||
typedef CK_RV (*get_t_label_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_manufacturer_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_model_f)(CK_UTF8CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_flags_f)(CK_FLAGS_PTR);
|
||||
typedef CK_RV (*get_t_version_f)(CK_UTF8CHAR_PTR, CK_ULONG, CK_VERSION_PTR);
|
||||
typedef CK_RV (*get_t_serial_f)(CK_CHAR_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_mechanisms_num_f)(CK_ULONG_PTR);
|
||||
typedef CK_RV (*get_t_mechanism_list_f)(CK_MECHANISM_TYPE_PTR, CK_ULONG);
|
||||
typedef CK_RV (*get_t_mechanism_info_f)(CK_MECHANISM_TYPE, CK_MECHANISM_INFO_PTR);
|
||||
typedef CK_RV (*get_t_objects_num_f)(ykpiv_state *, CK_ULONG_PTR);
|
||||
typedef CK_RV (*get_t_object_list_f)(ykpiv_state *, piv_obj_id_t *, CK_ULONG);
|
||||
|
||||
|
||||
typedef struct {
|
||||
get_s_description_f get_slot_description;
|
||||
get_s_manufacturer_f get_slot_manufacturer;
|
||||
get_s_flags_f get_slot_flags;
|
||||
get_s_version_f get_slot_version;
|
||||
get_t_label_f get_token_label;
|
||||
get_t_manufacturer_f get_token_manufacturer;
|
||||
get_t_model_f get_token_model;
|
||||
get_t_flags_f get_token_flags;
|
||||
get_t_version_f get_token_version;
|
||||
get_t_serial_f get_token_serial;
|
||||
get_t_mechanisms_num_f get_token_mechanisms_num;
|
||||
get_t_mechanism_list_f get_token_mechanism_list;
|
||||
get_t_mechanism_info_f get_token_mechanism_info;
|
||||
get_t_objects_num_f get_token_objects_num;
|
||||
get_t_object_list_f get_token_object_list;
|
||||
} vendor_t;
|
||||
#include "vendor_ids.h"
|
||||
#include "slot_vendors.h"
|
||||
#include "token_vendors.h"
|
||||
|
||||
vendor_id_t get_vendor_id(char *vendor_name);
|
||||
vendor_t get_vendor(vendor_id_t vid);
|
||||
|
||||
#endif
|
||||
|
||||
+14
-17
@@ -237,7 +237,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetTokenInfo)(
|
||||
{
|
||||
DIN;
|
||||
CK_VERSION ver = {0, 0};
|
||||
vendor_t token_vendor;
|
||||
token_vendor_t token;
|
||||
CK_BYTE buf[64];
|
||||
|
||||
if (piv_state == NULL)
|
||||
@@ -261,7 +261,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetTokenInfo)(
|
||||
return CKR_TOKEN_NOT_RECOGNIZED;
|
||||
}
|
||||
|
||||
token_vendor = get_vendor(slots[slotID].token->vid);
|
||||
token = get_token_vendor(slots[slotID].token->vid);
|
||||
|
||||
memcpy(pInfo, &slots[slotID].token->info, sizeof(CK_TOKEN_INFO));
|
||||
|
||||
@@ -279,7 +279,6 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetTokenInfo)(
|
||||
pInfo->ulTotalPrivateMemory = CK_UNAVAILABLE_INFORMATION;
|
||||
pInfo->ulFreePrivateMemory = CK_UNAVAILABLE_INFORMATION;
|
||||
|
||||
|
||||
DOUT;
|
||||
return CKR_OK;
|
||||
}
|
||||
@@ -303,7 +302,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismList)(
|
||||
)
|
||||
{
|
||||
DIN;
|
||||
vendor_t vendor;
|
||||
token_vendor_t token;
|
||||
CK_ULONG count;
|
||||
|
||||
if (piv_state == NULL) {
|
||||
@@ -322,9 +321,9 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismList)(
|
||||
// TODO: check more return values
|
||||
// TODO: user NULL_PTR more for coherence
|
||||
|
||||
vendor = get_vendor(slots[slotID].vid); // TODO: make a token field in slot_t ?;
|
||||
token = get_token_vendor(slots[slotID].vid);
|
||||
|
||||
if (vendor.get_token_mechanisms_num(&count) != CKR_OK)
|
||||
if (token.get_token_mechanisms_num(&count) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
if (pMechanismList == NULL_PTR) {
|
||||
@@ -339,7 +338,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismList)(
|
||||
return CKR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
if (vendor.get_token_mechanism_list(pMechanismList, *pulCount) != CKR_OK)
|
||||
if (token.get_token_mechanism_list(pMechanismList, *pulCount) != CKR_OK)
|
||||
return CKR_FUNCTION_FAILED;
|
||||
|
||||
DOUT;
|
||||
@@ -353,7 +352,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismInfo)(
|
||||
)
|
||||
{
|
||||
DIN;
|
||||
vendor_t vendor;
|
||||
token_vendor_t token;
|
||||
|
||||
if (piv_state == NULL) {
|
||||
DBG(("libykpiv is not initialized or already finalized"));
|
||||
@@ -371,9 +370,9 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismInfo)(
|
||||
// TODO: check more return values
|
||||
// TODO: user NULL_PTR more for coherence
|
||||
|
||||
vendor = get_vendor(slots[slotID].vid); // TODO: make a token field in slot_t ?;
|
||||
token = get_token_vendor(slots[slotID].vid);
|
||||
|
||||
if (vendor.get_token_mechanism_info(type, pInfo) != CKR_OK)
|
||||
if (token.get_token_mechanism_info(type, pInfo) != CKR_OK)
|
||||
return CKR_MECHANISM_INVALID;
|
||||
|
||||
DOUT;
|
||||
@@ -428,7 +427,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_OpenSession)(
|
||||
{
|
||||
DIN;
|
||||
|
||||
vendor_t token_vendor;
|
||||
token_vendor_t token;
|
||||
|
||||
if (piv_state == NULL)
|
||||
return CKR_CRYPTOKI_NOT_INITIALIZED;
|
||||
@@ -461,14 +460,14 @@ CK_DEFINE_FUNCTION(CK_RV, C_OpenSession)(
|
||||
return CKR_SESSION_PARALLEL_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
token_vendor = get_vendor(slots[slotID].token->vid);
|
||||
token = get_token_vendor(slots[slotID].token->vid);
|
||||
|
||||
// Store the slot
|
||||
session.slot = slots + slotID;
|
||||
//session.slot->info.slotID = slotID; // Redundant but required in CK_SESSION_INFO
|
||||
|
||||
// Get the number of token objects
|
||||
if (token_vendor.get_token_objects_num(piv_state, &session.slot->token->n_objects) != CKR_OK) {
|
||||
if (token.get_token_objects_num(piv_state, &session.slot->token->n_objects) != CKR_OK) {
|
||||
DBG(("Unable to retrieve number of token objects"));
|
||||
return CKR_FUNCTION_FAILED;
|
||||
}
|
||||
@@ -481,7 +480,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_OpenSession)(
|
||||
}
|
||||
|
||||
// Store all the objects available in the token
|
||||
if (token_vendor.get_token_object_list(piv_state,
|
||||
if (token.get_token_object_list(piv_state,
|
||||
session.slot->token->objects,
|
||||
session.slot->token->n_objects) != CKR_OK) {
|
||||
DBG(("Unable to retrieve token objects"));
|
||||
@@ -789,7 +788,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_FindObjectsInit)(
|
||||
{
|
||||
DIN;
|
||||
CK_ULONG i;
|
||||
vendor_t vendor;
|
||||
//token_vendor_t token;
|
||||
|
||||
if (piv_state == NULL)
|
||||
return CKR_CRYPTOKI_NOT_INITIALIZED;
|
||||
@@ -803,8 +802,6 @@ CK_DEFINE_FUNCTION(CK_RV, C_FindObjectsInit)(
|
||||
if (find_obj.active == CK_TRUE)
|
||||
return CKR_OPERATION_ACTIVE;
|
||||
|
||||
//vendor = get_vendor(slots[session_info.slotID].vid); // TODO: make a token field in slot_t ?;
|
||||
|
||||
find_obj.idx = 0;
|
||||
find_obj.num = session.slot->token->n_objects;
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "yubico_slot.h"
|
||||
#include "pkcs11.h"
|
||||
#include <string.h>
|
||||
|
||||
static const CK_UTF8CHAR_PTR slot_description = "YubiKey Virtual Reader";
|
||||
static const CK_UTF8CHAR_PTR slot_manufacturer = "Yubico";
|
||||
static const CK_FLAGS slot_flags = CKF_TOKEN_PRESENT | CKF_HW_SLOT;
|
||||
static const CK_VERSION slot_version = {1, 0};
|
||||
|
||||
CK_RV YUBICO_get_slot_description(CK_UTF8CHAR_PTR str, CK_ULONG len) {
|
||||
|
||||
if (strlen(slot_description) > len)
|
||||
return CKR_BUFFER_TOO_SMALL;
|
||||
|
||||
memcpy(str, slot_description, strlen(slot_description));
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_slot_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len) {
|
||||
|
||||
if (strlen(slot_manufacturer) > len)
|
||||
return CKR_BUFFER_TOO_SMALL;
|
||||
|
||||
memcpy(str, slot_manufacturer, strlen(slot_manufacturer));
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_slot_flags(CK_FLAGS_PTR flags) {
|
||||
|
||||
*flags = slot_flags;
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_slot_version(CK_VERSION_PTR version) {
|
||||
|
||||
version->major = slot_version.major;
|
||||
version->minor = slot_version.minor;
|
||||
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef YUBICO_SLOT_H
|
||||
#define YUBICO_SLOT_H
|
||||
|
||||
#include "pkcs11.h"
|
||||
|
||||
CK_RV YUBICO_get_slot_description(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
CK_RV YUBICO_get_slot_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
CK_RV YUBICO_get_slot_flags(CK_FLAGS_PTR flags);
|
||||
CK_RV YUBICO_get_slot_version(CK_VERSION_PTR version);
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "yubico.h"
|
||||
#include "yubico_token.h"
|
||||
#include "pkcs11.h"
|
||||
#include <string.h>
|
||||
|
||||
@@ -9,11 +9,6 @@
|
||||
#define MIN_ECC_KEY_SIZE 256
|
||||
#define MAX_ECC_KEY_SIZE 384
|
||||
|
||||
// TODO add a type in vendor_t for SLOT | READER
|
||||
static const CK_UTF8CHAR_PTR slot_description = "YubiKey Virtual Reader";
|
||||
static const CK_UTF8CHAR_PTR slot_manufacturer = "Yubico";
|
||||
static const CK_FLAGS slot_flags = CKF_TOKEN_PRESENT | CKF_HW_SLOT;
|
||||
static const CK_VERSION slot_version = {1, 0};
|
||||
static const CK_UTF8CHAR_PTR token_label = "YubiKey PIV X";
|
||||
static const CK_UTF8CHAR_PTR token_manufacturer = "Yubico";
|
||||
static const CK_UTF8CHAR_PTR token_model = "YubiKey MODEL";
|
||||
@@ -107,42 +102,6 @@ static const piv_obj_id_t token_objects[] = { // TODO: is there a way to get thi
|
||||
};
|
||||
static const CK_ULONG token_objects_num = sizeof(token_objects) / sizeof(piv_obj_id_t);
|
||||
|
||||
CK_RV YUBICO_get_slot_description(CK_UTF8CHAR_PTR str, CK_ULONG len) {
|
||||
|
||||
if (strlen(slot_description) > len)
|
||||
return CKR_BUFFER_TOO_SMALL;
|
||||
|
||||
memcpy(str, slot_description, strlen(slot_description));
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_slot_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len) {
|
||||
|
||||
if (strlen(slot_manufacturer) > len)
|
||||
return CKR_BUFFER_TOO_SMALL;
|
||||
|
||||
memcpy(str, slot_manufacturer, strlen(slot_manufacturer));
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_slot_flags(CK_FLAGS_PTR flags) {
|
||||
|
||||
*flags = slot_flags;
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_slot_version(CK_VERSION_PTR version) {
|
||||
|
||||
version->major = slot_version.major;
|
||||
version->minor = slot_version.minor;
|
||||
|
||||
return CKR_OK;
|
||||
|
||||
}
|
||||
|
||||
CK_RV YUBICO_get_token_label(CK_UTF8CHAR_PTR str, CK_ULONG len) {
|
||||
|
||||
if (strlen(token_label) > len)
|
||||
@@ -1,14 +1,10 @@
|
||||
#ifndef YUBICO_H
|
||||
#define YUBICO_H
|
||||
#ifndef YUBICO_TOKEN_H
|
||||
#define YUBICO_TOKEN_H
|
||||
|
||||
#include "pkcs11.h"
|
||||
#include "obj_types.h"
|
||||
#include <ykpiv.h>
|
||||
|
||||
CK_RV YUBICO_get_slot_description(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
CK_RV YUBICO_get_slot_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
CK_RV YUBICO_get_slot_flags(CK_FLAGS_PTR flags);
|
||||
CK_RV YUBICO_get_slot_version(CK_VERSION_PTR version);
|
||||
CK_RV YUBICO_get_token_label(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
CK_RV YUBICO_get_token_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
CK_RV YUBICO_get_token_model(CK_UTF8CHAR_PTR str, CK_ULONG len);
|
||||
Reference in New Issue
Block a user