diff options
author | Stef Walter <stef@memberwebs.com> | 2007-04-27 03:19:46 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2007-04-27 03:19:46 +0000 |
commit | 3d8ed01d2653c45e52821ba00ac72099a12600e1 (patch) | |
tree | ad13d6df465ef1a4f143109f04c35991ddb1efba /cryptoki-capi.h |
Diffstat (limited to 'cryptoki-capi.h')
-rw-r--r-- | cryptoki-capi.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/cryptoki-capi.h b/cryptoki-capi.h new file mode 100644 index 0000000..a5dc9d5 --- /dev/null +++ b/cryptoki-capi.h @@ -0,0 +1,99 @@ +#ifndef CRYPTOKI_CAPI_H +#define CRYPTOKI_CAPI_H + +#ifndef ASSERT +#include "assert.h" +#define ASSERT assert +#endif + +#define WIN32_LEAN_AND_MEAN +#define _WIN32_WINNT 0x400 +#include <windows.h> + +#define CRYPTOKI_EXPORTS +#include "pkcs11/cryptoki.h" + +#include "cryptoki-capi-util.h" + +struct _Object; +struct _Session; + +/* ------------------------------------------------------------------ + * cryptoki-capi.c + */ + +#define DBG(args) \ + ckcapi_debug args + +void ckcapi_debug(const char* msg, ...); +void ckcapi_lock_global(void); +void ckcapi_unlock_global(void); +CK_RV ckcapi_winerr_to_ckr (DWORD werr); + +/* ------------------------------------------------------------------ + * cryptoki-capi-session.c + */ + +/* For operation_type in Session */ +enum +{ + OPERATION_NONE = 0, + OPERATION_FIND = 1, +}; + +typedef void (*SessionCancel) (struct _Session* sess); + +typedef struct _Session +{ + CK_ULONG id; /* Unique ID for this session */ + int in_call; /* Whether this session is use in PKCS#11 function */ + + int operation_type; /* Whether an operation is happening or not */ + void* operation_data; /* Data for this operation */ + SessionCancel operation_cancel; /* Callback to cancel operation when necessary */ + + CK_NOTIFY notify_callback; /* Application specified callback */ + CK_VOID_PTR user_data; /* Argument for above */ + + int refs; /* Reference count */ + HANDLE mutex; /* Mutex for protecting this structure */ +} +Session; + +#define DBGS(sess, msg) \ + ckcapi_debug("S%d: %s", (sess) ? (sess)->id : 0, (msg)) + +Session* ckcapi_session_create(void); +void ckcapi_session_destroy(Session* sess); +CK_RV ckcapi_session_register(Session* sess); +CK_RV ckcapi_session_find_lock_ref(CK_ULONG id, int remove, Session **sess); +void ckcapi_session_unref_unlock(Session* sess); +void ckcapi_session_close_all(); + + +/* ------------------------------------------------------------------ + * cryptoki-capi-object.c + */ + +typedef struct _Object +{ + CK_ULONG id; /* Unique ID for this object */ + + CK_ATTRIBUTE_PTR attrs; /* All the attributes of this object */ + CK_ULONG n_attrs; /* Number of attributes */ +} +Object; + +/* +Object* ckcapi_object_create(Session* sess, CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs); +void ckcapi_object_destroy(Session* sess, Object* obj); +*/ + +CK_RV ckcapi_object_find_init (Session* sess, CK_ATTRIBUTE_PTR templ, CK_ULONG count); +CK_RV ckcapi_object_find (Session* sess, CK_OBJECT_HANDLE_PTR objects, + CK_ULONG max_object_count, CK_ULONG_PTR object_count); +CK_RV ckcapi_objects_find_final (Session* sess); + + +#endif /* CRYPTOKI_CAPI_H */ + |