diff options
Diffstat (limited to 'ckcapi.h')
-rw-r--r-- | ckcapi.h | 41 |
1 files changed, 37 insertions, 4 deletions
@@ -75,12 +75,17 @@ CK_RV ckcapi_session_find (CkCapiSession* sess, CK_OBJECT_HANDLE_PTR objects CK_ULONG max_object_count, CK_ULONG_PTR object_count); CK_RV ckcapi_session_find_final (CkCapiSession* sess); - - /* ------------------------------------------------------------------ * ckcapi-object.c */ +/* For operation_type in CkCapiSession */ +enum +{ + OBJECT_CERT = 1, + OBJECT_BUILTIN = 2 +}; + typedef CK_RV (*CkCapiGetAttribute)(void* obj, CK_ATTRIBUTE_TYPE type, CK_VOID_PTR data, CK_ULONG_PTR len); @@ -103,6 +108,7 @@ typedef struct _CkCapiObjectData } CkCapiObjectData; +typedef CK_RV (*CkCapiPurge)(struct _CkCapiObject* obj); typedef CK_RV (*CkCapiLoadData)(struct _CkCapiObject* obj, CkCapiObjectData* objdata); typedef struct _CkCapiObjectVtable @@ -112,13 +118,34 @@ typedef struct _CkCapiObjectVtable } CkCapiObjectVtable; +/* + * Each object has a unique key which guarantees that we're + * not loading the same objects over and over again. + * Usually these are contiguous members of a struct. These + * macros help calculate the address and length of such a + * unique key + */ + +/* The unique key starts at the address of the starting struct member */ +#define UNIQUE_KEY_AT(obj, mem) \ + (void*)(&((obj->mem))) + +/* Calculates key length between first and last struct members */ +#define UNIQUE_KEY_LEN(obj, first, last) \ + UNIQUE_KEY_VAR_LEN(obj, first, last, sizeof(obj->last)) + +/* Calcs key len between first and a certain num of bytes past last struct member */ +#define UNIQUE_KEY_VAR_LEN(obj, first, last, len) \ + ((((char*)&((obj->last))) - ((char*)&((obj->first)))) + (len)) + typedef struct _CkCapiObject { CK_OBJECT_HANDLE id; + + // These items must remain together in the structure + CkCapiObjectVtable obj_funcs; void* unique_key; size_t unique_len; - CkCapiObjectVtable obj_funcs; - CkCapiObjectDataVtable data_funcs; } CkCapiObject; @@ -157,6 +184,12 @@ CK_RV ckcapi_cert_find_all (CkCapiSession* sess, CK_ATTRIBUTE_PTR match, CK_RV ckcapi_cert_find_in_store (CkCapiSession* sess, const char* store_name, CK_ATTRIBUTE_PTR match, CK_ULONG count, CkCapiArray* arr); +/* ------------------------------------------------------------------- + * ckcapi-builtin.c + */ + +CK_RV ckcapi_builtin_find_all (CkCapiSession* sess, CK_ATTRIBUTE_PTR match, + CK_ULONG count, CkCapiArray* arr); #endif /* CRYPTOKI_CAPI_H */ |