summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-12-09 20:09:51 +0000
committerStef Walter <stef@memberwebs.com>2008-12-09 20:09:51 +0000
commitd108e2008ec7205ef3907296fd3e5a810e45919b (patch)
treed4206f5c4187221523a0a47c255f5df00cf6596e
parent2ef411d0fb1923bf75c3c631992cdef787d0c619 (diff)
First shot at renaming the project.
-rw-r--r--ckcapi-cert.h55
-rw-r--r--ckcapi-rsa.h44
-rw-r--r--ckcapi-session.h150
-rw-r--r--ckcapi-token.h60
-rw-r--r--ckcapi-util.h93
-rw-r--r--p11-capi-builtin.c (renamed from ckcapi-builtin.c)46
-rw-r--r--p11-capi-builtin.h (renamed from ckcapi-builtin.h)14
-rw-r--r--p11-capi-cert.c (renamed from ckcapi-cert.c)160
-rw-r--r--p11-capi-cert.h37
-rw-r--r--p11-capi-der.c (renamed from ckcapi-der.c)14
-rw-r--r--p11-capi-der.h (renamed from ckcapi-der.h)22
-rw-r--r--p11-capi-key.c (renamed from ckcapi-key.c)162
-rw-r--r--p11-capi-key.h (renamed from ckcapi-key.h)18
-rw-r--r--p11-capi-object.c (renamed from ckcapi-object.c)14
-rw-r--r--p11-capi-object.h (renamed from ckcapi-object.h)68
-rw-r--r--p11-capi-rsa.c (renamed from ckcapi-rsa.c)74
-rw-r--r--p11-capi-rsa.h44
-rw-r--r--p11-capi-session.c (renamed from ckcapi-session.c)279
-rw-r--r--p11-capi-session.h169
-rw-r--r--p11-capi-token.c (renamed from ckcapi-token.c)150
-rw-r--r--p11-capi-token.h60
-rw-r--r--p11-capi-trust.c (renamed from ckcapi-trust.c)110
-rw-r--r--p11-capi-trust.h (renamed from ckcapi-trust.h)14
-rw-r--r--p11-capi-util.c (renamed from ckcapi-util.c)76
-rw-r--r--p11-capi-util.h92
-rw-r--r--p11-capi.c (renamed from ckcapi.c)470
-rw-r--r--p11-capi.dep (renamed from ckcapi.dep)42
-rw-r--r--p11-capi.h (renamed from ckcapi.h)71
-rw-r--r--p11-capi.vcproj (renamed from ckcapi.vcproj)70
29 files changed, 1339 insertions, 1339 deletions
diff --git a/ckcapi-cert.h b/ckcapi-cert.h
deleted file mode 100644
index 28edd9d..0000000
--- a/ckcapi-cert.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007 Stef Walter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef CKCAPI_CERT_H
-#define CKCAPI_CERT_H
-
-/* --------------------------------------------------------------------
- *
- * Session = CkCapiSession
- * - A PKCS#11 Session
- *
- * Objects = CkCapiObject
- * - There's a global list of objects in ckcapi-object.c indexed by
- * object handle.
- * - The object itself has no attributes or cached data, but knows how
- * to load data when needed.
- * - Each object has a unique key which guarantees we don't load the
- * same object twice with two different object handles.
- *
- * Object Data = CkCapiObjectData
- * - Object Data is owned by the Session
- * - Loaded data and/or attributes for an object.
- */
-
-#include "ckcapi.h"
-#include "ckcapi-util.h"
-
-/* Find certificates matching criteria */
-CK_RV ckcapi_cert_find (CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count,
- CkCapiArray* arr);
-
-/* Called by trust and key stuff */
-CK_RV ckcapi_cert_certificate_get_bytes (PCCERT_CONTEXT cert,
- CK_ATTRIBUTE_PTR attr);
-
-PCCERT_CONTEXT ckcapi_cert_object_data_get_certificate (CkCapiObjectData* objdata);
-
-#endif /* CRYPTOKI_CERT_H */
diff --git a/ckcapi-rsa.h b/ckcapi-rsa.h
deleted file mode 100644
index d410cc1..0000000
--- a/ckcapi-rsa.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Stef Walter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef CKCAPI_RSA_H
-#define CKCAPI_RSA_H
-
-#include "ckcapi.h"
-
-CK_RV ckcapi_rsa_pkcs_sign_init (CkCapiObjectData* keydata, void** operation);
-
-CK_RV ckcapi_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG data_len,
- CK_BYTE_PTR signature, CK_ULONG_PTR signature_len,
- void** operation);
-
-void ckcapi_rsa_pkcs_sign_cleanup (void* operation);
-
-CK_RV ckcapi_rsa_pkcs_decrypt_init (CkCapiObjectData* keydata, void** operation);
-
-CK_RV ckcapi_rsa_pkcs_decrypt_perform (CK_BYTE_PTR encdata, CK_ULONG n_encdata,
- CK_BYTE_PTR result, CK_ULONG_PTR n_result,
- void** operation);
-
-void ckcapi_rsa_pkcs_decrypt_cleanup (void* operation);
-
-void ckcapi_rsa_pkcs_get_info (CK_MECHANISM_TYPE mech,
- CK_MECHANISM_INFO_PTR info);
-
-#endif /* CKCAPI_RSA_H */
diff --git a/ckcapi-session.h b/ckcapi-session.h
deleted file mode 100644
index f486277..0000000
--- a/ckcapi-session.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2007 Stef Walter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef CKCAPI_SESSION_H
-#define CKCAPI_SESSION_H
-
-#include "ckcapi.h"
-
-/* Callback to cleanup a current operation */
-typedef void (*CkCapiSessionCancel) (struct _CkCapiSession* sess);
-
-/* Represents an open session */
-typedef struct _CkCapiSession
-{
- CK_SESSION_HANDLE id; /* Unique ID for this session */
- CK_SLOT_ID slot;
- int in_call; /* Whether this session is use in PKCS#11 function */
-
- HCERTSTORE store; /* Handle to an open certificate store */
-
- BOOL read_write; /* A read-write session? */
-
- int operation_type; /* Whether an operation is happening or not */
- void* operation_data; /* Data for this operation */
- CkCapiSessionCancel operation_cancel; /* Callback to cancel operation when necessary */
-
- CkCapiHash* object_data;
-
- 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 */
-}
-CkCapiSession;
-
-/* Debug print something related to a session */
-#define DBGS(sess, msg) \
- ckcapi_debug("S%d: %s", (sess) ? (sess)->id : 0, (msg))
-
-/* Create a session */
-CK_RV ckcapi_session_create (CK_SLOT_ID slot, CkCapiSession** ret);
-
-/* Destroy a session */
-void ckcapi_session_destroy (CkCapiSession* sess);
-
-/* Register a new session */
-CK_RV ckcapi_session_register (CkCapiSession* sess);
-
-/* Get information about a session */
-void ckcapi_session_get_info (CkCapiSession* sess,
- CK_SESSION_INFO_PTR info);
-
-/* Get a session from a handle, and lock it */
-CK_RV ckcapi_session_get_lock_ref (CK_ULONG id, BOOL writable,
- CkCapiSession **sess);
-
-/* Get a session from a handle, remove it from list, and lock it */
-CK_RV ckcapi_session_remove_lock_ref (CK_ULONG id, CkCapiSession **sess);
-
-/* Unlock and unreference a session */
-void ckcapi_session_unref_unlock (CkCapiSession* sess);
-
-/* Close all sessions on a certain slot/token */
-CK_RV ckcapi_session_close_all (CK_SLOT_ID slot);
-
-
-
-/* Start a find operation on a session */
-CK_RV ckcapi_session_find_init (CkCapiSession* sess,
- CK_ATTRIBUTE_PTR templ,
- CK_ULONG count);
-
-/* Return results from a find operation */
-CK_RV ckcapi_session_find (CkCapiSession* sess,
- CK_OBJECT_HANDLE_PTR objects,
- CK_ULONG max_object_count,
- CK_ULONG_PTR object_count);
-
-/* End a find operation */
-CK_RV ckcapi_session_find_final (CkCapiSession* sess);
-
-
-/* Start a sign operation on a session */
-CK_RV ckcapi_session_sign_init (CkCapiSession* sess,
- CK_MECHANISM_PTR mech,
- CkCapiObjectData *objdata);
-
-/* Perform sign operation */
-CK_RV ckcapi_session_sign (CkCapiSession* sess,
- CK_BYTE_PTR data, CK_ULONG n_data,
- CK_BYTE_PTR sig, CK_ULONG_PTR n_sig);
-
-/* Start a decrypt operation on a session */
-CK_RV ckcapi_session_decrypt_init (CkCapiSession* sess,
- CK_MECHANISM_PTR mech,
- CkCapiObjectData *objdata);
-
-/* Perform decrypt operation */
-CK_RV ckcapi_session_decrypt (CkCapiSession* sess,
- CK_BYTE_PTR encdata, CK_ULONG n_encdata,
- CK_BYTE_PTR result, CK_ULONG_PTR n_result);
-
-/* Get object data for an object */
-CK_RV ckcapi_session_get_object_data (CkCapiSession* sess,
- CkCapiObject* obj,
- CkCapiObjectData** objdata);
-
-/* Get object data for an object handle */
-CK_RV ckcapi_session_get_object_data_for (CkCapiSession* sess,
- CK_OBJECT_HANDLE hand,
- CkCapiObjectData** objdata);
-
-/* Set object data for an object */
-void ckcapi_session_take_object_data (CkCapiSession* sess,
- CkCapiObject* obj,
- CkCapiObjectData* objdata);
-
-/* Clear object data for an object */
-void ckcapi_session_clear_object_data (CkCapiSession* sess,
- CkCapiObject* obj);
-
-/* Enumerate object data for all objects */
-typedef void (*CkCapiEnumObjectData) (CkCapiSession* sess,
- CkCapiObject* obj,
- CkCapiObjectData* data,
- void* arg);
-void ckcapi_session_enum_object_data (CkCapiSession* sess,
- CkCapiEnumObjectData enum_func,
- void* arg);
-
-void ckcapi_session_cleanup_all (void);
-
-#endif /* CKCAPI_SESSION_H */
diff --git a/ckcapi-token.h b/ckcapi-token.h
deleted file mode 100644
index 1176701..0000000
--- a/ckcapi-token.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2007 Stef Walter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef CKCAPI_TOKEN_H
-#define CKCAPI_TOKEN_H
-
-#include "ckcapi.h"
-
-#define CKCAPI_SLOT_CERTS 0x00000001
-#define CKCAPI_SLOT_ANYKEY 0x00000002
-#define CKCAPI_SLOT_CA 0x00000100
-#define CKCAPI_SLOT_TRUSTED 0x00000200
-
-/* Register a new object, a handle will be assigned to obj->id */
-CK_RV ckcapi_token_register_object (CK_SLOT_ID slot, CkCapiObject* obj);
-
-/* Lookup an object for a given object handle */
-CkCapiObject* ckcapi_token_lookup_object (CK_SLOT_ID slot, CK_OBJECT_HANDLE obj);
-
-/* Clear all objects for all tokens. Only done when finalizing */
-void ckcapi_token_cleanup_all (void);
-
-/* Get the number of the maximum object handle currently in memory */
-CK_OBJECT_HANDLE ckcapi_token_get_max_handle (void);
-
-unsigned int ckcapi_token_get_count (void);
-
-CK_SLOT_ID ckcapi_token_get_slot_id (unsigned int index);
-
-CK_BBOOL ckcapi_token_is_valid (CK_SLOT_ID slot);
-
-const char* ckcapi_token_get_display_name (CK_SLOT_ID slot);
-
-const char* ckcapi_token_get_store_name (CK_SLOT_ID slot);
-
-CK_ULONG ckcapi_token_get_flags (CK_SLOT_ID slot);
-
-CK_RV ckcapi_token_login (CK_SLOT_ID slot);
-
-CK_RV ckcapi_token_logout (CK_SLOT_ID slot);
-
-CK_BBOOL ckcapi_token_is_logged_in (CK_SLOT_ID slot);
-
-#endif /* CKCAPI_TOKEN_H */
diff --git a/ckcapi-util.h b/ckcapi-util.h
deleted file mode 100644
index 59e660c..0000000
--- a/ckcapi-util.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2007 Stef Walter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __CKCAPI_UTIL_H__
-#define __CKCAPI_UTIL_H__
-
-#include <stdlib.h>
-
-
-void ckcapi_reverse_memory (void* data, size_t length);
-
-/* --------------------------------------------------------------------------------
- * ARRAYS
- */
-
-typedef struct _Array
-{
- void* data;
- size_t len;
-}
-CkCapiArray;
-
-#define ckcapi_array_append(a,v) ckcapi_array_append_vals(a, &(v), 1)
-#define ckcapi_array_index(a,t,i) (((t*) (a)->data) [(i)])
-
-CkCapiArray* ckcapi_array_new (int zero_terminated, int zero,
- size_t element_size);
-
-CkCapiArray* ckcapi_array_sized_new (int zero_terminated, int zero,
- size_t element_size, size_t reserved_size);
-
-void* ckcapi_array_free (CkCapiArray* array, int free_segment);
-
-int ckcapi_array_append_vals (CkCapiArray* array, const void* data,
- size_t num);
-
-void ckcapi_array_remove_index (CkCapiArray* array, unsigned int index);
-
-void ckcapi_array_remove_range (CkCapiArray* array, unsigned int index,
- size_t count);
-
-
-/* --------------------------------------------------------------------------------
- * HASHTABLE
- */
-
-struct _CkCapiHash;
-typedef struct _CkCapiHash CkCapiHash;
-
-typedef unsigned int (*CkCapiHashFunc)(const void* key);
-
-typedef int (*CkCapiHashEqual)(const void* a, const void* b);
-
-typedef void (*CkCapiHashDestroy)(void* val);
-
-CkCapiHash* ckcapi_hash_new (CkCapiHashFunc hash_func, CkCapiHashEqual equal_func);
-
-void ckcapi_hash_free (CkCapiHash* ht, CkCapiHashDestroy destroy_func);
-
-size_t ckcapi_hash_count (CkCapiHash* ht);
-
-void* ckcapi_hash_get (CkCapiHash* ht, const void* key);
-
-int ckcapi_hash_set (CkCapiHash* ht, const void* key, void* val);
-
-void* ckcapi_hash_rem (CkCapiHash* ht, const void* key);
-
-unsigned int ckcapi_hash_pointer (const void* ptr);
-
-unsigned int ckcapi_hash_data (const void* data, size_t n_data);
-
-unsigned int ckcapi_hash_integer (int integer);
-
-#define ckcapi_hash_key(num) \
- (((char*)NULL) + (size_t)(num))
-
-#endif /* __CKCAPI_UTIL_H__ */ \ No newline at end of file
diff --git a/ckcapi-builtin.c b/p11-capi-builtin.c
index 7d92f81..2757cb3 100644
--- a/ckcapi-builtin.c
+++ b/p11-capi-builtin.c
@@ -17,10 +17,10 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
-#include "ckcapi-object.h"
-#include "ckcapi-session.h"
-#include "ckcapi-token.h"
+#include "p11-capi.h"
+#include "p11-capi-object.h"
+#include "p11-capi-session.h"
+#include "p11-capi-token.h"
#include "pkcs11/pkcs11n.h"
@@ -58,7 +58,7 @@ typedef struct _BuiltinMatch
BuiltinMatch;
static const BuiltinMatch all_builtins[] = {
- { (CK_ATTRIBUTE_PTR)&builtin_root, CKCAPI_SLOT_TRUSTED | CKCAPI_SLOT_CA | CKCAPI_SLOT_CERTS },
+ { (CK_ATTRIBUTE_PTR)&builtin_root, P11c_SLOT_TRUSTED | P11c_SLOT_CA | P11c_SLOT_CERTS },
{ NULL, 0 }
};
@@ -72,20 +72,20 @@ static CK_ULONG num_builtins = 0;
/* Represents a loaded builtin object */
typedef struct _BuiltinObject
{
- CkCapiObject obj;
+ P11cObject obj;
CK_ATTRIBUTE_PTR attr;
}
BuiltinObject;
typedef struct _BuiltinObjectData
{
- CkCapiObjectData base;
+ P11cObjectData base;
CK_ATTRIBUTE_PTR attr;
}
BuiltinObjectData;
static CK_RV
-builtin_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+builtin_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
BuiltinObjectData* bdata = (BuiltinObjectData*)objdata;
CK_ATTRIBUTE_PTR builtin = bdata->attr;
@@ -99,7 +99,7 @@ builtin_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
if(builtin->ulValueLen == 0)
return CKR_ATTRIBUTE_TYPE_INVALID;
- return ckcapi_return_data(attr, builtin->pValue, builtin->ulValueLen);
+ return p11c_return_data(attr, builtin->pValue, builtin->ulValueLen);
}
builtin++;
@@ -116,7 +116,7 @@ builtin_data_release(void* data)
free(bdata);
}
-static const CkCapiObjectDataVtable builtin_objdata_vtable = {
+static const P11cObjectDataVtable builtin_objdata_vtable = {
builtin_attribute,
builtin_attribute,
builtin_attribute,
@@ -124,7 +124,7 @@ static const CkCapiObjectDataVtable builtin_objdata_vtable = {
};
static CK_RV
-builtin_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdata)
+builtin_load_data(P11cSession* sess, P11cObject* obj, P11cObjectData** objdata)
{
BuiltinObject* bobj = (BuiltinObject*)obj;
BuiltinObjectData* bdata;
@@ -148,13 +148,13 @@ builtin_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** obj
}
static unsigned int
-builtin_hash_func(CkCapiObject* obj)
+builtin_hash_func(P11cObject* obj)
{
- return ckcapi_hash_pointer(((BuiltinObject*)obj)->attr);
+ return p11c_hash_pointer(((BuiltinObject*)obj)->attr);
}
static int
-builtin_equal_func(CkCapiObject* one, CkCapiObject* two)
+builtin_equal_func(P11cObject* one, P11cObject* two)
{
return ((BuiltinObject*)one)->attr == ((BuiltinObject*)two)->attr;
}
@@ -167,7 +167,7 @@ builtin_object_release(void* data)
free(bobj);
}
-static const CkCapiObjectVtable builtin_object_vtable = {
+static const P11cObjectVtable builtin_object_vtable = {
builtin_load_data,
builtin_hash_func,
builtin_equal_func,
@@ -175,7 +175,7 @@ static const CkCapiObjectVtable builtin_object_vtable = {
};
static CK_RV
-register_builtin_object(CkCapiSession* sess, CK_ATTRIBUTE_PTR attr, CkCapiObject** obj)
+register_builtin_object(P11cSession* sess, CK_ATTRIBUTE_PTR attr, P11cObject** obj)
{
BuiltinObject* bobj;
CK_RV ret;
@@ -189,7 +189,7 @@ register_builtin_object(CkCapiSession* sess, CK_ATTRIBUTE_PTR attr, CkCapiObject
bobj->obj.id = 0;
bobj->obj.obj_funcs = &builtin_object_vtable;
- ret = ckcapi_token_register_object(sess->slot, &(bobj->obj));
+ ret = p11c_token_register_object(sess->slot, &(bobj->obj));
if(ret != CKR_OK)
{
free(bobj);
@@ -202,10 +202,10 @@ register_builtin_object(CkCapiSession* sess, CK_ATTRIBUTE_PTR attr, CkCapiObject
}
CK_RV
-ckcapi_builtin_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR match,
- CK_ULONG count, CkCapiArray* arr)
+p11c_builtin_find(P11cSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR match,
+ CK_ULONG count, P11cArray* arr)
{
- CkCapiObject* obj;
+ P11cObject* obj;
BuiltinObjectData bdata;
CK_RV ret = CKR_OK;
CK_ULONG i, fl;
@@ -222,7 +222,7 @@ ckcapi_builtin_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR m
for(i = 0; i < num_builtins; ++i)
{
/* Only apply built in objects to appropriate slots */
- fl = ckcapi_token_get_flags(sess->slot) & all_builtins[i].slot_flags;
+ fl = p11c_token_get_flags(sess->slot) & all_builtins[i].slot_flags;
if(fl != all_builtins[i].slot_flags)
continue;
@@ -230,13 +230,13 @@ ckcapi_builtin_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR m
bdata.base.object = 0;
bdata.base.data_funcs = &builtin_objdata_vtable;
- if(ckcapi_object_data_match(&bdata.base, match, count))
+ if(p11c_object_data_match(&bdata.base, match, count))
{
ret = register_builtin_object(sess, all_builtins[i].attr, &obj);
if(ret != CKR_OK)
break;
- ckcapi_array_append(arr, obj->id);
+ p11c_array_append(arr, obj->id);
}
}
diff --git a/ckcapi-builtin.h b/p11-capi-builtin.h
index b7a043c..b398509 100644
--- a/ckcapi-builtin.h
+++ b/p11-capi-builtin.h
@@ -17,14 +17,14 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef CKCAPI_BUILTIN_H
-#define CKCAPI_BUILTIN_H
+#ifndef P11C_BUILTIN_H
+#define P11C_BUILTIN_H
-#include "ckcapi.h"
+#include "p11-capi.h"
/* Find builtin objects matching criteria */
-CK_RV ckcapi_builtin_find (CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count,
- CkCapiArray* arr);
+CK_RV p11c_builtin_find (P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count,
+ P11cArray* arr);
-#endif /* CRYPTOKI_BUILTIN_H */
+#endif /* P11C_BUILTIN_H */
diff --git a/ckcapi-cert.c b/p11-capi-cert.c
index 5225286..960073a 100644
--- a/ckcapi-cert.c
+++ b/p11-capi-cert.c
@@ -17,11 +17,11 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
-#include "ckcapi-cert.h"
-#include "ckcapi-object.h"
-#include "ckcapi-session.h"
-#include "ckcapi-token.h"
+#include "p11-capi.h"
+#include "p11-capi-cert.h"
+#include "p11-capi-object.h"
+#include "p11-capi-session.h"
+#include "p11-capi-token.h"
#include <memory.h>
@@ -35,7 +35,7 @@
typedef struct _CertObject
{
- CkCapiObject obj;
+ P11cObject obj;
/* Together these can uniquely identify a certificate */
CRYPT_INTEGER_BLOB serial;
@@ -45,7 +45,7 @@ CertObject;
typedef struct _CertObjectData
{
- CkCapiObjectData base;
+ P11cObjectData base;
PCCERT_CONTEXT cert;
BOOL is_in_root;
}
@@ -66,17 +66,17 @@ parse_basic_constraints(CertObjectData* cdata, CK_ULONG* category)
*category = 0;
ext = CertFindExtension(szOID_BASIC_CONSTRAINTS,
- cdata->cert->pCertInfo->cExtension,
- cdata->cert->pCertInfo->rgExtension);
+ cdata->cert->pCertInfo->cExtension,
+ cdata->cert->pCertInfo->rgExtension);
/* No key usage, don't care */
if(!ext)
return CKR_OK;
/* Find the size of the decoded structure */
- if(!CryptDecodeObject(CKCAPI_ENCODINGS, X509_BASIC_CONSTRAINTS,
- ext->Value.pbData, ext->Value.cbData, 0, NULL, &size))
- return ckcapi_winerr_to_ckr(GetLastError());
+ if(!CryptDecodeObject(P11c_ENCODINGS, X509_BASIC_CONSTRAINTS,
+ ext->Value.pbData, ext->Value.cbData, 0, NULL, &size))
+ return p11c_winerr_to_ckr(GetLastError());
/* Allocate enough memory */
basic = (CERT_BASIC_CONSTRAINTS_INFO*)calloc(1, size);
@@ -84,8 +84,8 @@ parse_basic_constraints(CertObjectData* cdata, CK_ULONG* category)
return CKR_HOST_MEMORY;
/* And get the decoded structure */
- if(CryptDecodeObject(CKCAPI_ENCODINGS, X509_BASIC_CONSTRAINTS,
- ext->Value.pbData, ext->Value.cbData, 0, basic, &size))
+ if(CryptDecodeObject(P11c_ENCODINGS, X509_BASIC_CONSTRAINTS,
+ ext->Value.pbData, ext->Value.cbData, 0, basic, &size))
{
if(basic->SubjectType.cbData != 1)
{
@@ -107,7 +107,7 @@ parse_basic_constraints(CertObjectData* cdata, CK_ULONG* category)
}
else
{
- ret = ckcapi_winerr_to_ckr(GetLastError());
+ ret = p11c_winerr_to_ckr(GetLastError());
}
free(basic);
@@ -117,7 +117,7 @@ parse_basic_constraints(CertObjectData* cdata, CK_ULONG* category)
static CK_RV
-cert_bool_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+cert_bool_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
CertObjectData* cdata = (CertObjectData*)objdata;
CK_BBOOL val;
@@ -164,11 +164,11 @@ cert_bool_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
return CKR_ATTRIBUTE_TYPE_INVALID;
};
- return ckcapi_return_data(attr, &val, sizeof(CK_BBOOL));
+ return p11c_return_data(attr, &val, sizeof(CK_BBOOL));
}
static CK_RV
-cert_ulong_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+cert_ulong_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
CertObjectData* cdata = (CertObjectData*)objdata;
CK_ULONG val;
@@ -218,11 +218,11 @@ cert_ulong_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
return CKR_ATTRIBUTE_TYPE_INVALID;
};
- return ckcapi_return_data(attr, &val, sizeof(CK_ULONG));
+ return p11c_return_data(attr, &val, sizeof(CK_ULONG));
}
static CK_RV
-cert_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+cert_bytes_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
CertObjectData* cdata = (CertObjectData*)objdata;
PCCERT_CONTEXT cert = cdata->cert;
@@ -230,7 +230,7 @@ cert_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
ASSERT(sizeof(CK_ULONG) == sizeof(DWORD));
ASSERT(cdata);
- return ckcapi_cert_certificate_get_bytes(cdata->cert, attr);
+ return p11c_cert_certificate_get_bytes(cdata->cert, attr);
}
static void
@@ -242,15 +242,15 @@ cert_data_release(void* data)
free(cdata);
}
-static const CkCapiObjectDataVtable cert_objdata_vtable = {
+static const P11cObjectDataVtable cert_objdata_vtable = {
cert_bool_attribute,
cert_ulong_attribute,
cert_bytes_attribute,
cert_data_release,
};
-static CkCapiObjectData*
-cert_alloc_data(CkCapiSession* sess, CkCapiObject* obj, PCCERT_CONTEXT cert)
+static P11cObjectData*
+cert_alloc_data(P11cSession* sess, P11cObject* obj, PCCERT_CONTEXT cert)
{
CertObjectData* cdata;
@@ -259,7 +259,7 @@ cert_alloc_data(CkCapiSession* sess, CkCapiObject* obj, PCCERT_CONTEXT cert)
return NULL;
cdata->cert = cert;
- cdata->is_in_root = (ckcapi_token_get_flags(sess->slot) & CKCAPI_SLOT_CA) ? TRUE : FALSE;
+ cdata->is_in_root = (p11c_token_get_flags(sess->slot) & P11c_SLOT_CA) ? TRUE : FALSE;
cdata->base.object = obj->id;
cdata->base.data_funcs = &cert_objdata_vtable;
@@ -268,7 +268,7 @@ cert_alloc_data(CkCapiSession* sess, CkCapiObject* obj, PCCERT_CONTEXT cert)
}
static CK_RV
-cert_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdata)
+cert_load_data(P11cSession* sess, P11cObject* obj, P11cObjectData** objdata)
{
CertObject* cobj = (CertObject*)obj;
CERT_INFO info;
@@ -290,7 +290,7 @@ cert_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdat
memcpy(&info.SerialNumber, &cobj->serial, sizeof(info.SerialNumber));
memcpy(&info.Issuer, &cobj->issuer, sizeof(info.Issuer));
- cert = CertGetSubjectCertificateFromStore(sess->store, CKCAPI_ENCODINGS, &info);
+ cert = CertGetSubjectCertificateFromStore(sess->store, P11c_ENCODINGS, &info);
if(!cert)
{
@@ -301,7 +301,7 @@ cert_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdat
if(err == CRYPT_E_NOT_FOUND)
return CKR_OBJECT_HANDLE_INVALID;
else
- return ckcapi_winerr_to_ckr(GetLastError());
+ return p11c_winerr_to_ckr(GetLastError());
}
*objdata = cert_alloc_data(sess, obj, cert);
@@ -315,15 +315,15 @@ cert_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdat
}
static unsigned int
-cert_hash_func(CkCapiObject* obj)
+cert_hash_func(P11cObject* obj)
{
CertObject* cobj = (CertObject*)obj;
- return ckcapi_hash_data(cobj->issuer.pbData, cobj->issuer.cbData) ^
- ckcapi_hash_data(cobj->serial.pbData, cobj->serial.cbData);
+ return p11c_hash_data(cobj->issuer.pbData, cobj->issuer.cbData) ^
+ p11c_hash_data(cobj->serial.pbData, cobj->serial.cbData);
}
static int
-cert_equal_func(CkCapiObject* a, CkCapiObject* b)
+cert_equal_func(P11cObject* a, P11cObject* b)
{
CertObject* ca = (CertObject*)a;
CertObject* cb = (CertObject*)b;
@@ -341,7 +341,7 @@ cert_object_release(void* data)
free(cobj);
}
-static const CkCapiObjectVtable cert_object_vtable = {
+static const P11cObjectVtable cert_object_vtable = {
cert_load_data,
cert_hash_func,
cert_equal_func,
@@ -367,8 +367,8 @@ calculate_check_value(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
length = 0;
if(!CryptHashCertificate(0, CALG_SHA1, 0, cert->pbCertEncoded,
- cert->cbCertEncoded, NULL, &length))
- return ckcapi_winerr_to_ckr(GetLastError());
+ cert->cbCertEncoded, NULL, &length))
+ return p11c_winerr_to_ckr(GetLastError());
if(length < 3)
{
@@ -381,20 +381,20 @@ calculate_check_value(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
return CKR_HOST_MEMORY;
if(!CryptHashCertificate(0, CALG_SHA1, 0, cert->pbCertEncoded,
- cert->cbCertEncoded, buffer, &length))
+ cert->cbCertEncoded, buffer, &length))
{
free(buffer);
- return ckcapi_winerr_to_ckr(GetLastError());
+ return p11c_winerr_to_ckr(GetLastError());
}
- ret = ckcapi_return_data(attr, buffer, 3);
+ ret = p11c_return_data(attr, buffer, 3);
free(buffer);
return ret;
}
CK_RV
-ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
+p11c_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
{
DWORD err;
@@ -422,17 +422,17 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
if(err == CRYPT_E_NOT_FOUND)
utf16 = L"Unnamed Certificate";
else
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
if(!utf16)
{
utf16 = _alloca(size);
if(!CertGetCertificateContextProperty(cert, CERT_FRIENDLY_NAME_PROP_ID, utf16, &size))
- return ckcapi_winerr_to_ckr(GetLastError());
+ return p11c_winerr_to_ckr(GetLastError());
}
- return ckcapi_return_string(attr, utf16);
+ return p11c_return_string(attr, utf16);
}
break;
@@ -450,7 +450,7 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
err = GetLastError();
if(err == CRYPT_E_NOT_FOUND)
return CKR_ATTRIBUTE_TYPE_INVALID;
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
return CKR_OK;
@@ -462,8 +462,8 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
* directly.
*/
case CKA_SUBJECT:
- return ckcapi_return_data(attr, cert->pCertInfo->Subject.pbData,
- cert->pCertInfo->Subject.cbData);
+ return p11c_return_data(attr, cert->pCertInfo->Subject.pbData,
+ cert->pCertInfo->Subject.cbData);
/*
* DER-encoding of the certificate issuer name.
@@ -472,21 +472,21 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
* directly.
*/
case CKA_ISSUER:
- return ckcapi_return_data(attr, cert->pCertInfo->Issuer.pbData,
- cert->pCertInfo->Issuer.cbData);
+ return p11c_return_data(attr, cert->pCertInfo->Issuer.pbData,
+ cert->pCertInfo->Issuer.cbData);
/*
* DER-encoding of the certificate serial number.
*/
case CKA_SERIAL_NUMBER:
if(!CryptEncodeObject(X509_ASN_ENCODING, X509_MULTI_BYTE_INTEGER,
- &cert->pCertInfo->SerialNumber,
+ &cert->pCertInfo->SerialNumber,
attr->pValue, (DWORD*)&attr->ulValueLen))
{
err = GetLastError();
if(err == ERROR_FILE_NOT_FOUND)
return CKR_GENERAL_ERROR;
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
return CKR_OK;
@@ -496,8 +496,8 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
* We use CAPI's CERT_CONTEXT pbCertEncoded field directly.
*/
case CKA_VALUE:
- return ckcapi_return_data(attr, cert->pbCertEncoded,
- cert->cbCertEncoded);
+ return p11c_return_data(attr, cert->pbCertEncoded,
+ cert->cbCertEncoded);
/*
* If CKA_VALUE not specified, this is where the full
@@ -509,7 +509,7 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
* - Spec says default to empty.
*/
case CKA_URL:
- return ckcapi_return_data(attr, "", 0);
+ return p11c_return_data(attr, "", 0);
/*
* Checksum
@@ -524,19 +524,19 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
*/
case CKA_HASH_OF_SUBJECT_PUBLIC_KEY:
case CKA_HASH_OF_ISSUER_PUBLIC_KEY:
- return ckcapi_return_data(attr, "", 0);
+ return p11c_return_data(attr, "", 0);
/*
* Start date for the certificate.
*/
case CKA_START_DATE:
- return ckcapi_return_filetime(attr, &cert->pCertInfo->NotBefore);
+ return p11c_return_filetime(attr, &cert->pCertInfo->NotBefore);
/*
* End date for the certificate.
*/
case CKA_END_DATE:
- return ckcapi_return_filetime(attr, &cert->pCertInfo->NotAfter);
+ return p11c_return_filetime(attr, &cert->pCertInfo->NotAfter);
default:
return CKR_ATTRIBUTE_TYPE_INVALID;
@@ -544,7 +544,7 @@ ckcapi_cert_certificate_get_bytes(PCCERT_CONTEXT cert, CK_ATTRIBUTE_PTR attr)
}
PCCERT_CONTEXT
-ckcapi_cert_object_data_get_certificate(CkCapiObjectData* objdata)
+p11c_cert_object_data_get_certificate(P11cObjectData* objdata)
{
CertObjectData* cdata;
@@ -556,7 +556,7 @@ ckcapi_cert_object_data_get_certificate(CkCapiObjectData* objdata)
}
static CK_RV
-register_cert_object(CkCapiSession* sess, PCCERT_CONTEXT cert, CkCapiObject** obj)
+register_cert_object(P11cSession* sess, PCCERT_CONTEXT cert, P11cObject** obj)
{
CertObject* cobj;
CK_RV ret;
@@ -577,15 +577,15 @@ register_cert_object(CkCapiSession* sess, PCCERT_CONTEXT cert, CkCapiObject** ob
cobj->issuer.cbData = cert->pCertInfo->Issuer.cbData;
cobj->issuer.pbData = (BYTE*)(cobj + 1);
memcpy(cobj->issuer.pbData, cert->pCertInfo->Issuer.pbData,
- cobj->issuer.cbData);
+ cobj->issuer.cbData);
/* Copy Serial Number data in */
cobj->serial.cbData = cert->pCertInfo->SerialNumber.cbData;
cobj->serial.pbData = cobj->issuer.pbData + cobj->issuer.cbData;
memcpy(cobj->serial.pbData, cert->pCertInfo->SerialNumber.pbData,
- cobj->serial.cbData);
+ cobj->serial.cbData);
- ret = ckcapi_token_register_object(sess->slot, &(cobj->obj));
+ ret = p11c_token_register_object(sess->slot, &(cobj->obj));
if(ret != CKR_OK)
{
free(cobj);
@@ -598,12 +598,12 @@ register_cert_object(CkCapiSession* sess, PCCERT_CONTEXT cert, CkCapiObject** ob
}
static CK_RV
-find_in_store(CkCapiSession* sess, DWORD find_type, const void *find_criteria,
- CK_ATTRIBUTE_PTR match, CK_ULONG count, CkCapiArray* arr)
+find_in_store(P11cSession* sess, DWORD find_type, const void *find_criteria,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count, P11cArray* arr)
{
PCCERT_CONTEXT cert = NULL;
- CkCapiObject* obj;
- CkCapiObjectData* objdata;
+ P11cObject* obj;
+ P11cObjectData* objdata;
CertObjectData cdata;
DWORD err;
CK_RV ret = CKR_OK;
@@ -614,7 +614,7 @@ find_in_store(CkCapiSession* sess, DWORD find_type, const void *find_criteria,
for(;;)
{
- cert = CertFindCertificateInStore(sess->store, CKCAPI_ENCODINGS, 0,
+ cert = CertFindCertificateInStore(sess->store, P11c_ENCODINGS, 0,
find_type, find_criteria, cert);
if(cert == NULL)
{
@@ -624,7 +624,7 @@ find_in_store(CkCapiSession* sess, DWORD find_type, const void *find_criteria,
if(err == CRYPT_E_NOT_FOUND)
return CKR_OK;
else
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
/* Match the certificate */
@@ -632,7 +632,7 @@ find_in_store(CkCapiSession* sess, DWORD find_type, const void *find_criteria,
cdata.base.object = 0;
cdata.base.data_funcs = &cert_objdata_vtable;
- if(ckcapi_object_data_match(&cdata.base, match, count))
+ if(p11c_object_data_match(&cdata.base, match, count))
{
ret = register_cert_object(sess, cert, &obj);
if(ret == CKR_OK)
@@ -643,13 +643,13 @@ find_in_store(CkCapiSession* sess, DWORD find_type, const void *find_criteria,
objdata = cert_alloc_data(sess, obj, cert);
if(objdata)
{
- ckcapi_session_take_object_data(sess, obj, objdata);
+ p11c_session_take_object_data(sess, obj, objdata);
/* For continuing the enumeration */
cert = CertDuplicateCertificateContext(cert);
}
- ckcapi_array_append(arr, obj->id);
+ p11c_array_append(arr, obj->id);
}
}
}
@@ -661,8 +661,8 @@ find_in_store(CkCapiSession* sess, DWORD find_type, const void *find_criteria,
}
CK_RV
-ckcapi_cert_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR match,
- CK_ULONG count, CkCapiArray* arr)
+p11c_cert_find(P11cSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR match,
+ CK_ULONG count, P11cArray* arr)
{
CRYPT_INTEGER_BLOB* serial = NULL;
CK_RV ret;
@@ -677,18 +677,18 @@ ckcapi_cert_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR matc
return CKR_OK;
/* Only work with slots that have certificates */
- if(!(ckcapi_token_get_flags (sess->slot) & CKCAPI_SLOT_CERTS))
+ if(!(p11c_token_get_flags (sess->slot) & P11c_SLOT_CERTS))
return CKR_OK;
/*
* There are some better searches we can do rather than
* listing everything.
- *
- * CKA_ISSUER + CKA_SERIAL_NUMBER
+ *
+ * CKA_ISSUER + CKA_SERIAL_NUMBER
* See if we have a issuer and serial number for a
* specific certificate to find.
- *
- * CKA_ID
+ *
+ * CKA_ID
* Search by key identifier
*
* TODO: could search by hash (use CertFindCertificateInStore
@@ -719,8 +719,8 @@ ckcapi_cert_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR matc
else if(match[i].type == CKA_SERIAL_NUMBER && !serial)
{
- if(!CryptDecodeObject(CKCAPI_ENCODINGS, X509_MULTI_BYTE_INTEGER,
- match[i].pValue, match[i].ulValueLen, 0, NULL, &size))
+ if(!CryptDecodeObject(P11c_ENCODINGS, X509_MULTI_BYTE_INTEGER,
+ match[i].pValue, match[i].ulValueLen, 0, NULL, &size))
{
continue;
}
@@ -729,8 +729,8 @@ ckcapi_cert_find(CkCapiSession* sess, CK_OBJECT_CLASS cls, CK_ATTRIBUTE_PTR matc
if(!serial)
continue;
- if(!CryptDecodeObject(CKCAPI_ENCODINGS, X509_MULTI_BYTE_INTEGER,
- match[i].pValue, match[i].ulValueLen, 0, serial, &size))
+ if(!CryptDecodeObject(P11c_ENCODINGS, X509_MULTI_BYTE_INTEGER,
+ match[i].pValue, match[i].ulValueLen, 0, serial, &size))
continue;
ASSERT(serial->cbData);
diff --git a/p11-capi-cert.h b/p11-capi-cert.h
new file mode 100644
index 0000000..a19b740
--- /dev/null
+++ b/p11-capi-cert.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007 Stef Walter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef P11C_CERT_H
+#define P11C_CERT_H
+
+#include "p11-capi.h"
+#include "p11-capi-util.h"
+
+/* Find certificates matching criteria */
+CK_R p11c_cert_find (P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count,
+ P11cArray* arr);
+
+/* Called by trust and key stuff */
+CK_RV p11c_cert_certificate_get_bytes (PCCERT_CONTEXT cert,
+ CK_ATTRIBUTE_PTR attr);
+
+PCCERT_CONTEXT p11c_cert_object_data_get_certificate (P11cObjectData* objdata);
+
+#endif /* P11C_CERT_H */
diff --git a/ckcapi-der.c b/p11-capi-der.c
index 602b831..db69b89 100644
--- a/ckcapi-der.c
+++ b/p11-capi-der.c
@@ -46,15 +46,15 @@
*
* ***** END LICENSE BLOCK ***** */
-#include "ckcapi.h"
-#include "ckcapi-der.h"
+#include "p11-capi.h"
+#include "p11-capi-der.h"
/*
* unwrap a single DER value
*/
BYTE*
-ckcapi_der_unwrap(BYTE* src, DWORD n_src,
- DWORD* n_result, BYTE** next)
+p11c_der_unwrap(BYTE* src, DWORD n_src,
+ DWORD* n_result, BYTE** next)
{
BYTE* start = src;
BYTE* end = src + n_src;
@@ -126,7 +126,7 @@ put_decimal_string(char* cstr, DWORD value)
* Create a Capi OID string value from a DER OID
*/
char*
-ckcapi_der_read_oid(BYTE* oid_tag, DWORD n_oid_tag)
+p11c_der_read_oid(BYTE* oid_tag, DWORD n_oid_tag)
{
BYTE* oid;
char *oid_str;
@@ -135,10 +135,10 @@ ckcapi_der_read_oid(BYTE* oid_tag, DWORD n_oid_tag)
DWORD n_oid;
/* wasn't an oid */
- if(CKCAPI_DER_OBJECT_ID != *oid_tag)
+ if(P11c_DER_OBJECT_ID != *oid_tag)
return NULL;
- oid = ckcapi_der_unwrap(oid_tag, n_oid_tag, &n_oid, NULL);;
+ oid = p11c_der_unwrap(oid_tag, n_oid_tag, &n_oid, NULL);;
if(n_oid < 2)
return NULL;
diff --git a/ckcapi-der.h b/p11-capi-der.h
index 9030ce3..0807fcd 100644
--- a/ckcapi-der.h
+++ b/p11-capi-der.h
@@ -17,19 +17,19 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef CKCAPI_DER_H
-#define CKCAPI_DER_H
+#ifndef P11C_DER_H
+#define P11C_DER_H
-#include "ckcapi.h"
+#include "p11-capi.h"
-#define CKCAPI_DER_OCTET_STRING 0x04
-#define CKCAPI_DER_OBJECT_ID 0x06
-#define CKCAPI_DER_SEQUENCE 0x10
-#define CKCAPI_DER_CONSTRUCTED 0x20
+#define P11C_DER_OCTET_STRING 0x04
+#define P11C_DER_OBJECT_ID 0x06
+#define P11C_DER_SEQUENCE 0x10
+#define P11C_DER_CONSTRUCTED 0x20
-BYTE* ckcapi_der_unwrap (BYTE* src, DWORD n_src,
- DWORD* n_result, BYTE** next);
+BYTE* p11c_der_unwrap (BYTE* src, DWORD n_src,
+ DWORD* n_result, BYTE** next);
-char* ckcapi_der_read_oid (BYTE* oid_tag, DWORD n_oid_tag);
+char* p11c_der_read_oid (BYTE* oid_tag, DWORD n_oid_tag);
-#endif /* CRYPTOKI_DER_H */
+#endif /* P11C_DER_H */
diff --git a/ckcapi-key.c b/p11-capi-key.c
index 34a6ae1..bda2baf 100644
--- a/ckcapi-key.c
+++ b/p11-capi-key.c
@@ -17,17 +17,17 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
-#include "ckcapi-cert.h"
-#include "ckcapi-key.h"
-#include "ckcapi-object.h"
-#include "ckcapi-session.h"
-#include "ckcapi-token.h"
+#include "p11-capi.h"
+#include "p11-capi-cert.h"
+#include "p11-capi-key.h"
+#include "p11-capi-object.h"
+#include "p11-capi-session.h"
+#include "p11-capi-token.h"
#include "x509-usages.h"
typedef struct _KeyObject
{
- CkCapiObject obj;
+ P11cObject obj;
/* The raw key identifier */
CRYPT_HASH_BLOB key_identifier;
@@ -37,7 +37,7 @@ KeyObject;
typedef struct _KeyObjectData
{
- CkCapiObjectData base;
+ P11cObjectData base;
CK_OBJECT_CLASS object_class;
CRYPT_INTEGER_BLOB key_identifier;
CRYPT_DATA_BLOB raw_public_key;
@@ -46,8 +46,8 @@ typedef struct _KeyObjectData
KeyObjectData;
static CK_RV
-load_key_handle (CkCapiObjectData* objdata, HCRYPTPROV* ret_prov,
- HCRYPTKEY* ret_key)
+load_key_handle(P11cObjectData* objdata, HCRYPTPROV* ret_prov,
+ HCRYPTKEY* ret_key)
{
KeyObjectData* kdata = (KeyObjectData*)objdata;
HCRYPTPROV prov;
@@ -62,14 +62,14 @@ load_key_handle (CkCapiObjectData* objdata, HCRYPTPROV* ret_prov,
kdata->prov_info->pwszProvName,
kdata->prov_info->dwProvType, 0))
{
- return ckcapi_winerr_to_ckr(GetLastError());
+ return p11c_winerr_to_ckr(GetLastError());
}
if(!CryptGetUserKey(prov, kdata->prov_info->dwKeySpec, &key))
{
error = GetLastError();
CryptReleaseContext(prov, 0);
- return ckcapi_winerr_to_ckr(error);
+ return p11c_winerr_to_ckr(error);
}
*ret_key = key;
@@ -103,7 +103,7 @@ load_raw_public_key(KeyObjectData* kdata)
else
{
if(CryptExportKey(key, 0, PUBLICKEYBLOB, 0, kdata->raw_public_key.pbData,
- &kdata->raw_public_key.cbData))
+ &kdata->raw_public_key.cbData))
{
success = TRUE;
}
@@ -122,7 +122,7 @@ load_raw_public_key(KeyObjectData* kdata)
error = GetLastError();
if(error == NTE_BAD_KEY_STATE)
return CKR_ATTRIBUTE_SENSITIVE;
- return ckcapi_winerr_to_ckr(error);
+ return p11c_winerr_to_ckr(error);
}
}
@@ -156,14 +156,14 @@ lookup_rsa_attribute(KeyObjectData* kdata, CK_ATTRIBUTE_PTR attr)
{
case CKA_MODULUS_BITS:
number = pubkey->bitlen;
- return ckcapi_return_data(attr, &number, sizeof(CK_ULONG));
+ return p11c_return_data(attr, &number, sizeof(CK_ULONG));
case CKA_PUBLIC_EXPONENT:
- return ckcapi_return_dword_as_bytes(attr, pubkey->pubexp);
+ return p11c_return_dword_as_bytes(attr, pubkey->pubexp);
case CKA_MODULUS:
- return ckcapi_return_reversed_data(attr, (pubkey + 1),
- pubkey->bitlen / 8);
+ return p11c_return_reversed_data(attr, (pubkey + 1),
+ pubkey->bitlen / 8);
case CKA_PRIVATE_EXPONENT:
case CKA_PRIME_1:
@@ -183,7 +183,7 @@ lookup_rsa_attribute(KeyObjectData* kdata, CK_ATTRIBUTE_PTR attr)
}
static CK_RV
-key_bool_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+key_bool_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
KeyObjectData* kdata = (KeyObjectData*)objdata;
CK_BBOOL val;
@@ -374,11 +374,11 @@ key_bool_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
return CKR_ATTRIBUTE_TYPE_INVALID;
};
- return ckcapi_return_data(attr, &val, sizeof(CK_BBOOL));
+ return p11c_return_data(attr, &val, sizeof(CK_BBOOL));
}
static CK_RV
-key_ulong_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+key_ulong_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
KeyObjectData* kdata = (KeyObjectData*)objdata;
CK_ULONG val;
@@ -428,11 +428,11 @@ key_ulong_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
return CKR_ATTRIBUTE_TYPE_INVALID;
};
- return ckcapi_return_data(attr, &val, sizeof(CK_ULONG));
+ return p11c_return_data(attr, &val, sizeof(CK_ULONG));
}
static CK_RV
-key_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+key_bytes_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
KeyObjectData* kdata = (KeyObjectData*)objdata;
CK_MECHANISM_TYPE allowed_mechanisms[] = { CKM_RSA_PKCS };
@@ -448,8 +448,8 @@ key_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
* return for any matching certificates.
*/
case CKA_ID:
- return ckcapi_return_data(attr, kdata->key_identifier.pbData,
- kdata->key_identifier.cbData);
+ return p11c_return_data(attr, kdata->key_identifier.pbData,
+ kdata->key_identifier.cbData);
/*
* The key label.
@@ -459,14 +459,14 @@ key_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
label = kdata->prov_info->pwszContainerName;
if(!label)
label = L"Unnamed Key";
- return ckcapi_return_string(attr, label);
+ return p11c_return_string(attr, label);
/*
* The subject of the related certificate.
* TODO: Implement this lookup.
*/
case CKA_SUBJECT:
- return ckcapi_return_data(attr, "", 0);
+ return p11c_return_data(attr, "", 0);
/*
* Allowed mechanisms with this key.
@@ -474,7 +474,7 @@ key_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
* TODO: Needs updating when DSA implemented.
*/
case CKA_ALLOWED_MECHANISMS:
- return ckcapi_return_data(attr, &allowed_mechanisms,
+ return p11c_return_data(attr, &allowed_mechanisms,
sizeof(allowed_mechanisms));
/*
@@ -499,7 +499,7 @@ key_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
*/
case CKA_END_DATE:
case CKA_START_DATE:
- return ckcapi_return_data(attr, "", 0);
+ return p11c_return_data(attr, "", 0);
default:
return CKR_ATTRIBUTE_TYPE_INVALID;
@@ -521,7 +521,7 @@ key_release(void* data)
free(kdata);
}
-static const CkCapiObjectDataVtable key_objdata_vtable = {
+static const P11cObjectDataVtable key_objdata_vtable = {
key_bool_attribute,
key_ulong_attribute,
key_bytes_attribute,
@@ -605,8 +605,8 @@ duplicate_prov_info(CRYPT_KEY_PROV_INFO* original)
return result;
}
-static CkCapiObjectData*
-key_alloc_data(CkCapiSession* sess, CkCapiObject* obj, CRYPT_KEY_PROV_INFO* prov_info)
+static P11cObjectData*
+key_alloc_data(P11cSession* sess, P11cObject* obj, CRYPT_KEY_PROV_INFO* prov_info)
{
KeyObject* kobj = (KeyObject*)obj;
KeyObjectData* kdata;
@@ -640,8 +640,8 @@ key_alloc_data(CkCapiSession* sess, CkCapiObject* obj, CRYPT_KEY_PROV_INFO* prov
static BOOL WINAPI
load_key_property_info(PCRYPT_HASH_BLOB key_identifier, DWORD flags,
- void* reserved, void* arg, DWORD n_props, DWORD* props,
- void** datas, DWORD* n_datas)
+ void* reserved, void* arg, DWORD n_props, DWORD* props,
+ void** datas, DWORD* n_datas)
{
CRYPT_KEY_PROV_INFO** prov_info = (CRYPT_KEY_PROV_INFO**)arg;
DWORD i;
@@ -667,7 +667,7 @@ load_key_property_info(PCRYPT_HASH_BLOB key_identifier, DWORD flags,
}
static CK_RV
-key_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdata)
+key_load_data(P11cSession* sess, P11cObject* obj, P11cObjectData** objdata)
{
KeyObject* kobj = (KeyObject*)obj;
CRYPT_KEY_PROV_INFO* prov_info = NULL;
@@ -678,8 +678,8 @@ key_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdata
/* Load the provider info */
if(!CryptEnumKeyIdentifierProperties((CRYPT_HASH_BLOB*)&kobj->key_identifier,
CERT_KEY_PROV_INFO_PROP_ID, 0, NULL, NULL,
- &prov_info, load_key_property_info))
- return ckcapi_winerr_to_ckr(GetLastError());
+ &prov_info, load_key_property_info))
+ return p11c_winerr_to_ckr(GetLastError());
/* No provider info, bad news */
if(!prov_info)
@@ -696,15 +696,15 @@ key_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdata
}
static unsigned int
-key_hash_func(CkCapiObject* obj)
+key_hash_func(P11cObject* obj)
{
KeyObject* kobj = (KeyObject*)obj;
- return ckcapi_hash_data(kobj->key_identifier.pbData, kobj->key_identifier.cbData) ^
- ckcapi_hash_integer((int)kobj->object_class);
+ return p11c_hash_data(kobj->key_identifier.pbData, kobj->key_identifier.cbData) ^
+ p11c_hash_integer((int)kobj->object_class);
}
static int
-key_equal_func(CkCapiObject* a, CkCapiObject* b)
+key_equal_func(P11cObject* a, P11cObject* b)
{
KeyObject* ka = (KeyObject*)a;
KeyObject* kb = (KeyObject*)b;
@@ -721,7 +721,7 @@ key_object_release(void* data)
free(kobj);
}
-static const CkCapiObjectVtable key_object_vtable = {
+static const P11cObjectVtable key_object_vtable = {
key_load_data,
key_hash_func,
key_equal_func,
@@ -729,8 +729,8 @@ static const CkCapiObjectVtable key_object_vtable = {
};
static CK_RV
-register_key_object(CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CRYPT_HASH_BLOB* key_identifier, CkCapiObject** obj)
+register_key_object(P11cSession* sess, CK_OBJECT_CLASS cls,
+ CRYPT_HASH_BLOB* key_identifier, P11cObject** obj)
{
KeyObject* kobj;
CK_RV ret;
@@ -752,7 +752,7 @@ register_key_object(CkCapiSession* sess, CK_OBJECT_CLASS cls,
memcpy(kobj->key_identifier.pbData, key_identifier->pbData,
kobj->key_identifier.cbData);
- ret = ckcapi_token_register_object(sess->slot, &(kobj->obj));
+ ret = p11c_token_register_object(sess->slot, &(kobj->obj));
if(ret != CKR_OK)
{
free(kobj);
@@ -767,23 +767,23 @@ register_key_object(CkCapiSession* sess, CK_OBJECT_CLASS cls,
typedef struct _EnumArguments
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_OBJECT_CLASS object_class;
CK_ATTRIBUTE_PTR match;
CK_ULONG count;
- CkCapiArray* results;
+ P11cArray* results;
CK_RV ret;
}
EnumArguments;
static BOOL WINAPI
enum_key_property_info(PCRYPT_HASH_BLOB key_identifier, DWORD flags,
- void* reserved, void* arg, DWORD n_props, DWORD* props,
- void** datas, DWORD* n_datas)
+ void* reserved, void* arg, DWORD n_props, DWORD* props,
+ void** datas, DWORD* n_datas)
{
EnumArguments* args = (EnumArguments*)arg;
CRYPT_KEY_PROV_INFO* prov_info = NULL;
- CkCapiObject *obj = NULL;
+ P11cObject *obj = NULL;
KeyObjectData kdata;
DWORD i;
@@ -807,13 +807,13 @@ enum_key_property_info(PCRYPT_HASH_BLOB key_identifier, DWORD flags,
kdata.base.object = 0;
kdata.base.data_funcs = &key_objdata_vtable;
- if(ckcapi_object_data_match(&kdata.base, args->match, args->count))
+ if(p11c_object_data_match(&kdata.base, args->match, args->count))
{
args->ret = register_key_object(args->sess, args->object_class, key_identifier, &obj);
if(args->ret == CKR_OK)
{
ASSERT(obj);
- ckcapi_array_append(args->results, obj->id);
+ p11c_array_append(args->results, obj->id);
}
}
@@ -822,8 +822,8 @@ enum_key_property_info(PCRYPT_HASH_BLOB key_identifier, DWORD flags,
}
static CK_RV
-find_any_keys(CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count, CkCapiArray* arr)
+find_any_keys(P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count, P11cArray* arr)
{
CRYPT_HASH_BLOB find_id;
EnumArguments enum_args;
@@ -852,14 +852,14 @@ find_any_keys(CkCapiSession* sess, CK_OBJECT_CLASS cls,
if(!CryptEnumKeyIdentifierProperties(find_id.cbData != 0 ? &find_id : NULL,
CERT_KEY_PROV_INFO_PROP_ID, 0, NULL, NULL,
&enum_args, enum_key_property_info))
- return ckcapi_winerr_to_ckr(GetLastError());
+ return p11c_winerr_to_ckr(GetLastError());
return enum_args.ret;
}
static CK_RV
-list_matching_certificates(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
- CK_ULONG count, CkCapiArray* arr)
+list_matching_certificates(P11cSession* sess, CK_ATTRIBUTE_PTR match,
+ CK_ULONG count, P11cArray* arr)
{
CK_OBJECT_CLASS cert_class = CKO_CERTIFICATE;
CK_ATTRIBUTE search[3];
@@ -888,19 +888,19 @@ list_matching_certificates(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
}
/* Do the certificate search */
- return ckcapi_cert_find(sess, CKO_CERTIFICATE, search, n_search, arr);
+ return p11c_cert_find(sess, CKO_CERTIFICATE, search, n_search, arr);
}
static CK_RV
-find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
+find_certificate_key(P11cSession* session, CK_OBJECT_CLASS cls,
CK_ATTRIBUTE_PTR match, CK_ULONG count,
- PCCERT_CONTEXT cert, CkCapiArray* arr)
+ PCCERT_CONTEXT cert, P11cArray* arr)
{
CRYPT_KEY_PROV_INFO* prov_info;
CRYPT_HASH_BLOB key_identifier;
- CkCapiObjectData* objdata;
+ P11cObjectData* objdata;
KeyObjectData kdata;
- CkCapiObject* obj;
+ P11cObject* obj;
DWORD prov_length;
DWORD error;
CK_RV ret = CKR_OK;
@@ -912,7 +912,7 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
error = GetLastError();
if(error == CRYPT_E_NOT_FOUND)
return CKR_OK;
- return ckcapi_winerr_to_ckr(error);
+ return p11c_winerr_to_ckr(error);
}
/* We own the info memory */
@@ -936,7 +936,7 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
kdata.base.object = 0;
kdata.base.data_funcs = &key_objdata_vtable;
- if(ckcapi_object_data_match(&kdata.base, match, count))
+ if(p11c_object_data_match(&kdata.base, match, count))
{
ret = register_key_object(session, cls, &key_identifier, &obj);
if(ret == CKR_OK)
@@ -947,7 +947,7 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
objdata = key_alloc_data(session, obj, prov_info);
if(objdata)
{
- ckcapi_session_take_object_data(session, obj, objdata);
+ p11c_session_take_object_data(session, obj, objdata);
/* Note these are used, and not to be freed */
key_identifier.pbData = NULL;
@@ -955,13 +955,13 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
prov_info = NULL;
}
- ckcapi_array_append(arr, obj->id);
+ p11c_array_append(arr, obj->id);
}
}
}
else
{
- ret = ckcapi_winerr_to_ckr(GetLastError());
+ ret = p11c_winerr_to_ckr(GetLastError());
}
if(key_identifier.pbData)
@@ -973,18 +973,18 @@ find_certificate_key(CkCapiSession* session, CK_OBJECT_CLASS cls,
}
static CK_RV
-find_certificate_keys(CkCapiSession* session, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count, CkCapiArray* arr)
+find_certificate_keys(P11cSession* session, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count, P11cArray* arr)
{
CK_OBJECT_HANDLE id;
- CkCapiObjectData* certdata;
- CkCapiArray* certarr;
+ P11cObjectData* certdata;
+ P11cArray* certarr;
PCCERT_CONTEXT cert;
CK_RV ret = CKR_OK;
CK_ULONG i;
/* Get a list of all certificates */
- certarr = ckcapi_array_new(0, 1, sizeof(CK_OBJECT_HANDLE));
+ certarr = p11c_array_new(0, 1, sizeof(CK_OBJECT_HANDLE));
if(!certarr)
return CKR_HOST_MEMORY;
ret = list_matching_certificates(session, match, count, certarr);
@@ -994,15 +994,15 @@ find_certificate_keys(CkCapiSession* session, CK_OBJECT_CLASS cls,
{
for(i = 0; i < certarr->len; ++i)
{
- id = ckcapi_array_index(certarr, CK_OBJECT_HANDLE, i);
+ id = p11c_array_index(certarr, CK_OBJECT_HANDLE, i);
ASSERT(id);
/* Get the certificate data for this certificate object */
- if(ckcapi_session_get_object_data_for(session, id, &certdata) != CKR_OK)
+ if(p11c_session_get_object_data_for(session, id, &certdata) != CKR_OK)
continue;
/* Get the certificate context */
- cert = ckcapi_cert_object_data_get_certificate(certdata);
+ cert = p11c_cert_object_data_get_certificate(certdata);
if(!cert)
continue;
@@ -1011,18 +1011,18 @@ find_certificate_keys(CkCapiSession* session, CK_OBJECT_CLASS cls,
}
}
- ckcapi_array_free(certarr, TRUE);
+ p11c_array_free(certarr, TRUE);
return ret;
}
CK_RV
-ckcapi_key_find(CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count, CkCapiArray* arr)
+p11c_key_find(P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count, P11cArray* arr)
{
CK_RV ret = CKR_OK;
/* Is this somewhere we have all keys present? */
- if(ckcapi_token_get_flags(sess->slot) & CKCAPI_SLOT_ANYKEY)
+ if(p11c_token_get_flags(sess->slot) & P11c_SLOT_ANYKEY)
{
if((cls == CKO_PRIVATE_KEY || cls == CKO_ANY) && ret == CKR_OK)
ret = find_any_keys(sess, CKO_PRIVATE_KEY, match, count, arr);
@@ -1043,7 +1043,7 @@ ckcapi_key_find(CkCapiSession* sess, CK_OBJECT_CLASS cls,
}
DWORD
-ckcapi_key_object_data_get_bits(CkCapiObjectData* objdata)
+p11c_key_object_data_get_bits(P11cObjectData* objdata)
{
KeyObjectData* kdata;
PUBLICKEYSTRUC* header;
@@ -1073,7 +1073,7 @@ ckcapi_key_object_data_get_bits(CkCapiObjectData* objdata)
}
CRYPT_KEY_PROV_INFO*
-ckcapi_key_object_data_get_prov_info(CkCapiObjectData* objdata)
+p11c_key_object_data_get_prov_info(P11cObjectData* objdata)
{
KeyObjectData* kdata;
diff --git a/ckcapi-key.h b/p11-capi-key.h
index eabe7a9..b57a2d3 100644
--- a/ckcapi-key.h
+++ b/p11-capi-key.h
@@ -17,18 +17,18 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef CKCAPI_KEY_H
-#define CKCAPI_KEY_H
+#ifndef P11C_KEY_H
+#define P11C_KEY_H
-#include "ckcapi.h"
+#include "p11-capi.h"
/* Find key objects matching criteria */
-CK_RV ckcapi_key_find (CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count,
- CkCapiArray* arr);
+CK_RV p11c_key_find (P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count,
+ P11cArray* arr);
-DWORD ckcapi_key_object_data_get_bits (CkCapiObjectData* objdata);
+DWORD p11c_key_object_data_get_bits (P11cObjectData* objdata);
-CRYPT_KEY_PROV_INFO* ckcapi_key_object_data_get_prov_info (CkCapiObjectData* objdata);
+CRYPT_KEY_PROV_INFO* p11c_key_object_data_get_prov_info (P11cObjectData* objdata);
-#endif /* CRYPTOKI_KEY_H */
+#endif /* P11C_KEY_H */
diff --git a/ckcapi-object.c b/p11-capi-object.c
index 3143700..6c2330e 100644
--- a/ckcapi-object.c
+++ b/p11-capi-object.c
@@ -17,8 +17,8 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
-#include "ckcapi-object.h"
+#include "p11-capi.h"
+#include "p11-capi-object.h"
#include "pkcs11/pkcs11n.h"
@@ -148,7 +148,7 @@ attribute_data_type(CK_ATTRIBUTE_TYPE type)
}
CK_BBOOL
-ckcapi_object_data_match_attr(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR match)
+p11c_object_data_match_attr(P11cObjectData* objdata, CK_ATTRIBUTE_PTR match)
{
CK_ATTRIBUTE attr;
CK_RV rv;
@@ -201,18 +201,18 @@ ckcapi_object_data_match_attr(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR match)
return CK_FALSE;
return (match->ulValueLen == attr.ulValueLen &&
- memcmp(match->pValue, attr.pValue, attr.ulValueLen) == 0);
+ memcmp(match->pValue, attr.pValue, attr.ulValueLen) == 0);
}
CK_BBOOL
-ckcapi_object_data_match(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR matches,
+p11c_object_data_match(P11cObjectData* objdata, CK_ATTRIBUTE_PTR matches,
CK_ULONG count)
{
CK_ULONG i;
for(i = 0; i < count; ++i)
{
- if(!ckcapi_object_data_match_attr(objdata, &matches[i]))
+ if(!p11c_object_data_match_attr(objdata, &matches[i]))
return CK_FALSE;
}
@@ -220,7 +220,7 @@ ckcapi_object_data_match(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR matches,
}
CK_RV
-ckcapi_object_data_get_attrs(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attrs,
+p11c_object_data_get_attrs(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attrs,
CK_ULONG count)
{
CK_ULONG i;
diff --git a/ckcapi-object.h b/p11-capi-object.h
index 2b07c30..cd08ae9 100644
--- a/ckcapi-object.h
+++ b/p11-capi-object.h
@@ -17,84 +17,84 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef CKCAPI_OBJECT_H
-#define CKCAPI_OBJECT_H
+#ifndef P11C_OBJECT_H
+#define P11C_OBJECT_H
-#include "ckcapi.h"
+#include "p11-capi.h"
/* Debug print something about an object */
#define DBGO(obj, msg) \
- ckcapi_debug("O%d: %s", (obj) ? (obj)->id : 0, (msg))
+ p11c_debug("O%d: %s", (obj) ? (obj)->id : 0, (msg))
/* A function to load data for an object */
-typedef CK_RV (*CkCapiLoadData)(CkCapiSession* sess, struct _CkCapiObject* obj,
- CkCapiObjectData** objdata);
+typedef CK_RV (*P11cLoadData)(P11cSession* sess, struct _P11cObject* obj,
+ P11cObjectData** objdata);
/* Produce a hash code for an object */
-typedef CK_RV (*CkCapiHashObject)(struct _CkCapiObject* obj);
+typedef CK_RV (*P11cHashObject)(struct _P11cObject* obj);
/* Produce a hash code for an object */
-typedef CK_RV (*CkCapiEqualObject)(struct _CkCapiObject* one, struct _CkCapiObject* two);
+typedef CK_RV (*P11cEqualObject)(struct _P11cObject* one, struct _P11cObject* two);
/* A function to free some data */
-typedef void (*CkCapiRelease)(void* data);
+typedef void (*P11cRelease)(void* data);
/* Object functions */
-typedef struct _CkCapiObjectVtable
+typedef struct _P11cObjectVtable
{
- CkCapiLoadData load_data;
- CkCapiHashObject hash_object;
- CkCapiEqualObject equal_object;
- CkCapiRelease release;
+ P11cLoadData load_data;
+ P11cHashObject hash_object;
+ P11cEqualObject equal_object;
+ P11cRelease release;
}
-CkCapiObjectVtable;
+P11cObjectVtable;
/* Represents a object we've seen */
-struct _CkCapiObject
+struct _P11cObject
{
CK_OBJECT_HANDLE id;
CK_SLOT_ID slot;
CK_SESSION_HANDLE session;
- const CkCapiObjectVtable* obj_funcs;
+ const P11cObjectVtable* obj_funcs;
};
/* A function to get an attribute from ObjectData */
-typedef CK_RV (*CkCapiGetAttribute)(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr);
+typedef CK_RV (*P11cGetAttribute)(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr);
/* Object data functions */
-typedef struct _CkCapiObjectDataVtable
+typedef struct _P11cObjectDataVtable
{
- CkCapiGetAttribute get_bool;
- CkCapiGetAttribute get_ulong;
- CkCapiGetAttribute get_bytes;
- CkCapiRelease release;
+ P11cGetAttribute get_bool;
+ P11cGetAttribute get_ulong;
+ P11cGetAttribute get_bytes;
+ P11cRelease release;
}
-CkCapiObjectDataVtable;
+P11cObjectDataVtable;
/*
* Base class for object data. Different types of
* objects extend this with more detailed data
*/
-struct _CkCapiObjectData
+struct _P11cObjectData
{
CK_OBJECT_HANDLE object;
- const CkCapiObjectDataVtable* data_funcs;
+ const P11cObjectDataVtable* data_funcs;
};
/* Match object data against all the given match attributes */
-CK_BBOOL ckcapi_object_data_match (CkCapiObjectData* objdata,
- CK_ATTRIBUTE_PTR matches, CK_ULONG count);
+CK_BBOO p11c_object_data_match (P11cObjectData* objdata,
+ CK_ATTRIBUTE_PTR matches, CK_ULONG count);
/* Match a single attribute against object data */
-CK_BBOOL ckcapi_object_data_match_attr (CkCapiObjectData* objdata,
- CK_ATTRIBUTE_PTR match);
+CK_BBOOL p11c_object_data_match_attr (P11cObjectData* objdata,
+ CK_ATTRIBUTE_PTR match);
/* Get a bunch of attributes from object data */
-CK_RV ckcapi_object_data_get_attrs (CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attrs,
- CK_ULONG count);
+CK_RV p11c_object_data_get_attrs (P11cObjectData* objdata, CK_ATTRIBUTE_PTR attrs,
+ CK_ULONG count);
/* Debug print something about an object data */
#define DBGOD(objdata, msg) \
- ckcapi_debug("O%d: %s", (objdata) ? (objdata)->obj : 0, (msg))
+ p11c_debug("O%d: %s", (objdata) ? (objdata)->obj : 0, (msg))
-#endif /* CKCAPI_OBJECT_H */
+#endif /* P11C_OBJECT_H */
diff --git a/ckcapi-rsa.c b/p11-capi-rsa.c
index 032bf82..1e22618 100644
--- a/ckcapi-rsa.c
+++ b/p11-capi-rsa.c
@@ -17,11 +17,11 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
+#include "p11c.h"
-#include "ckcapi-der.h"
-#include "ckcapi-key.h"
-#include "ckcapi-object.h"
+#include "p11-capi-der.h"
+#include "p11-capi-key.h"
+#include "p11-capi-object.h"
/*
* Portions derived from NSS source files:
@@ -102,7 +102,7 @@ parse_rsa_pkcs_der_hash(CK_BYTE_PTR input, CK_ULONG n_input,
}
/* make sure we have a sequence tag */
- if((CKCAPI_DER_SEQUENCE | CKCAPI_DER_CONSTRUCTED) != *input)
+ if((P11C_DER_SEQUENCE | P11C_DER_CONSTRUCTED) != *input)
return NULL;
/*
@@ -120,7 +120,7 @@ parse_rsa_pkcs_der_hash(CK_BYTE_PTR input, CK_ULONG n_input,
*/
/* unwrap */
- algid = ckcapi_der_unwrap(input, n_input, &n_algid, NULL);
+ algid = p11c_der_unwrap(input, n_input, &n_algid, NULL);
if(!algid)
return NULL;
@@ -129,10 +129,10 @@ parse_rsa_pkcs_der_hash(CK_BYTE_PTR input, CK_ULONG n_input,
return NULL;
/* wasn't an algid */
- if((CKCAPI_DER_SEQUENCE | CKCAPI_DER_CONSTRUCTED) != *algid)
+ if((P11C_DER_SEQUENCE | P11C_DER_CONSTRUCTED) != *algid)
return NULL;
- oid = ckcapi_der_unwrap(algid, n_algid, &n_oid, &hash_data);
+ oid = p11c_der_unwrap(algid, n_algid, &n_oid, &hash_data);
if(!oid || !hash_data)
return NULL;
@@ -142,7 +142,7 @@ parse_rsa_pkcs_der_hash(CK_BYTE_PTR input, CK_ULONG n_input,
* get the real oid as a string. Again, Microsoft does not
* export anything that does this for us
*/
- oid_str = ckcapi_der_read_oid(oid, n_oid);
+ oid_str = p11c_der_read_oid(oid, n_oid);
if(!oid_str)
return NULL;
@@ -152,16 +152,16 @@ parse_rsa_pkcs_der_hash(CK_BYTE_PTR input, CK_ULONG n_input,
}
/* wasn't a hash? */
- if(CKCAPI_DER_OCTET_STRING != *hash_data)
+ if(P11C_DER_OCTET_STRING != *hash_data)
return NULL;
/* get the real raw hash */
- return ckcapi_der_unwrap(hash_data, n_algid - (hash_data - algid),
+ return p11c_der_unwrap(hash_data, n_algid - (hash_data - algid),
n_hash, NULL);
}
CK_RV
-ckcapi_rsa_pkcs_sign_init(CkCapiObjectData *keydata, void** operation)
+p11c_rsa_pkcs_sign_init(P11CObjectData *keydata, void** operation)
{
CRYPT_KEY_PROV_INFO* prov_info;
@@ -169,7 +169,7 @@ ckcapi_rsa_pkcs_sign_init(CkCapiObjectData *keydata, void** operation)
ASSERT(operation);
ASSERT(!*operation);
- prov_info = ckcapi_key_object_data_get_prov_info(keydata);
+ prov_info = p11c_key_object_data_get_prov_info(keydata);
if(prov_info->dwProvType != PROV_RSA_FULL)
return CKR_KEY_TYPE_INCONSISTENT;
@@ -178,12 +178,12 @@ ckcapi_rsa_pkcs_sign_init(CkCapiObjectData *keydata, void** operation)
}
CK_RV
-ckcapi_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG n_data,
- CK_BYTE_PTR signature, CK_ULONG_PTR n_signature,
- void** operation)
+p11c_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG n_data,
+ CK_BYTE_PTR signature, CK_ULONG_PTR n_signature,
+ void** operation)
{
CRYPT_KEY_PROV_INFO* prov_info;
- CkCapiObjectData* keydata;
+ P11CObjectData* keydata;
ALG_ID algorithm;
BYTE* hash_data;
DWORD n_hash_data;
@@ -202,13 +202,13 @@ ckcapi_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG n_data,
if(!data || !n_data)
return CKR_ARGUMENTS_BAD;
- keydata = (CkCapiObjectData*)*operation;
+ keydata = (P11CObjectData*)*operation;
- prov_info = ckcapi_key_object_data_get_prov_info(keydata);
+ prov_info = p11c_key_object_data_get_prov_info(keydata);
ASSERT(prov_info);
/* Calculate the number of bits */
- bits = ckcapi_key_object_data_get_bits (keydata);
+ bits = p11c_key_object_data_get_bits (keydata);
if(!bits)
return CKR_GENERAL_ERROR;
@@ -264,7 +264,7 @@ ckcapi_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG n_data,
* the data we recieved here
*/
if(signature)
- ckcapi_reverse_memory(signature, *n_signature);
+ p11c_reverse_memory(signature, *n_signature);
capifail = FALSE;
ret = CKR_OK;
@@ -275,7 +275,7 @@ ckcapi_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG n_data,
}
if(capifail)
- ret = ckcapi_winerr_to_ckr(GetLastError());
+ ret = p11c_winerr_to_ckr(GetLastError());
if(hash)
CryptDestroyHash(hash);
@@ -286,14 +286,14 @@ ckcapi_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG n_data,
}
void
-ckcapi_rsa_pkcs_sign_cleanup (void* operation)
+p11c_rsa_pkcs_sign_cleanup (void* operation)
{
/* Nothing to do */
}
CK_RV
-ckcapi_rsa_pkcs_decrypt_init(CkCapiObjectData* keydata, void** operation)
+p11c_rsa_pkcs_decrypt_init(P11CObjectData* keydata, void** operation)
{
CRYPT_KEY_PROV_INFO* prov_info;
@@ -301,7 +301,7 @@ ckcapi_rsa_pkcs_decrypt_init(CkCapiObjectData* keydata, void** operation)
ASSERT(operation);
ASSERT(!*operation);
- prov_info = ckcapi_key_object_data_get_prov_info(keydata);
+ prov_info = p11c_key_object_data_get_prov_info(keydata);
if(prov_info->dwProvType != PROV_RSA_FULL)
return CKR_KEY_TYPE_INCONSISTENT;
@@ -310,12 +310,12 @@ ckcapi_rsa_pkcs_decrypt_init(CkCapiObjectData* keydata, void** operation)
}
CK_RV
-ckcapi_rsa_pkcs_decrypt_perform(CK_BYTE_PTR encdata, CK_ULONG n_encdata,
- CK_BYTE_PTR result, CK_ULONG_PTR n_result,
- void** operation)
+p11c_rsa_pkcs_decrypt_perform(CK_BYTE_PTR encdata, CK_ULONG n_encdata,
+ CK_BYTE_PTR result, CK_ULONG_PTR n_result,
+ void** operation)
{
CRYPT_KEY_PROV_INFO* prov_info;
- CkCapiObjectData* keydata;
+ P11CObjectData* keydata;
BOOL capifail;
DWORD bits, error;
CK_RV ret;
@@ -329,13 +329,13 @@ ckcapi_rsa_pkcs_decrypt_perform(CK_BYTE_PTR encdata, CK_ULONG n_encdata,
ASSERT(encdata);
ASSERT(n_encdata);
- keydata = (CkCapiObjectData*)*operation;
+ keydata = (P11CObjectData*)*operation;
- prov_info = ckcapi_key_object_data_get_prov_info(keydata);
+ prov_info = p11c_key_object_data_get_prov_info(keydata);
ASSERT(prov_info);
/* Calculate the number of bits */
- bits = ckcapi_key_object_data_get_bits (keydata);
+ bits = p11c_key_object_data_get_bits (keydata);
if(!bits)
return CKR_GENERAL_ERROR;
@@ -355,7 +355,7 @@ ckcapi_rsa_pkcs_decrypt_perform(CK_BYTE_PTR encdata, CK_ULONG n_encdata,
return CKR_HOST_MEMORY;
memcpy(buffer, encdata, n_encdata);
- ckcapi_reverse_memory(buffer, n_encdata);
+ p11c_reverse_memory(buffer, n_encdata);
capifail = TRUE;
if(CryptAcquireContextW(&prov, prov_info->pwszContainerName, prov_info->pwszProvName,
@@ -380,13 +380,13 @@ ckcapi_rsa_pkcs_decrypt_perform(CK_BYTE_PTR encdata, CK_ULONG n_encdata,
case NTE_BAD_DATA:
ret = CKR_ENCRYPTED_DATA_INVALID;
default:
- ret = ckcapi_winerr_to_ckr(error);
+ ret = p11c_winerr_to_ckr(error);
};
}
/* Copy the memory out to the result buffer */
if(ret == CKR_OK)
- ret = ckcapi_return_data_raw(result, n_result, buffer, *n_result);
+ ret = p11c_return_data_raw(result, n_result, buffer, *n_result);
if(key)
CryptDestroyKey(key);
@@ -399,13 +399,13 @@ ckcapi_rsa_pkcs_decrypt_perform(CK_BYTE_PTR encdata, CK_ULONG n_encdata,
}
void
-ckcapi_rsa_pkcs_decrypt_cleanup(void* operation)
+p11c_rsa_pkcs_decrypt_cleanup(void* operation)
{
/* Nothing to do */
}
void
-ckcapi_rsa_pkcs_get_info (CK_MECHANISM_TYPE mech, CK_MECHANISM_INFO_PTR info)
+p11c_rsa_pkcs_get_info(CK_MECHANISM_TYPE mech, CK_MECHANISM_INFO_PTR info)
{
ASSERT(mech == CKM_RSA_PKCS);
ASSERT(info != NULL);
diff --git a/p11-capi-rsa.h b/p11-capi-rsa.h
new file mode 100644
index 0000000..0ce571e
--- /dev/null
+++ b/p11-capi-rsa.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008 Stef Walter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef P11C_RSA_H
+#define P11C_RSA_H
+
+#include "p11-capi.h"
+
+CK_RV p11c_rsa_pkcs_sign_init (P11cObjectData* keydata, void** operation);
+
+CK_RV p11c_rsa_pkcs_sign_perform (CK_BYTE_PTR data, CK_ULONG data_len,
+ CK_BYTE_PTR signature, CK_ULONG_PTR signature_len,
+ void** operation);
+
+void p11c_rsa_pkcs_sign_cleanup (void* operation);
+
+CK_RV p11c_rsa_pkcs_decrypt_init (P11cObjectData* keydata, void** operation);
+
+CK_RV p11c_rsa_pkcs_decrypt_perform (CK_BYTE_PTR encdata, CK_ULONG n_encdata,
+ CK_BYTE_PTR result, CK_ULONG_PTR n_result,
+ void** operation);
+
+void p11c_rsa_pkcs_decrypt_cleanup (void* operation);
+
+void p11c_rsa_pkcs_get_info (CK_MECHANISM_TYPE mech,
+ CK_MECHANISM_INFO_PTR info);
+
+#endif /* P11C_RSA_H */
diff --git a/ckcapi-session.c b/p11-capi-session.c
index d1d345c..e921875 100644
--- a/ckcapi-session.c
+++ b/p11-capi-session.c
@@ -19,17 +19,17 @@
#include <stdlib.h>
-#include "ckcapi.h"
-#include "ckcapi-builtin.h"
-#include "ckcapi-cert.h"
-#include "ckcapi-key.h"
-#include "ckcapi-object.h"
-#include "ckcapi-rsa.h"
-#include "ckcapi-session.h"
-#include "ckcapi-token.h"
-#include "ckcapi-trust.h"
-
-/* For operation_type in CkCapiSession */
+#include "p11-capi.h"
+#include "p11-capi-builtin.h"
+#include "p11-capi-cert.h"
+#include "p11-capi-key.h"
+#include "p11-capi-object.h"
+#include "p11-capi-rsa.h"
+#include "p11-capi-session.h"
+#include "p11-capi-token.h"
+#include "p11-capi-trust.h"
+
+/* For operation_type in P11cSession */
enum
{
OPERATION_NONE,
@@ -38,10 +38,10 @@ enum
OPERATION_DECRYPT
};
-static CkCapiArray* all_sessions = NULL;
+static P11cArray* all_sessions = NULL;
static void
-object_data_release(CkCapiObjectData* objdata)
+object_data_release(P11cObjectData* objdata)
{
ASSERT(objdata->data_funcs);
ASSERT(objdata->data_funcs->release);
@@ -49,17 +49,17 @@ object_data_release(CkCapiObjectData* objdata)
}
CK_RV
-ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
+p11c_session_create(CK_SLOT_ID slot, P11cSession** ret)
{
- CkCapiSession* sess;
+ P11cSession* sess;
const char *store;
DWORD err;
- sess = calloc(1, sizeof(CkCapiSession));
+ sess = calloc(1, sizeof(P11cSession));
if(!sess)
return CKR_HOST_MEMORY;
- sess->object_data = ckcapi_hash_new(NULL, NULL);
+ sess->object_data = p11c_hash_new(NULL, NULL);
if(!sess->object_data) {
free(sess);
return CKR_HOST_MEMORY;
@@ -67,12 +67,12 @@ ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
sess->mutex = CreateMutex(NULL, FALSE, NULL);
if(!sess->mutex) {
- ckcapi_hash_free(sess->object_data, NULL);
+ p11c_hash_free(sess->object_data, NULL);
free(sess);
return CKR_HOST_MEMORY;
}
- store = ckcapi_token_get_store_name(slot);
+ store = p11c_token_get_store_name(slot);
if(store)
{
sess->store = CertOpenSystemStore((HCRYPTPROV)NULL, store);
@@ -83,10 +83,10 @@ ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
/* Store not found, we don't care */
if(err != ERROR_FILE_NOT_FOUND)
{
- ckcapi_hash_free(sess->object_data, NULL);
+ p11c_hash_free(sess->object_data, NULL);
CloseHandle(sess->mutex);
free(sess);
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
}
}
@@ -100,9 +100,9 @@ ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
}
CK_RV
-ckcapi_session_register(CkCapiSession* sess)
+p11c_session_register(P11cSession* sess)
{
- CkCapiSession* blank = NULL;
+ P11cSession* blank = NULL;
CK_SESSION_HANDLE id = 0;
CK_RV ret = CKR_OK;
size_t i;
@@ -112,7 +112,7 @@ ckcapi_session_register(CkCapiSession* sess)
DBGS(sess, "registering new session");
- ckcapi_lock_global();
+ p11c_lock_global();
/* Find a nice session identifier */
while(id == 0) {
@@ -120,7 +120,7 @@ ckcapi_session_register(CkCapiSession* sess)
/* Allocate sessions properly */
if(!all_sessions)
{
- all_sessions = ckcapi_array_new(0, 1, sizeof(CkCapiSession*));
+ all_sessions = p11c_array_new(0, 1, sizeof(P11cSession*));
if(!all_sessions)
{
ret = CKR_HOST_MEMORY;
@@ -128,7 +128,7 @@ ckcapi_session_register(CkCapiSession* sess)
}
/* A blank entry for '0' */
- ckcapi_array_append(all_sessions, blank);
+ p11c_array_append(all_sessions, blank);
DBG(("allocated new session list"));
}
@@ -143,7 +143,7 @@ ckcapi_session_register(CkCapiSession* sess)
for(i = 1; i < all_sessions->len; ++i)
{
/* Any empty position will do */
- if(!ckcapi_array_index(all_sessions, CkCapiSession*, i))
+ if(!p11c_array_index(all_sessions, P11cSession*, i))
{
id = i;
break;
@@ -154,18 +154,18 @@ ckcapi_session_register(CkCapiSession* sess)
if(id == 0)
{
id = all_sessions->len;
- ckcapi_array_append(all_sessions, blank);
+ p11c_array_append(all_sessions, blank);
}
}
if(ret == CKR_OK)
{
ASSERT(id > 0 && id < all_sessions->len);
- ASSERT(!ckcapi_array_index(all_sessions, CkCapiSession*, id));
+ ASSERT(!p11c_array_index(all_sessions, P11cSession*, id));
/* And assign it to the session handle */
- ckcapi_array_index(all_sessions, CkCapiSession*, i) = sess;
+ p11c_array_index(all_sessions, P11cSession*, i) = sess;
sess->id = id;
/* The session list reference */
@@ -175,13 +175,13 @@ ckcapi_session_register(CkCapiSession* sess)
DBGS(sess, "registered sesson id");
}
- ckcapi_unlock_global();
+ p11c_unlock_global();
return ret;
}
void
-ckcapi_session_destroy(CkCapiSession* sess)
+p11c_session_destroy(P11cSession* sess)
{
ASSERT(sess);
ASSERT(sess->refs == 0);
@@ -202,7 +202,7 @@ ckcapi_session_destroy(CkCapiSession* sess)
/* Make all the object adat go away */
ASSERT(sess->object_data != NULL);
- ckcapi_hash_free(sess->object_data, object_data_release);
+ p11c_hash_free(sess->object_data, object_data_release);
/* And make the mutex go away */
ASSERT(sess->mutex != NULL);
@@ -213,7 +213,7 @@ ckcapi_session_destroy(CkCapiSession* sess)
}
void
-ckcapi_session_get_info(CkCapiSession* sess, CK_SESSION_INFO_PTR info)
+p11c_session_get_info(P11cSession* sess, CK_SESSION_INFO_PTR info)
{
ASSERT(sess);
ASSERT(info);
@@ -223,7 +223,7 @@ ckcapi_session_get_info(CkCapiSession* sess, CK_SESSION_INFO_PTR info)
if(sess->read_write)
info->flags |= CKF_RW_SESSION;
- if(ckcapi_token_is_logged_in(sess->slot))
+ if(p11c_token_is_logged_in(sess->slot))
info->state = sess->read_write ? CKS_RW_USER_FUNCTIONS : CKS_RO_USER_FUNCTIONS;
else
info->state = sess->read_write ? CKS_RW_PUBLIC_SESSION : CKS_RO_PUBLIC_SESSION;
@@ -233,10 +233,10 @@ ckcapi_session_get_info(CkCapiSession* sess, CK_SESSION_INFO_PTR info)
}
static CK_RV
-lock_ref_internal(CkCapiArray* sessions, CK_SESSION_HANDLE id,
- BOOL remove, BOOL writable, CkCapiSession** sess_ret)
+lock_ref_internal(P11cArray* sessions, CK_SESSION_HANDLE id,
+ BOOL remove, BOOL writable, P11cSession** sess_ret)
{
- CkCapiSession *sess;
+ P11cSession *sess;
DWORD r;
ASSERT(sessions);
@@ -250,7 +250,7 @@ lock_ref_internal(CkCapiArray* sessions, CK_SESSION_HANDLE id,
/* A seemingly valid id */
ASSERT(sessions);
- sess = ckcapi_array_index(sessions, CkCapiSession*, id);
+ sess = p11c_array_index(sessions, P11cSession*, id);
if(!sess)
{
@@ -281,7 +281,7 @@ lock_ref_internal(CkCapiArray* sessions, CK_SESSION_HANDLE id,
}
}
- /* Lock the CallCkCapiSession */
+ /* Lock the CallP11cSession */
r = WaitForSingleObject(sess->mutex, INFINITE);
ASSERT(r == WAIT_OBJECT_0);
@@ -302,7 +302,7 @@ lock_ref_internal(CkCapiArray* sessions, CK_SESSION_HANDLE id,
/* And remove it if necessary */
if(remove)
{
- ckcapi_array_index(sessions, CkCapiSession*, id) = NULL;
+ p11c_array_index(sessions, P11cSession*, id) = NULL;
/* The session list reference */
sess->refs--;
@@ -321,7 +321,7 @@ lock_ref_internal(CkCapiArray* sessions, CK_SESSION_HANDLE id,
}
CK_RV
-ckcapi_session_get_lock_ref(CK_ULONG id, BOOL writable, CkCapiSession **sess)
+p11c_session_get_lock_ref(CK_ULONG id, BOOL writable, P11cSession **sess)
{
/* This must be called without any locks held */
@@ -335,17 +335,17 @@ ckcapi_session_get_lock_ref(CK_ULONG id, BOOL writable, CkCapiSession **sess)
return CKR_ARGUMENTS_BAD;
}
- ckcapi_lock_global();
+ p11c_lock_global();
ret = lock_ref_internal (all_sessions, id, FALSE, writable, sess);
- ckcapi_unlock_global();
+ p11c_unlock_global();
return ret;
}
CK_RV
-ckcapi_session_remove_lock_ref(CK_ULONG id, CkCapiSession **sess)
+p11c_session_remove_lock_ref(CK_ULONG id, P11cSession **sess)
{
/* This must be called without any locks held */
@@ -359,19 +359,19 @@ ckcapi_session_remove_lock_ref(CK_ULONG id, CkCapiSession **sess)
return CKR_ARGUMENTS_BAD;
}
- ckcapi_lock_global();
+ p11c_lock_global();
ret = lock_ref_internal (all_sessions, id, TRUE, FALSE, sess);
- ckcapi_unlock_global();
+ p11c_unlock_global();
return ret;
}
void
-ckcapi_session_unref_unlock(CkCapiSession* sess)
+p11c_session_unref_unlock(P11cSession* sess)
{
- /* The CallCkCapiSession must be locked at this point */
+ /* The CallP11cSession must be locked at this point */
int refs;
BOOL r;
@@ -395,16 +395,16 @@ ckcapi_session_unref_unlock(CkCapiSession* sess)
*/
if(refs == 0)
- ckcapi_session_destroy(sess);
+ p11c_session_destroy(sess);
}
CK_RV
-ckcapi_session_close_all(CK_SLOT_ID slot)
+p11c_session_close_all(CK_SLOT_ID slot)
{
/* This must be called without any locks held */
- CkCapiArray* sessions;
- CkCapiSession *sess;
+ P11cArray* sessions;
+ P11cSession *sess;
size_t i;
CK_RV ret = CKR_OK;
@@ -419,9 +419,9 @@ ckcapi_session_close_all(CK_SLOT_ID slot)
if(!all_sessions)
return CKR_OK;
- ckcapi_lock_global();
+ p11c_lock_global();
- sessions = ckcapi_array_sized_new(0, 1, sizeof(CkCapiSession*),
+ sessions = p11c_array_sized_new(0, 1, sizeof(P11cSession*),
all_sessions->len);
if(!sessions)
ret = CKR_HOST_MEMORY;
@@ -431,11 +431,11 @@ ckcapi_session_close_all(CK_SLOT_ID slot)
{
for(i = 0; i < all_sessions->len; ++i)
{
- sess = ckcapi_array_index(all_sessions, CkCapiSession*, i);
+ sess = p11c_array_index(all_sessions, P11cSession*, i);
if(sess && (slot == ((CK_SLOT_ID)-1) || sess->slot == slot))
{
/* Steal this session */
- ckcapi_array_index(all_sessions, CkCapiSession*, i) = NULL;
+ p11c_array_index(all_sessions, P11cSession*, i) = NULL;
}
else
{
@@ -444,13 +444,13 @@ ckcapi_session_close_all(CK_SLOT_ID slot)
}
/* Both null and normal sessions are set to preserve indexes */
- ckcapi_array_append(sessions, sess);
+ p11c_array_append(sessions, sess);
}
ASSERT(sessions->len == all_sessions->len);
}
- ckcapi_unlock_global();
+ p11c_unlock_global();
if(ret != CKR_OK)
return ret;
@@ -458,30 +458,30 @@ ckcapi_session_close_all(CK_SLOT_ID slot)
/* Close each session in turn */
for(i = 0; i < sessions->len; ++i)
{
- if(!ckcapi_array_index(sessions, CkCapiSession*, i))
+ if(!p11c_array_index(sessions, P11cSession*, i))
continue;
/* We need any calls in other threads to finish, so wait here */
if(lock_ref_internal(sessions, i, TRUE, FALSE, &sess) == CKR_OK)
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
/* We stole the memory above, free it now */
- ckcapi_array_free(sessions, 1);
+ p11c_array_free(sessions, 1);
return CKR_OK;
}
void
-ckcapi_session_cleanup_all()
+p11c_session_cleanup_all()
{
- ckcapi_session_close_all((CK_SLOT_ID)-1);
+ p11c_session_close_all((CK_SLOT_ID)-1);
- ckcapi_lock_global();
+ p11c_lock_global();
- ckcapi_array_free(all_sessions, 1);
+ p11c_array_free(all_sessions, 1);
all_sessions = NULL;
- ckcapi_unlock_global();
+ p11c_unlock_global();
}
/* ----------------------------------------------------------------------------
@@ -489,11 +489,11 @@ ckcapi_session_cleanup_all()
*/
CK_RV
-ckcapi_session_get_object_data(CkCapiSession* sess, CkCapiObject* obj,
- CkCapiObjectData** objdata)
+p11c_session_get_object_data(P11cSession* sess, P11cObject* obj,
+ P11cObjectData** objdata)
{
CK_OBJECT_HANDLE id;
- CkCapiObjectData* newdata;
+ P11cObjectData* newdata;
CK_RV ret;
ASSERT(sess);
@@ -505,7 +505,7 @@ ckcapi_session_get_object_data(CkCapiSession* sess, CkCapiObject* obj,
id = obj->id;
- *objdata = ckcapi_hash_get(sess->object_data, ckcapi_hash_key(id));
+ *objdata = p11c_hash_get(sess->object_data, p11c_hash_key(id));
if(*objdata)
return CKR_OK;
@@ -516,7 +516,8 @@ ckcapi_session_get_object_data(CkCapiSession* sess, CkCapiObject* obj,
newdata->object = id;
ASSERT(newdata->data_funcs);
- if(!ckcapi_hash_set(sess->object_data, ckcapi_hash_key(id), newdata)) {
+ if(!p11c_hash_set(sess->object_data, p11c_hash_key(id), newdata))
+ {
object_data_release(newdata);
return CKR_HOST_MEMORY;
}
@@ -526,39 +527,39 @@ ckcapi_session_get_object_data(CkCapiSession* sess, CkCapiObject* obj,
}
void
-ckcapi_session_clear_object_data(CkCapiSession* sess, CkCapiObject* obj)
+p11c_session_clear_object_data(P11cSession* sess, P11cObject* obj)
{
- CkCapiObjectData* objdata;
+ P11cObjectData* objdata;
ASSERT(sess);
ASSERT(sess->object_data);
ASSERT(obj);
- objdata = (CkCapiObjectData*)ckcapi_hash_rem(sess->object_data, ckcapi_hash_key(obj->id));
+ objdata = (P11cObjectData*)p11c_hash_rem(sess->object_data, p11c_hash_key(obj->id));
if(objdata)
object_data_release(objdata);
}
void
-ckcapi_session_enum_object_data(CkCapiSession* sess,
- CkCapiEnumObjectData enum_func, void* arg)
+p11c_session_enum_object_data(P11cSession* sess,
+ P11cEnumObjectData enum_func, void* arg)
{
CK_OBJECT_HANDLE i, max;
- CkCapiObject* obj;
- CkCapiObjectData* objdata;
+ P11cObject* obj;
+ P11cObjectData* objdata;
ASSERT(sess);
ASSERT(sess->object_data);
ASSERT(enum_func);
- max = ckcapi_token_get_max_handle();
+ max = p11c_token_get_max_handle();
for(i = 0; i < max; ++i)
{
- objdata = (CkCapiObjectData*)ckcapi_hash_get(sess->object_data, ckcapi_hash_key(i));
+ objdata = (P11cObjectData*)p11c_hash_get(sess->object_data, p11c_hash_key(i));
if(!objdata)
continue;
- obj = ckcapi_token_lookup_object(sess->slot, i);
+ obj = p11c_token_lookup_object(sess->slot, i);
if(!obj)
continue;
@@ -567,23 +568,23 @@ ckcapi_session_enum_object_data(CkCapiSession* sess,
}
CK_RV
-ckcapi_session_get_object_data_for(CkCapiSession* sess, CK_OBJECT_HANDLE hand,
- CkCapiObjectData** objdata)
+p11c_session_get_object_data_for(P11cSession* sess, CK_OBJECT_HANDLE hand,
+ P11cObjectData** objdata)
{
- CkCapiObject* obj;
+ P11cObject* obj;
- obj = ckcapi_token_lookup_object(sess->slot, hand);
+ obj = p11c_token_lookup_object(sess->slot, hand);
if(!obj)
return CKR_OBJECT_HANDLE_INVALID;
- return ckcapi_session_get_object_data(sess, obj, objdata);
+ return p11c_session_get_object_data(sess, obj, objdata);
}
void
-ckcapi_session_take_object_data(CkCapiSession* sess, CkCapiObject* obj,
- CkCapiObjectData* objdata)
+p11c_session_take_object_data(P11cSession* sess, P11cObject* obj,
+ P11cObjectData* objdata)
{
- CkCapiObjectData* prev;
+ P11cObjectData* prev;
ASSERT(obj);
ASSERT(sess);
@@ -592,11 +593,11 @@ ckcapi_session_take_object_data(CkCapiSession* sess, CkCapiObject* obj,
ASSERT(objdata);
objdata->object = obj->id;
- prev = ckcapi_hash_rem(sess->object_data, ckcapi_hash_key(obj->id));
+ prev = p11c_hash_rem(sess->object_data, p11c_hash_key(obj->id));
if(prev)
object_data_release(prev);
- if(!ckcapi_hash_set(sess->object_data, ckcapi_hash_key(obj->id), objdata))
+ if(!p11c_hash_set(sess->object_data, p11c_hash_key(obj->id), objdata))
object_data_release(objdata);
}
@@ -607,7 +608,7 @@ ckcapi_session_take_object_data(CkCapiSession* sess, CkCapiObject* obj,
static BOOL
get_ulong_attribute(CK_ATTRIBUTE_TYPE type, CK_ATTRIBUTE_PTR templ,
- CK_ULONG count, CK_ULONG* val)
+ CK_ULONG count, CK_ULONG* val)
{
CK_ULONG i;
@@ -627,8 +628,8 @@ get_ulong_attribute(CK_ATTRIBUTE_TYPE type, CK_ATTRIBUTE_PTR templ,
}
static CK_RV
-gather_objects(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
- CK_ULONG count, CkCapiArray* arr)
+gather_objects(P11cSession* sess, CK_ATTRIBUTE_PTR match,
+ CK_ULONG count, P11cArray* arr)
{
CK_OBJECT_CLASS ocls = CKO_ANY;
CK_RV ret = CKR_OK;
@@ -636,7 +637,7 @@ gather_objects(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
get_ulong_attribute(CKA_CLASS, match, count, &ocls);
/* Search for builtins */
- ret = ckcapi_builtin_find(sess, ocls, match, count, arr);
+ ret = p11c_builtin_find(sess, ocls, match, count, arr);
if(ret != CKR_OK)
return ret;
@@ -652,17 +653,17 @@ gather_objects(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
* The trust objects we expose also depend on the certificates
* loaded.
*/
- ret = ckcapi_cert_find(sess, ocls, match, count, arr);
+ ret = p11c_cert_find(sess, ocls, match, count, arr);
if(ret != CKR_OK)
return ret;
/* Search through trust objects */
- ret = ckcapi_trust_find(sess, ocls, match, count, arr);
+ ret = p11c_trust_find(sess, ocls, match, count, arr);
if(ret != CKR_OK)
return ret;
/* Search through key objects */
- ret = ckcapi_key_find(sess, ocls, match, count, arr);
+ ret = p11c_key_find(sess, ocls, match, count, arr);
if(ret != CKR_OK)
return ret;
@@ -670,51 +671,51 @@ gather_objects(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
}
void
-cleanup_find_operation(CkCapiSession* sess)
+cleanup_find_operation(P11cSession* sess)
{
ASSERT(sess->operation_type == OPERATION_FIND);
if(sess->operation_data)
- ckcapi_array_free((CkCapiArray*)sess->operation_data, TRUE);
+ p11c_array_free((P11cArray*)sess->operation_data, TRUE);
sess->operation_type = OPERATION_NONE;
sess->operation_data = NULL;
sess->operation_cancel = NULL;
}
void
-purge_duplicate_objects(CkCapiArray* arr)
+purge_duplicate_objects(P11cArray* arr)
{
- CkCapiHash* checks;
+ P11cHash* checks;
CK_OBJECT_HANDLE v;
size_t i;
- checks = ckcapi_hash_new(NULL, NULL);
+ checks = p11c_hash_new(NULL, NULL);
if(!checks)
return;
for(i = 0; i < arr->len; )
{
- v = ckcapi_array_index(arr, CK_OBJECT_HANDLE, i);
- if(ckcapi_hash_get(checks, ckcapi_hash_key(v)))
+ v = p11c_array_index(arr, CK_OBJECT_HANDLE, i);
+ if(p11c_hash_get(checks, p11c_hash_key(v)))
{
- ckcapi_array_remove_index(arr, i);
+ p11c_array_remove_index(arr, i);
/* Look at same i again */
}
else
{
- if(!ckcapi_hash_set(checks, ckcapi_hash_key(v), arr))
+ if(!p11c_hash_set(checks, p11c_hash_key(v), arr))
break;
++i;
}
}
- ckcapi_hash_free(checks, NULL);
+ p11c_hash_free(checks, NULL);
}
CK_RV
-ckcapi_session_find_init(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
- CK_ULONG count)
+p11c_session_find_init(P11cSession* sess, CK_ATTRIBUTE_PTR match,
+ CK_ULONG count)
{
- CkCapiArray* arr;
+ P11cArray* arr;
CK_RV ret;
ASSERT(sess);
@@ -723,14 +724,14 @@ ckcapi_session_find_init(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
if(sess->operation_type != OPERATION_NONE)
return CKR_OPERATION_ACTIVE;
- arr = ckcapi_array_new(0, 1, sizeof(CK_OBJECT_HANDLE));
+ arr = p11c_array_new(0, 1, sizeof(CK_OBJECT_HANDLE));
if(!arr)
return CKR_HOST_MEMORY;
ret = gather_objects(sess, match, count, arr);
if(ret != CKR_OK)
{
- ckcapi_array_free(arr, TRUE);
+ p11c_array_free(arr, TRUE);
return ret;
}
@@ -745,10 +746,10 @@ ckcapi_session_find_init(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
}
CK_RV
-ckcapi_session_find(CkCapiSession* sess, CK_OBJECT_HANDLE_PTR objects,
- CK_ULONG max_object_count, CK_ULONG_PTR object_count)
+p11c_session_find(P11cSession* sess, CK_OBJECT_HANDLE_PTR objects,
+ CK_ULONG max_object_count, CK_ULONG_PTR object_count)
{
- CkCapiArray* arr;
+ P11cArray* arr;
size_t i;
ASSERT(sess);
@@ -764,18 +765,18 @@ ckcapi_session_find(CkCapiSession* sess, CK_OBJECT_HANDLE_PTR objects,
return CKR_OK;
}
- arr = (CkCapiArray*)sess->operation_data;
+ arr = (P11cArray*)sess->operation_data;
*object_count = (max_object_count > arr->len ? arr->len : max_object_count);
for(i = 0; i < *object_count; ++i)
- objects[i] = ckcapi_array_index(arr, CK_OBJECT_HANDLE, i);
+ objects[i] = p11c_array_index(arr, CK_OBJECT_HANDLE, i);
- ckcapi_array_remove_range(arr, 0, *object_count);
+ p11c_array_remove_range(arr, 0, *object_count);
return CKR_OK;
}
CK_RV
-ckcapi_session_find_final(CkCapiSession* sess)
+p11c_session_find_final(P11cSession* sess)
{
ASSERT(sess);
@@ -794,13 +795,13 @@ ckcapi_session_find_final(CkCapiSession* sess)
typedef struct _CryptoContext
{
CK_MECHANISM_TYPE mech_type;
- CkCapiDestroyFunc mech_cleanup;
+ P11cDestroyFunc mech_cleanup;
void* mech_data;
}
CryptoContext;
void
-cleanup_crypto_operation(CkCapiSession* sess)
+cleanup_crypto_operation(P11cSession* sess)
{
CryptoContext* ctx;
@@ -818,8 +819,8 @@ cleanup_crypto_operation(CkCapiSession* sess)
}
CK_RV
-ckcapi_session_sign_init(CkCapiSession* sess, CK_MECHANISM_PTR mech,
- CkCapiObjectData *objdata)
+p11c_session_sign_init(P11cSession* sess, CK_MECHANISM_PTR mech,
+ P11cObjectData *objdata)
{
CryptoContext* ctx;
CK_RV ret;
@@ -840,8 +841,8 @@ ckcapi_session_sign_init(CkCapiSession* sess, CK_MECHANISM_PTR mech,
switch(mech->mechanism)
{
case CKM_RSA_PKCS:
- ret = ckcapi_rsa_pkcs_sign_init(objdata, &ctx->mech_data);
- ctx->mech_cleanup = ckcapi_rsa_pkcs_sign_cleanup;
+ ret = p11c_rsa_pkcs_sign_init(objdata, &ctx->mech_data);
+ ctx->mech_cleanup = p11c_rsa_pkcs_sign_cleanup;
break;
default:
ret = CKR_MECHANISM_INVALID;
@@ -862,8 +863,8 @@ ckcapi_session_sign_init(CkCapiSession* sess, CK_MECHANISM_PTR mech,
}
CK_RV
-ckcapi_session_sign(CkCapiSession* sess, CK_BYTE_PTR data, CK_ULONG n_data,
- CK_BYTE_PTR signature, CK_ULONG_PTR n_signature)
+p11c_session_sign(P11cSession* sess, CK_BYTE_PTR data, CK_ULONG n_data,
+ CK_BYTE_PTR signature, CK_ULONG_PTR n_signature)
{
CryptoContext *ctx;
BOOL incomplete;
@@ -880,8 +881,8 @@ ckcapi_session_sign(CkCapiSession* sess, CK_BYTE_PTR data, CK_ULONG n_data,
switch(ctx->mech_type)
{
case CKM_RSA_PKCS:
- ret = ckcapi_rsa_pkcs_sign_perform(data, n_data, signature, n_signature,
- &ctx->mech_data);
+ ret = p11c_rsa_pkcs_sign_perform(data, n_data, signature, n_signature,
+ &ctx->mech_data);
break;
default:
@@ -900,8 +901,8 @@ ckcapi_session_sign(CkCapiSession* sess, CK_BYTE_PTR data, CK_ULONG n_data,
}
CK_RV
-ckcapi_session_decrypt_init(CkCapiSession* sess, CK_MECHANISM_PTR mech,
- CkCapiObjectData *objdata)
+p11c_session_decrypt_init(P11cSession* sess, CK_MECHANISM_PTR mech,
+ P11cObjectData *objdata)
{
CryptoContext* ctx;
CK_RV ret;
@@ -922,8 +923,8 @@ ckcapi_session_decrypt_init(CkCapiSession* sess, CK_MECHANISM_PTR mech,
switch(mech->mechanism)
{
case CKM_RSA_PKCS:
- ret = ckcapi_rsa_pkcs_decrypt_init(objdata, &ctx->mech_data);
- ctx->mech_cleanup = ckcapi_rsa_pkcs_decrypt_cleanup;
+ ret = p11c_rsa_pkcs_decrypt_init(objdata, &ctx->mech_data);
+ ctx->mech_cleanup = p11c_rsa_pkcs_decrypt_cleanup;
break;
default:
ret = CKR_MECHANISM_INVALID;
@@ -944,8 +945,8 @@ ckcapi_session_decrypt_init(CkCapiSession* sess, CK_MECHANISM_PTR mech,
}
CK_RV
-ckcapi_session_decrypt(CkCapiSession* sess, CK_BYTE_PTR encdata, CK_ULONG n_encdata,
- CK_BYTE_PTR result, CK_ULONG_PTR n_result)
+p11c_session_decrypt(P11cSession* sess, CK_BYTE_PTR encdata, CK_ULONG n_encdata,
+ CK_BYTE_PTR result, CK_ULONG_PTR n_result)
{
CryptoContext *ctx;
BOOL incomplete;
@@ -962,8 +963,8 @@ ckcapi_session_decrypt(CkCapiSession* sess, CK_BYTE_PTR encdata, CK_ULONG n_enc
switch(ctx->mech_type)
{
case CKM_RSA_PKCS:
- ret = ckcapi_rsa_pkcs_decrypt_perform(encdata, n_encdata, result, n_result,
- &ctx->mech_data);
+ ret = p11c_rsa_pkcs_decrypt_perform(encdata, n_encdata, result, n_result,
+ &ctx->mech_data);
break;
default:
diff --git a/p11-capi-session.h b/p11-capi-session.h
new file mode 100644
index 0000000..8f84026
--- /dev/null
+++ b/p11-capi-session.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2007 Stef Walter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef P11C_SESSION_H
+#define P11C_SESSION_H
+
+#include "p11-capi.h"
+
+/* --------------------------------------------------------------------
+ *
+ * Session = P11cSession
+ * - A PKCS#11 Session
+ *
+ * Objects = P11cObject
+ * - There's a global list of objects in p11c-object.c indexed by
+ * object handle.
+ * - The object itself has no attributes or cached data, but knows how
+ * to load data when needed.
+ * - Each object has a unique key which guarantees we don't load the
+ * same object twice with two different object handles.
+ *
+ * Object Data = P11cObjectData
+ * - Object Data is owned by the Session
+ * - Loaded data and/or attributes for an object.
+ */
+
+/* Callback to cleanup a current operation */
+typedef void (*P11cSessionCancel) (struct _P11cSession* sess);
+
+/* Represents an open session */
+typedef struct _P11cSession
+{
+ CK_SESSION_HANDLE id; /* Unique ID for this session */
+ CK_SLOT_ID slot;
+ int in_call; /* Whether this session is use in PKCS#11 function */
+
+ HCERTSTORE store; /* Handle to an open certificate store */
+
+ BOOL read_write; /* A read-write session? */
+
+ int operation_type; /* Whether an operation is happening or not */
+ void* operation_data; /* Data for this operation */
+ P11cSessionCancel operation_cancel; /* Callback to cancel operation when necessary */
+
+ P11cHash* object_data;
+
+ 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 */
+}
+P11cSession;
+
+/* Debug print something related to a session */
+#define DBGS(sess, msg) \
+ p11c_debug("S%d: %s", (sess) ? (sess)->id : 0, (msg))
+
+/* Create a session */
+CK_RV p11c_session_create (CK_SLOT_ID slot, P11cSession** ret);
+
+/* Destroy a session */
+void p11c_session_destroy (P11cSession* sess);
+
+/* Register a new session */
+CK_RV p11c_session_register (P11cSession* sess);
+
+/* Get information about a session */
+void p11c_session_get_info (P11cSession* sess,
+ CK_SESSION_INFO_PTR info);
+
+/* Get a session from a handle, and lock it */
+CK_RV p11c_session_get_lock_ref (CK_ULONG id, BOOL writable,
+ P11cSession **sess);
+
+/* Get a session from a handle, remove it from list, and lock it */
+CK_RV p11c_session_remove_lock_ref (CK_ULONG id, P11cSession **sess);
+
+/* Unlock and unreference a session */
+void p11c_session_unref_unlock (P11cSession* sess);
+
+/* Close all sessions on a certain slot/token */
+CK_RV p11c_session_close_all (CK_SLOT_ID slot);
+
+
+
+/* Start a find operation on a session */
+CK_RV p11c_session_find_init (P11cSession* sess,
+ CK_ATTRIBUTE_PTR templ,
+ CK_ULONG count);
+
+/* Return results from a find operation */
+CK_RV p11c_session_find (P11cSession* sess,
+ CK_OBJECT_HANDLE_PTR objects,
+ CK_ULONG max_object_count,
+ CK_ULONG_PTR object_count);
+
+/* End a find operation */
+CK_RV p11c_session_find_final (P11cSession* sess);
+
+
+/* Start a sign operation on a session */
+CK_RV p11c_session_sign_init (P11cSession* sess,
+ CK_MECHANISM_PTR mech,
+ P11cObjectData *objdata);
+
+/* Perform sign operation */
+CK_RV p11c_session_sign (P11cSession* sess,
+ CK_BYTE_PTR data, CK_ULONG n_data,
+ CK_BYTE_PTR sig, CK_ULONG_PTR n_sig);
+
+/* Start a decrypt operation on a session */
+CK_RV p11c_session_decrypt_init (P11cSession* sess,
+ CK_MECHANISM_PTR mech,
+ P11cObjectData *objdata);
+
+/* Perform decrypt operation */
+CK_RV p11c_session_decrypt (P11cSession* sess,
+ CK_BYTE_PTR encdata, CK_ULONG n_encdata,
+ CK_BYTE_PTR result, CK_ULONG_PTR n_result);
+
+/* Get object data for an object */
+CK_RV p11c_session_get_object_data (P11cSession* sess,
+ P11cObject* obj,
+ P11cObjectData** objdata);
+
+/* Get object data for an object handle */
+CK_RV p11c_session_get_object_data_for (P11cSession* sess,
+ CK_OBJECT_HANDLE hand,
+ P11cObjectData** objdata);
+
+/* Set object data for an object */
+void p11c_session_take_object_data (P11cSession* sess,
+ P11cObject* obj,
+ P11cObjectData* objdata);
+
+/* Clear object data for an object */
+void p11c_session_clear_object_data (P11cSession* sess,
+ P11cObject* obj);
+
+/* Enumerate object data for all objects */
+typedef void (*P11cEnumObjectData) (P11cSession* sess,
+ P11cObject* obj,
+ P11cObjectData* data,
+ void* arg);
+
+void p11c_session_enum_object_data (P11cSession* sess,
+ P11cEnumObjectData enum_func,
+ void* arg);
+
+void p11c_session_cleanup_all (void);
+
+#endif /* P11C_SESSION_H */
diff --git a/ckcapi-token.c b/p11-capi-token.c
index c9b6f34..13a87d6 100644
--- a/ckcapi-token.c
+++ b/p11-capi-token.c
@@ -17,13 +17,13 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
-#include "ckcapi-object.h"
-#include "ckcapi-token.h"
+#include "p11-capi.h"
+#include "p11-capi-object.h"
+#include "p11-capi-token.h"
-static CkCapiArray* object_array = NULL;
-static CkCapiHash* object_hash = NULL;
-static CkCapiArray* logged_in_slots = NULL;
+static P11cArray* object_array = NULL;
+static P11cHash* object_hash = NULL;
+static P11cArray* logged_in_slots = NULL;
typedef struct _SlotInfo
{
@@ -36,14 +36,14 @@ SlotInfo;
#define SLOT_OFFSET 0x00001000
static SlotInfo slot_info[] = {
- { "My", "Personal Certificates", CKCAPI_SLOT_TRUSTED | CKCAPI_SLOT_CERTS },
- { "AddressBook", "Address Book Certificates", CKCAPI_SLOT_CERTS },
- { "CA", "Certificate Authorities", CKCAPI_SLOT_CA | CKCAPI_SLOT_CERTS },
- { "Root", "Root Authorities", CKCAPI_SLOT_TRUSTED | CKCAPI_SLOT_CA | CKCAPI_SLOT_CERTS },
- { "Trust", "Trust", CKCAPI_SLOT_CERTS },
- { "TrustedPeople", "Trusted People", CKCAPI_SLOT_TRUSTED | CKCAPI_SLOT_CERTS },
- { "AuthRoot", "Auth Root", CKCAPI_SLOT_CERTS },
- { NULL, "All User Keys", CKCAPI_SLOT_ANYKEY }
+ { "My", "Personal Certificates", P11c_SLOT_TRUSTED | P11c_SLOT_CERTS },
+ { "AddressBook", "Address Book Certificates", P11c_SLOT_CERTS },
+ { "CA", "Certificate Authorities", P11c_SLOT_CA | P11c_SLOT_CERTS },
+ { "Root", "Root Authorities", P11c_SLOT_TRUSTED | P11c_SLOT_CA | P11c_SLOT_CERTS },
+ { "Trust", "Trust", P11c_SLOT_CERTS },
+ { "TrustedPeople", "Trusted People", P11c_SLOT_TRUSTED | P11c_SLOT_CERTS },
+ { "AuthRoot", "Auth Root", P11c_SLOT_CERTS },
+ { NULL, "All User Keys", P11c_SLOT_ANYKEY }
};
#define SLOT_TO_OFFSET(slot) \
@@ -53,52 +53,52 @@ static SlotInfo slot_info[] = {
((offset) | SLOT_OFFSET)
unsigned int
-ckcapi_token_get_count(void)
+p11c_token_get_count(void)
{
return sizeof(slot_info) / sizeof(slot_info[0]);
}
CK_SLOT_ID
-ckcapi_token_get_slot_id(unsigned int offset)
+p11c_token_get_slot_id(unsigned int offset)
{
- ASSERT(offset < ckcapi_token_get_count());
+ ASSERT(offset < p11c_token_get_count());
return OFFSET_TO_SLOT(offset);
}
CK_BBOOL
-ckcapi_token_is_valid(CK_SLOT_ID slot)
+p11c_token_is_valid(CK_SLOT_ID slot)
{
unsigned int offset = SLOT_TO_OFFSET(slot);
- return offset >= 0 && offset < ckcapi_token_get_count();
+ return offset >= 0 && offset < p11c_token_get_count();
}
const char*
-ckcapi_token_get_display_name(CK_SLOT_ID slot)
+p11c_token_get_display_name(CK_SLOT_ID slot)
{
unsigned int offset = SLOT_TO_OFFSET(slot);
- ASSERT(ckcapi_token_is_valid(slot));
+ ASSERT(p11c_token_is_valid(slot));
ASSERT(slot_info[offset].display_name);
return slot_info[offset].display_name;
}
const char*
-ckcapi_token_get_store_name(CK_SLOT_ID slot)
+p11c_token_get_store_name(CK_SLOT_ID slot)
{
unsigned int offset = SLOT_TO_OFFSET(slot);
- ASSERT(ckcapi_token_is_valid(slot));
+ ASSERT(p11c_token_is_valid(slot));
return slot_info[offset].capi_store;
}
CK_ULONG
-ckcapi_token_get_flags(CK_SLOT_ID slot)
+p11c_token_get_flags(CK_SLOT_ID slot)
{
unsigned int offset = SLOT_TO_OFFSET(slot);
- ASSERT(ckcapi_token_is_valid(slot));
+ ASSERT(p11c_token_is_valid(slot));
return slot_info[offset].slot_flags;
}
static void
-object_free(CkCapiObject* obj)
+object_free(P11cObject* obj)
{
ASSERT(obj);
ASSERT(obj->obj_funcs);
@@ -107,15 +107,15 @@ object_free(CkCapiObject* obj)
}
void
-ckcapi_token_cleanup_all(void)
+p11c_token_cleanup_all(void)
{
size_t i;
- ckcapi_lock_global();
+ p11c_lock_global();
if(object_hash)
{
- ckcapi_hash_free(object_hash, NULL);
+ p11c_hash_free(object_hash, NULL);
object_hash = NULL;
}
@@ -123,47 +123,47 @@ ckcapi_token_cleanup_all(void)
{
for(i = 1; i < object_array->len; ++i)
{
- ASSERT(ckcapi_array_index(object_array, CkCapiObject*, i));
- object_free(ckcapi_array_index(object_array, CkCapiObject*, i));
+ ASSERT(p11c_array_index(object_array, P11cObject*, i));
+ object_free(p11c_array_index(object_array, P11cObject*, i));
}
- ckcapi_array_free(object_array, TRUE);
+ p11c_array_free(object_array, TRUE);
object_array = NULL;
}
if(logged_in_slots)
{
- ckcapi_array_free(logged_in_slots, TRUE);
+ p11c_array_free(logged_in_slots, TRUE);
logged_in_slots = NULL;
}
- ckcapi_unlock_global();
+ p11c_unlock_global();
}
CK_OBJECT_HANDLE
-ckcapi_token_get_max_handle(void)
+p11c_token_get_max_handle(void)
{
if(!object_array)
return 0;
return object_array->len;
}
-CkCapiObject*
-ckcapi_token_lookup_object(CK_SLOT_ID slot, CK_OBJECT_HANDLE obj)
+P11cObject*
+p11c_token_lookup_object(CK_SLOT_ID slot, CK_OBJECT_HANDLE obj)
{
/* This must be called without any locks held */
- CkCapiObject* ret = NULL;
+ P11cObject* ret = NULL;
ASSERT(slot);
ASSERT(obj > 0);
- ckcapi_lock_global();
+ p11c_lock_global();
if(object_array && obj < object_array->len)
- ret = ckcapi_array_index(object_array, CkCapiObject*, obj);
+ ret = p11c_array_index(object_array, P11cObject*, obj);
- ckcapi_unlock_global();
+ p11c_unlock_global();
/* Must belong to the right slot */
if(ret && ret->slot != slot)
@@ -175,8 +175,8 @@ ckcapi_token_lookup_object(CK_SLOT_ID slot, CK_OBJECT_HANDLE obj)
static unsigned int
object_hash_func(const void* a)
{
- CkCapiObject* obj = (CkCapiObject*)a;
- unsigned int hash = ckcapi_hash_pointer(obj->obj_funcs);
+ P11cObject* obj = (P11cObject*)a;
+ unsigned int hash = p11c_hash_pointer(obj->obj_funcs);
hash ^= (obj->obj_funcs->hash_object)(obj);
return hash;
}
@@ -184,8 +184,8 @@ object_hash_func(const void* a)
static int
object_equal_func(const void* a, const void* b)
{
- CkCapiObject* ca = (CkCapiObject*)a;
- CkCapiObject* cb = (CkCapiObject*)b;
+ P11cObject* ca = (P11cObject*)a;
+ P11cObject* cb = (P11cObject*)b;
if(ca == cb)
return 1;
if(ca->obj_funcs != cb->obj_funcs)
@@ -194,9 +194,9 @@ object_equal_func(const void* a, const void* b)
}
CK_RV
-ckcapi_token_register_object(CK_SLOT_ID slot, CkCapiObject* obj)
+p11c_token_register_object(CK_SLOT_ID slot, P11cObject* obj)
{
- CkCapiObject* prev;
+ P11cObject* prev;
CK_RV ret = CKR_OK;
ASSERT(slot);
@@ -204,19 +204,19 @@ ckcapi_token_register_object(CK_SLOT_ID slot, CkCapiObject* obj)
DBG(("registering object"));
- ckcapi_lock_global();
+ p11c_lock_global();
if(!object_array)
{
- object_array = ckcapi_array_sized_new(0, 1, sizeof(CkCapiObject*), 16);
+ object_array = p11c_array_sized_new(0, 1, sizeof(P11cObject*), 16);
if(object_array)
{
/* A blank entry for '0' */
- CkCapiObject* blank = NULL;
- ckcapi_array_append(object_array, blank);
+ P11cObject* blank = NULL;
+ p11c_array_append(object_array, blank);
}
- object_hash = ckcapi_hash_new(object_hash_func, object_equal_func);
+ object_hash = p11c_hash_new(object_hash_func, object_equal_func);
if(!object_array || !object_hash)
{
@@ -231,15 +231,15 @@ ckcapi_token_register_object(CK_SLOT_ID slot, CkCapiObject* obj)
ASSERT(object_hash);
/* Look in the hash and find a previous object */
- prev = ckcapi_hash_get(object_hash, obj);
+ prev = p11c_hash_get(object_hash, obj);
if(prev)
{
/* Register it in the previous object's place */
obj->id = prev->id;
ASSERT(prev->id < object_array->len);
- if(ckcapi_hash_set(object_hash, obj, obj))
+ if(p11c_hash_set(object_hash, obj, obj))
{
- ckcapi_array_index(object_array, CkCapiObject*, obj->id) = obj;
+ p11c_array_index(object_array, P11cObject*, obj->id) = obj;
object_free(prev);
DBGO(obj, "found old object id");
}
@@ -253,9 +253,9 @@ ckcapi_token_register_object(CK_SLOT_ID slot, CkCapiObject* obj)
/* Register it at the end of the array */
obj->id = object_array->len;
ASSERT(obj->id > 0);
- if(ckcapi_hash_set(object_hash, obj, obj))
+ if(p11c_hash_set(object_hash, obj, obj))
{
- if(ckcapi_array_append(object_array, obj))
+ if(p11c_array_append(object_array, obj))
{
DBGO(obj, "registered new object id");
}
@@ -264,7 +264,7 @@ ckcapi_token_register_object(CK_SLOT_ID slot, CkCapiObject* obj)
ret = CKR_HOST_MEMORY;
/* Roll back our addition */
- ckcapi_hash_rem(object_hash, obj);
+ p11c_hash_rem(object_hash, obj);
}
}
else
@@ -277,78 +277,78 @@ ckcapi_token_register_object(CK_SLOT_ID slot, CkCapiObject* obj)
if(ret == CKR_OK)
obj->slot = slot;
- ckcapi_unlock_global();
+ p11c_unlock_global();
return ret;
}
CK_BBOOL
-ckcapi_token_is_logged_in(CK_SLOT_ID slot)
+p11c_token_is_logged_in(CK_SLOT_ID slot)
{
unsigned int count, offset;
- ASSERT(ckcapi_token_is_valid(slot));
+ ASSERT(p11c_token_is_valid(slot));
if(!logged_in_slots)
return CK_FALSE;
offset = SLOT_TO_OFFSET(slot);
- count = ckcapi_token_get_count();
+ count = p11c_token_get_count();
ASSERT(logged_in_slots->len == count && offset < count);
- return ckcapi_array_index(logged_in_slots, CK_BBOOL, offset);
+ return p11c_array_index(logged_in_slots, CK_BBOOL, offset);
}
CK_RV
-ckcapi_token_login(CK_SLOT_ID slot)
+p11c_token_login(CK_SLOT_ID slot)
{
unsigned int i, count;
unsigned int offset;
CK_BBOOL value;
- ASSERT(ckcapi_token_is_valid(slot));
+ ASSERT(p11c_token_is_valid(slot));
offset = SLOT_TO_OFFSET(slot);
- count = ckcapi_token_get_count();
+ count = p11c_token_get_count();
if(!logged_in_slots)
{
- logged_in_slots = ckcapi_array_sized_new(0, 1, sizeof(CK_BBOOL), count);
+ logged_in_slots = p11c_array_sized_new(0, 1, sizeof(CK_BBOOL), count);
if(!logged_in_slots)
return CKR_HOST_MEMORY;
value = CK_FALSE;
for(i = 0; i < count; ++i)
- ckcapi_array_append(logged_in_slots, value);
+ p11c_array_append(logged_in_slots, value);
}
ASSERT(logged_in_slots->len == count && offset < count);
- if(ckcapi_array_index(logged_in_slots, CK_BBOOL, offset))
+ if(p11c_array_index(logged_in_slots, CK_BBOOL, offset))
return CKR_USER_ALREADY_LOGGED_IN;
- ckcapi_array_index(logged_in_slots, CK_BBOOL, offset) = CK_TRUE;
+ p11c_array_index(logged_in_slots, CK_BBOOL, offset) = CK_TRUE;
return CKR_OK;
}
CK_RV
-ckcapi_token_logout(CK_SLOT_ID slot)
+p11c_token_logout(CK_SLOT_ID slot)
{
unsigned int count, offset;
- ASSERT(ckcapi_token_is_valid(slot));
+ ASSERT(p11c_token_is_valid(slot));
if(!logged_in_slots)
return CKR_USER_NOT_LOGGED_IN;
offset = SLOT_TO_OFFSET(slot);
- count = ckcapi_token_get_count();
+ count = p11c_token_get_count();
ASSERT(logged_in_slots->len == count && offset < count);
- if(!ckcapi_array_index(logged_in_slots, CK_BBOOL, offset))
+ if(!p11c_array_index(logged_in_slots, CK_BBOOL, offset))
return CKR_USER_NOT_LOGGED_IN;
- ckcapi_array_index(logged_in_slots, CK_BBOOL, offset) = CK_FALSE;
+ p11c_array_index(logged_in_slots, CK_BBOOL, offset) = CK_FALSE;
return CKR_OK;
}
diff --git a/p11-capi-token.h b/p11-capi-token.h
new file mode 100644
index 0000000..e97f547
--- /dev/null
+++ b/p11-capi-token.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2007 Stef Walter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef P11C_TOKEN_H
+#define P11C_TOKEN_H
+
+#include "p11-capi.h"
+
+#define P11C_SLOT_CERTS 0x00000001
+#define P11C_SLOT_ANYKEY 0x00000002
+#define P11C_SLOT_CA 0x00000100
+#define P11C_SLOT_TRUSTED 0x00000200
+
+/* Register a new object, a handle will be assigned to obj->id */
+CK_RV p11c_token_register_object (CK_SLOT_ID slot, P11cObject* obj);
+
+/* Lookup an object for a given object handle */
+P11cObject* p11c_token_lookup_object (CK_SLOT_ID slot, CK_OBJECT_HANDLE obj);
+
+/* Clear all objects for all tokens. Only done when finalizing */
+void p11c_token_cleanup_all (void);
+
+/* Get the number of the maximum object handle currently in memory */
+CK_OBJECT_HANDLE p11c_token_get_max_handle (void);
+
+unsigned int p11c_token_get_count (void);
+
+CK_SLOT_ID p11c_token_get_slot_id (unsigned int index);
+
+CK_BBOOL p11c_token_is_valid (CK_SLOT_ID slot);
+
+const char* p11c_token_get_display_name (CK_SLOT_ID slot);
+
+const char* p11c_token_get_store_name (CK_SLOT_ID slot);
+
+CK_ULONG p11c_token_get_flags (CK_SLOT_ID slot);
+
+CK_RV p11c_token_login (CK_SLOT_ID slot);
+
+CK_RV p11c_token_logout (CK_SLOT_ID slot);
+
+CK_BBOOL p11c_token_is_logged_in (CK_SLOT_ID slot);
+
+#endif /* P11C_TOKEN_H */
diff --git a/ckcapi-trust.c b/p11-capi-trust.c
index 0449fc6..e8bab5f 100644
--- a/ckcapi-trust.c
+++ b/p11-capi-trust.c
@@ -17,12 +17,12 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi.h"
-#include "ckcapi-cert.h"
-#include "ckcapi-object.h"
-#include "ckcapi-session.h"
-#include "ckcapi-token.h"
-#include "ckcapi-trust.h"
+#include "p11-capi.h"
+#include "p11-capi-cert.h"
+#include "p11-capi-object.h"
+#include "p11-capi-session.h"
+#include "p11-capi-token.h"
+#include "p11-capi-trust.h"
#include "x509-usages.h"
#include "pkcs11/pkcs11n.h"
@@ -46,14 +46,14 @@
typedef struct _TrustObject
{
- CkCapiObject obj;
+ P11cObject obj;
CK_OBJECT_HANDLE cert_obj;
}
TrustObject;
typedef struct _TrustObjectData
{
- CkCapiObjectData base;
+ P11cObjectData base;
PCCERT_CONTEXT cert;
CERT_ENHKEY_USAGE* enhanced_usage;
@@ -95,7 +95,7 @@ has_enhanced_usage(TrustObjectData* tdata, const char* oid)
}
static CK_RV
-trust_bool_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+trust_bool_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
CK_BBOOL val;
@@ -138,11 +138,11 @@ trust_bool_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
return CKR_ATTRIBUTE_TYPE_INVALID;
};
- return ckcapi_return_data(attr, &val, sizeof(CK_BBOOL));
+ return p11c_return_data(attr, &val, sizeof(CK_BBOOL));
}
static CK_RV
-trust_ulong_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+trust_ulong_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
TrustObjectData* tdata = (TrustObjectData*)objdata;
CK_ULONG val;
@@ -218,11 +218,11 @@ trust_ulong_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
return CKR_ATTRIBUTE_TYPE_INVALID;
};
- return ckcapi_return_data(attr, &val, sizeof(CK_ULONG));
+ return p11c_return_data(attr, &val, sizeof(CK_ULONG));
}
static CK_RV
-trust_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
+trust_bytes_attribute(P11cObjectData* objdata, CK_ATTRIBUTE_PTR attr)
{
TrustObjectData* tdata = (TrustObjectData*)objdata;
@@ -239,7 +239,7 @@ trust_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
case CKA_SERIAL_NUMBER:
case CKA_LABEL:
ASSERT(tdata->cert);
- return ckcapi_cert_certificate_get_bytes(tdata->cert, attr);
+ return p11c_cert_certificate_get_bytes(tdata->cert, attr);
/*
* The hash of the DER encoded certificate.
@@ -247,10 +247,10 @@ trust_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
case CKA_CERT_MD5_HASH:
case CKA_CERT_SHA1_HASH:
if(!CryptHashCertificate(0, attr->type == CKA_CERT_MD5_HASH ? CALG_MD5 : CALG_SHA1,
- 0, tdata->cert->pbCertEncoded,
- tdata->cert->cbCertEncoded, attr->pValue,
- (DWORD*)(&attr->ulValueLen)))
- return ckcapi_winerr_to_ckr(GetLastError());
+ 0, tdata->cert->pbCertEncoded,
+ tdata->cert->cbCertEncoded, attr->pValue,
+ (DWORD*)(&attr->ulValueLen)))
+ return p11c_winerr_to_ckr(GetLastError());
return CKR_OK;
};
@@ -258,13 +258,13 @@ trust_bytes_attribute(CkCapiObjectData* objdata, CK_ATTRIBUTE_PTR attr)
}
static unsigned int
-trust_hash_func(CkCapiObject* obj)
+trust_hash_func(P11cObject* obj)
{
- return ckcapi_hash_integer(((TrustObject*)obj)->cert_obj);
+ return p11c_hash_integer(((TrustObject*)obj)->cert_obj);
}
static int
-trust_equal_func(CkCapiObject* a, CkCapiObject* b)
+trust_equal_func(P11cObject* a, P11cObject* b)
{
return ((TrustObject*)a)->cert_obj == ((TrustObject*)b)->cert_obj;
}
@@ -284,7 +284,7 @@ trust_release(void* data)
free(tdata);
}
-static const CkCapiObjectDataVtable trust_objdata_vtable = {
+static const P11cObjectDataVtable trust_objdata_vtable = {
trust_bool_attribute,
trust_ulong_attribute,
trust_bytes_attribute,
@@ -307,7 +307,7 @@ parse_usage(TrustObjectData* tdata, DWORD flags)
/* No enhanced_usage data is not an error */
if(err == CRYPT_E_NOT_FOUND)
return CKR_OK;
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
eusage = (CERT_ENHKEY_USAGE*)calloc(1, size);
@@ -320,7 +320,7 @@ parse_usage(TrustObjectData* tdata, DWORD flags)
err = GetLastError();
if(err == CRYPT_E_NOT_FOUND)
return CKR_OK;
- return ckcapi_winerr_to_ckr(err);
+ return p11c_winerr_to_ckr(err);
}
tdata->enhanced_usage = eusage;
@@ -341,17 +341,17 @@ parse_restrictions(TrustObjectData* tdata)
tdata->usage = 0x00;
ext = CertFindExtension(szOID_KEY_USAGE,
- tdata->cert->pCertInfo->cExtension,
- tdata->cert->pCertInfo->rgExtension);
+ tdata->cert->pCertInfo->cExtension,
+ tdata->cert->pCertInfo->rgExtension);
/* No key usage, don't care */
if(!ext)
return CKR_OK;
/* Find the size of the decoded structure */
- if(!CryptDecodeObject(CKCAPI_ENCODINGS, X509_KEY_USAGE,
- ext->Value.pbData, ext->Value.cbData, 0, NULL, &size))
- return ckcapi_winerr_to_ckr(GetLastError());
+ if(!CryptDecodeObject(P11c_ENCODINGS, X509_KEY_USAGE,
+ ext->Value.pbData, ext->Value.cbData, 0, NULL, &size))
+ return p11c_winerr_to_ckr(GetLastError());
/* Allocate enough memory */
rst = (CRYPT_BIT_BLOB*)calloc(1, size);
@@ -359,8 +359,8 @@ parse_restrictions(TrustObjectData* tdata)
return CKR_HOST_MEMORY;
/* And get the decoded structure */
- if(CryptDecodeObject(CKCAPI_ENCODINGS, X509_KEY_USAGE,
- ext->Value.pbData, ext->Value.cbData, 0, rst, &size))
+ if(CryptDecodeObject(P11c_ENCODINGS, X509_KEY_USAGE,
+ ext->Value.pbData, ext->Value.cbData, 0, rst, &size))
{
if(rst->cbData != 1 &&
rst->cUnusedBits != 0)
@@ -380,18 +380,18 @@ parse_restrictions(TrustObjectData* tdata)
}
static CK_RV
-trust_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objdata)
+trust_load_data(P11cSession* sess, P11cObject* obj, P11cObjectData** objdata)
{
TrustObject* tobj = (TrustObject*)obj;
TrustObjectData* tdata;
- CkCapiObjectData* certdata;
+ P11cObjectData* certdata;
CK_RV ret;
ASSERT(tobj);
ASSERT(objdata);
/* Get the raw data for the certificate */
- ret = ckcapi_session_get_object_data_for(sess, tobj->cert_obj, &certdata);
+ ret = p11c_session_get_object_data_for(sess, tobj->cert_obj, &certdata);
if(ret != CKR_OK)
return ret;
@@ -399,7 +399,7 @@ trust_load_data(CkCapiSession* sess, CkCapiObject* obj, CkCapiObjectData** objda
if(!tdata)
return CKR_HOST_MEMORY;
- tdata->cert = ckcapi_cert_object_data_get_certificate (certdata);
+ tdata->cert = p11c_cert_object_data_get_certificate (certdata);
ASSERT(tdata->cert);
/* Dig up the restrictions data extension */
@@ -440,7 +440,7 @@ trust_object_release(void* data)
free(tobj);
}
-static const CkCapiObjectVtable trust_object_vtable = {
+static const P11cObjectVtable trust_object_vtable = {
trust_load_data,
trust_hash_func,
trust_equal_func,
@@ -448,7 +448,7 @@ static const CkCapiObjectVtable trust_object_vtable = {
};
static CK_RV
-register_trust_object(CkCapiSession* sess, CkCapiObject* cert, CkCapiObject** obj)
+register_trust_object(P11cSession* sess, P11cObject* cert, P11cObject** obj)
{
TrustObject* tobj;
CK_RV ret;
@@ -462,7 +462,7 @@ register_trust_object(CkCapiSession* sess, CkCapiObject* cert, CkCapiObject** ob
tobj->obj.id = 0;
tobj->obj.obj_funcs = &trust_object_vtable;
- ret = ckcapi_token_register_object(sess->slot, &(tobj->obj));
+ ret = p11c_token_register_object(sess->slot, &(tobj->obj));
if(ret != CKR_OK)
{
free(tobj);
@@ -476,8 +476,8 @@ register_trust_object(CkCapiSession* sess, CkCapiObject* cert, CkCapiObject** ob
}
static CK_RV
-list_matching_certificates(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
- CK_ULONG count, CkCapiArray* arr)
+list_matching_certificates(P11cSession* sess, CK_ATTRIBUTE_PTR match,
+ CK_ULONG count, P11cArray* arr)
{
CK_OBJECT_CLASS cert_class = CKO_CERTIFICATE;
CK_ATTRIBUTE search[3];
@@ -507,18 +507,18 @@ list_matching_certificates(CkCapiSession* sess, CK_ATTRIBUTE_PTR match,
}
/* Do the certificate search */
- return ckcapi_cert_find(sess, CKO_CERTIFICATE, search, n_search, arr);
+ return p11c_cert_find(sess, CKO_CERTIFICATE, search, n_search, arr);
}
CK_RV
-ckcapi_trust_find(CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count, CkCapiArray* arr)
+p11c_trust_find(P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count, P11cArray* arr)
{
CK_OBJECT_HANDLE id;
- CkCapiObject* obj;
- CkCapiObject* certobj;
- CkCapiObjectData* objdata;
- CkCapiArray* certarr;
+ P11cObject* obj;
+ P11cObject* certobj;
+ P11cObjectData* objdata;
+ P11cArray* certarr;
CK_RV ret = CKR_OK;
CK_ULONG i;
@@ -527,11 +527,11 @@ ckcapi_trust_find(CkCapiSession* sess, CK_OBJECT_CLASS cls,
return CKR_OK;
/* Only work with slots that have certificates */
- if(!(ckcapi_token_get_flags (sess->slot) & CKCAPI_SLOT_CERTS))
+ if(!(p11c_token_get_flags (sess->slot) & P11c_SLOT_CERTS))
return CKR_OK;
/* Get a list of all certificates */
- certarr = ckcapi_array_new(0, 1, sizeof(CK_OBJECT_HANDLE));
+ certarr = p11c_array_new(0, 1, sizeof(CK_OBJECT_HANDLE));
if(!certarr)
return CKR_HOST_MEMORY;
ret = list_matching_certificates(sess, match, count, certarr);
@@ -541,10 +541,10 @@ ckcapi_trust_find(CkCapiSession* sess, CK_OBJECT_CLASS cls,
{
for(i = 0; i < certarr->len; ++i)
{
- id = ckcapi_array_index(certarr, CK_OBJECT_HANDLE, i);
+ id = p11c_array_index(certarr, CK_OBJECT_HANDLE, i);
ASSERT(id);
- certobj = ckcapi_token_lookup_object(sess->slot, id);
+ certobj = p11c_token_lookup_object(sess->slot, id);
ASSERT(certobj);
/* We'll register a trust object for any loaded certificate */
@@ -554,16 +554,16 @@ ckcapi_trust_find(CkCapiSession* sess, CK_OBJECT_CLASS cls,
ASSERT(obj);
- ret = ckcapi_session_get_object_data(sess, obj, &objdata);
+ ret = p11c_session_get_object_data(sess, obj, &objdata);
if(ret != CKR_OK)
break;
/* Only return new object if it matches */
- if(ckcapi_object_data_match(objdata, match, count))
- ckcapi_array_append(arr, obj->id);
+ if(p11c_object_data_match(objdata, match, count))
+ p11c_array_append(arr, obj->id);
}
}
- ckcapi_array_free(certarr, TRUE);
+ p11c_array_free(certarr, TRUE);
return ret;
}
diff --git a/ckcapi-trust.h b/p11-capi-trust.h
index f8d8bcc..639f2eb 100644
--- a/ckcapi-trust.h
+++ b/p11-capi-trust.h
@@ -17,14 +17,14 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef CKCAPI_TRUST_H
-#define CKCAPI_TRUST_H
+#ifndef P11C_TRUST_H
+#define P11C_TRUST_H
-#include "ckcapi.h"
+#include "p11-capi.h"
/* Find trust objects matching criteria */
-CK_RV ckcapi_trust_find (CkCapiSession* sess, CK_OBJECT_CLASS cls,
- CK_ATTRIBUTE_PTR match, CK_ULONG count,
- CkCapiArray* arr);
+CK_RV p11c_trust_find (P11cSession* sess, CK_OBJECT_CLASS cls,
+ CK_ATTRIBUTE_PTR match, CK_ULONG count,
+ P11cArray* arr);
-#endif /* CRYPTOKI_TRUST_H */
+#endif /* P11C_TRUST_H */
diff --git a/ckcapi-util.c b/p11-capi-util.c
index ae8c39b..5ebb72b 100644
--- a/ckcapi-util.c
+++ b/p11-capi-util.c
@@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA.
*/
-#include "ckcapi-util.h"
+#include "p11-capi-util.h"
#include <sys/types.h>
#include <stdlib.h>
@@ -25,7 +25,7 @@
void
-ckcapi_reverse_memory (void* data, size_t length)
+p11c_reverse_memory (void* data, size_t length)
{
size_t end = length - 1;
size_t middle = length / 2;
@@ -69,7 +69,7 @@ ckcapi_reverse_memory (void* data, size_t length)
typedef struct _RealArray
{
- CkCapiArray pub;
+ P11cArray pub;
size_t alloc;
size_t elt_size;
int zero_terminated : 1;
@@ -99,7 +99,7 @@ maybe_expand(RealArray *array, size_t len)
{
void* mem;
size_t want_alloc = array_elt_len(array, array->pub.len + len +
- array->zero_terminated);
+ array->zero_terminated);
if(want_alloc > array->alloc)
{
@@ -118,15 +118,15 @@ maybe_expand(RealArray *array, size_t len)
return 1;
}
-CkCapiArray*
-ckcapi_array_new(int zero_terminated, int clear, size_t elt_size)
+P11cArray*
+p11c_array_new(int zero_terminated, int clear, size_t elt_size)
{
- return ckcapi_array_sized_new(zero_terminated, clear, elt_size, 0);
+ return p11c_array_sized_new(zero_terminated, clear, elt_size, 0);
}
-CkCapiArray*
-ckcapi_array_sized_new(int zero_terminated, int clear, size_t elt_size,
- size_t reserved_size)
+P11cArray*
+p11c_array_sized_new(int zero_terminated, int clear, size_t elt_size,
+ size_t reserved_size)
{
RealArray *array = malloc(sizeof(RealArray));
if(!array)
@@ -145,11 +145,11 @@ ckcapi_array_sized_new(int zero_terminated, int clear, size_t elt_size,
array_zero_terminate(array);
}
- return (CkCapiArray*)array;
+ return (P11cArray*)array;
}
void*
-ckcapi_array_free(CkCapiArray* array, int free_segment)
+p11c_array_free(P11cArray* array, int free_segment)
{
void* segment;
@@ -170,14 +170,14 @@ ckcapi_array_free(CkCapiArray* array, int free_segment)
}
int
-ckcapi_array_append_vals(CkCapiArray* parray, const void* data, size_t len)
+p11c_array_append_vals(P11cArray* parray, const void* data, size_t len)
{
RealArray* array = (RealArray*)parray;
if(!maybe_expand(array, len))
return 0;
memcpy(array_elt_pos(array, array->pub.len), data,
- array_elt_len(array, len));
+ array_elt_len(array, len));
array->pub.len += len;
array_zero_terminate(array);
@@ -186,7 +186,7 @@ ckcapi_array_append_vals(CkCapiArray* parray, const void* data, size_t len)
}
void
-ckcapi_array_remove_index(CkCapiArray* parray, unsigned int index)
+p11c_array_remove_index(P11cArray* parray, unsigned int index)
{
RealArray* array = (RealArray*)parray;
@@ -204,7 +204,7 @@ ckcapi_array_remove_index(CkCapiArray* parray, unsigned int index)
}
void
-ckcapi_array_remove_range(CkCapiArray* parray, unsigned int index, size_t length)
+p11c_array_remove_range(P11cArray* parray, unsigned int index, size_t length)
{
RealArray *array = (RealArray*)parray;
@@ -217,8 +217,8 @@ ckcapi_array_remove_range(CkCapiArray* parray, unsigned int index, size_t length
if(index + length != array->pub.len)
memmove(array_elt_pos (array, index),
- array_elt_pos (array, index + length),
- (array->pub.len - (index + length)) * array->elt_size);
+ array_elt_pos (array, index + length),
+ (array->pub.len - (index + length)) * array->elt_size);
array->pub.len -= length;
array_elt_zero(array, array->pub.len, length);
@@ -271,11 +271,11 @@ HashEntry;
* The count of hash entries may be greater depending on the chosen
* collision rate.
*/
-struct _CkCapiHash
+struct _P11cHash
{
HashEntry** array;
- CkCapiHashFunc hash_func;
- CkCapiHashEqual equal_func;
+ P11cHashFunc hash_func;
+ P11cHashEqual equal_func;
size_t count;
size_t max;
};
@@ -294,18 +294,18 @@ equal_default(const void* a, const void* b)
*/
static HashEntry**
-alloc_array(CkCapiHash* ht, size_t max)
+alloc_array(P11cHash* ht, size_t max)
{
return calloc(1, sizeof(*(ht->array)) * (max + 1));
}
-CkCapiHash*
-ckcapi_hash_new(CkCapiHashFunc hash_func, CkCapiHashEqual equal_func)
+P11cHash*
+p11c_hash_new(P11cHashFunc hash_func, P11cHashEqual equal_func)
{
- CkCapiHash* ht = malloc(sizeof(CkCapiHash));
+ P11cHash* ht = malloc(sizeof(P11cHash));
if(ht)
{
- ht->hash_func = hash_func ? hash_func : ckcapi_hash_pointer;
+ ht->hash_func = hash_func ? hash_func : p11c_hash_pointer;
ht->equal_func = equal_func ? equal_func : equal_default;
ht->count = 0;
ht->max = INITIAL_MAX;
@@ -320,7 +320,7 @@ ckcapi_hash_new(CkCapiHashFunc hash_func, CkCapiHashEqual equal_func)
}
void
-ckcapi_hash_free(CkCapiHash* ht, CkCapiHashDestroy destroy_func)
+p11c_hash_free(P11cHash* ht, P11cHashDestroy destroy_func)
{
HashEntry* he;
HashEntry* next;
@@ -347,7 +347,7 @@ ckcapi_hash_free(CkCapiHash* ht, CkCapiHashDestroy destroy_func)
* Expanding a hash table
*/
static int
-expand_array(CkCapiHash* ht)
+expand_array(P11cHash* ht)
{
HashEntry** new_array;
size_t new_max;
@@ -364,7 +364,7 @@ expand_array(CkCapiHash* ht)
for(i = 0; i <= ht->max; ++i)
{
for(he = ht->array[i], next = he ? he->next : NULL;
- he != NULL; he = next, next = next ? next->next : NULL)
+ he != NULL; he = next, next = next ? next->next : NULL)
{
unsigned int j = he->hash & new_max;
he->next = new_array[j];
@@ -390,7 +390,7 @@ expand_array(CkCapiHash* ht)
*/
static HashEntry**
-find_entry(CkCapiHash* ht, const void* key, void* val)
+find_entry(P11cHash* ht, const void* key, void* val)
{
HashEntry** hep;
HashEntry* he;
@@ -400,7 +400,7 @@ find_entry(CkCapiHash* ht, const void* key, void* val)
/* scan linked list */
for(hep = &ht->array[hash & ht->max], he = *hep;
- he; hep = &he->next, he = *hep)
+ he; hep = &he->next, he = *hep)
{
if(he->hash == hash && (ht->equal_func)(he->key, key))
break;
@@ -427,7 +427,7 @@ find_entry(CkCapiHash* ht, const void* key, void* val)
}
void*
-ckcapi_hash_get(CkCapiHash* ht, const void *key)
+p11c_hash_get(P11cHash* ht, const void *key)
{
HashEntry** he = find_entry(ht, key, NULL);
if(he && *he)
@@ -437,7 +437,7 @@ ckcapi_hash_get(CkCapiHash* ht, const void *key)
}
int
-ckcapi_hash_set(CkCapiHash* ht, const void* key, void* val)
+p11c_hash_set(P11cHash* ht, const void* key, void* val)
{
HashEntry** hep = find_entry(ht, key, val);
if(hep && *hep)
@@ -460,7 +460,7 @@ ckcapi_hash_set(CkCapiHash* ht, const void* key, void* val)
}
void*
-ckcapi_hash_rem(CkCapiHash* ht, const void* key)
+p11c_hash_rem(P11cHash* ht, const void* key)
{
HashEntry** hep = find_entry(ht, key, NULL);
void* val = NULL;
@@ -478,19 +478,19 @@ ckcapi_hash_rem(CkCapiHash* ht, const void* key)
}
size_t
-ckcapi_hash_count(CkCapiHash* ht)
+p11c_hash_count(P11cHash* ht)
{
return ht->count;
}
unsigned int
-ckcapi_hash_pointer(const void* ptr)
+p11c_hash_pointer(const void* ptr)
{
return (unsigned int)ptr;
}
unsigned int
-ckcapi_hash_data(const void* data, size_t n_data)
+p11c_hash_data(const void* data, size_t n_data)
{
unsigned int hash = 0;
const unsigned char* end;
@@ -541,7 +541,7 @@ ckcapi_hash_data(const void* data, size_t n_data)
}
unsigned int
-ckcapi_hash_integer(int integer)
+p11c_hash_integer(int integer)
{
return integer;
}
diff --git a/p11-capi-util.h b/p11-capi-util.h
new file mode 100644
index 0000000..ed3507d
--- /dev/null
+++ b/p11-capi-util.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2007 Stef Walter
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __P11C_UTIL_H__
+#define __P11C_UTIL_H__
+
+#include <stdlib.h>
+
+
+void p11c_reverse_memory (void* data, size_t length);
+
+/* --------------------------------------------------------------------------------
+ * ARRAYS
+ */
+
+typedef struct _Array
+{
+ void* data;
+ size_t len;
+}
+P11cArray;
+
+#define p11c_array_append(a,v) p11c_array_append_vals(a, &(v), 1)
+#define p11c_array_index(a,t,i) (((t*) (a)->data) [(i)])
+
+P11cArray* p11c_array_new (int zero_terminated, int zero,
+ size_t element_size);
+
+P11cArray* p11c_array_sized_new (int zero_terminated, int zero,
+ size_t element_size, size_t reserved_size);
+
+void* p11c_array_free (P11cArray* array, int free_segment);
+
+int p11c_array_append_vals (P11cArray* array, const void* data,
+ size_t num);
+
+void p11c_array_remove_index (P11cArray* array, unsigned int index);
+
+void p11c_array_remove_range (P11cArray* array, unsigned int index,
+ size_t count);
+
+
+/* --------------------------------------------------------------------------------
+ * HASHTABLE
+ */
+
+struct _P11cHash;
+typedef struct _P11cHash P11cHash;
+
+typedef unsigned int (*P11cHashFunc)(const void* key);
+
+typedef int (*P11cHashEqual)(const void* a, const void* b);
+
+typedef void (*P11cHashDestroy)(void* val);
+
+P11cHash* p11c_hash_new (P11cHashFunc hash_func, P11cHashEqual equal_func);
+
+void p11c_hash_free (P11cHash* ht, P11cHashDestroy destroy_func);
+
+size_t p11c_hash_count (P11cHash* ht);
+
+void* p11c_hash_get (P11cHash* ht, const void* key);
+
+int p11c_hash_set (P11cHash* ht, const void* key, void* val);
+
+void* p11c_hash_rem (P11cHash* ht, const void* key);
+
+unsigned int p11c_hash_pointer (const void* ptr);
+
+unsigned int p11c_hash_data (const void* data, size_t n_data);
+
+unsigned int p11c_hash_integer (int integer);
+
+#define p11c_hash_key(num) (((char*)NULL) + (size_t)(num))
+
+#endif /* __P11C_UTIL_H__ */
diff --git a/ckcapi.c b/p11-capi.c
index c0e6036..b5f7f62 100644
--- a/ckcapi.c
+++ b/p11-capi.c
@@ -21,11 +21,11 @@
#include <stdarg.h>
#include <stdio.h>
-#include "ckcapi.h"
-#include "ckcapi-object.h"
-#include "ckcapi-session.h"
-#include "ckcapi-rsa.h"
-#include "ckcapi-token.h"
+#include "p11-capi.h"
+#include "p11-capi-object.h"
+#include "p11-capi-session.h"
+#include "p11-capi-rsa.h"
+#include "p11-capi-token.h"
/* Warns about all the raw string usage in this file */
#pragma warning (disable : 4996)
@@ -61,7 +61,7 @@ static CK_MECHANISM_TYPE all_mechanisms[] = {
#define LINE 1024
void
-ckcapi_debug(const char* msg, ...)
+p11c_debug(const char* msg, ...)
{
char buf[LINE];
va_list va;
@@ -82,16 +82,16 @@ ckcapi_debug(const char* msg, ...)
/* Bah humbug, MSVC doesn't have __func__ */
#define ENTER(func) \
char* _func = #func; \
- ckcapi_debug("%s: enter", _func)
+ p11c_debug("%s: enter", _func)
#define RETURN(ret) \
- return (ckcapi_debug("%s: %d", _func, ret), ret)
+ return (p11c_debug("%s: %d", _func, ret), ret)
#define PREREQ(cond, ret) \
- if (!(cond)) { ckcapi_debug("%s: %s failed: %d", _func, #cond, ret); return ret; }
+ if (!(cond)) { p11c_debug("%s: %s failed: %d", _func, #cond, ret); return ret; }
void
-ckcapi_lock_global(void)
+p11c_lock_global(void)
{
DWORD r;
@@ -102,7 +102,7 @@ ckcapi_lock_global(void)
}
void
-ckcapi_unlock_global(void)
+p11c_unlock_global(void)
{
BOOL r;
@@ -113,7 +113,7 @@ ckcapi_unlock_global(void)
}
CK_RV
-ckcapi_winerr_to_ckr(DWORD werr)
+p11c_winerr_to_ckr(DWORD werr)
{
switch(werr)
{
@@ -126,10 +126,10 @@ ckcapi_winerr_to_ckr(DWORD werr)
break;
case ERROR_MORE_DATA:
return CKR_BUFFER_TOO_SMALL;
- case ERROR_INVALID_PARAMETER: /* these params were derived from the */
- case ERROR_INVALID_HANDLE: /* inputs, so if they are bad, the input */
- case NTE_BAD_ALGID: /* data is bad */
- case NTE_BAD_HASH:
+ case ERROR_INVALID_PARAMETER: /* these params were derived from the */
+ case ERROR_INVALID_HANDLE: /* inputs, so if they are bad, the input */
+ case NTE_BAD_ALGID: /* data is bad */
+ case NTE_BAD_HASH:
case NTE_BAD_TYPE:
case NTE_BAD_PUBLIC_KEY:
return CKR_DATA_INVALID;
@@ -143,8 +143,8 @@ ckcapi_winerr_to_ckr(DWORD werr)
}
CK_RV
-ckcapi_return_data_raw(CK_VOID_PTR output, CK_ULONG_PTR n_output,
- CK_VOID_PTR input, CK_ULONG n_input)
+p11c_return_data_raw(CK_VOID_PTR output, CK_ULONG_PTR n_output,
+ CK_VOID_PTR input, CK_ULONG n_input)
{
ASSERT(n_output);
ASSERT(input);
@@ -169,14 +169,14 @@ ckcapi_return_data_raw(CK_VOID_PTR output, CK_ULONG_PTR n_output,
}
CK_RV
-ckcapi_return_data(CK_ATTRIBUTE_PTR attr, CK_VOID_PTR input, DWORD n_input)
+p11c_return_data(CK_ATTRIBUTE_PTR attr, CK_VOID_PTR input, DWORD n_input)
{
- return ckcapi_return_data_raw(attr->pValue, &(attr->ulValueLen),
- input, n_input);
+ return p11c_return_data_raw(attr->pValue, &(attr->ulValueLen),
+ input, n_input);
}
CK_RV
-ckcapi_return_string(CK_ATTRIBUTE_PTR attr, WCHAR* string)
+p11c_return_string(CK_ATTRIBUTE_PTR attr, WCHAR* string)
{
CK_UTF8CHAR_PTR buffer;
int result;
@@ -189,7 +189,7 @@ ckcapi_return_string(CK_ATTRIBUTE_PTR attr, WCHAR* string)
* case this part.
*/
if(!string[0])
- return ckcapi_return_data(attr, "", 0);
+ return p11c_return_data(attr, "", 0);
/* The length of the string, including null termination */
result = WideCharToMultiByte(CP_UTF8, 0, string, -1,
@@ -246,7 +246,7 @@ ckcapi_return_string(CK_ATTRIBUTE_PTR attr, WCHAR* string)
}
CK_RV
-ckcapi_return_dword_as_bytes(CK_ATTRIBUTE_PTR attr, DWORD value)
+p11c_return_dword_as_bytes(CK_ATTRIBUTE_PTR attr, DWORD value)
{
int i;
CK_ULONG count = 0;
@@ -280,13 +280,13 @@ ckcapi_return_dword_as_bytes(CK_ATTRIBUTE_PTR attr, DWORD value)
}
CK_RV
-ckcapi_return_reversed_data(CK_ATTRIBUTE_PTR attr, CK_VOID_PTR data, CK_ULONG length)
+p11c_return_reversed_data(CK_ATTRIBUTE_PTR attr, CK_VOID_PTR data, CK_ULONG length)
{
- CK_RV ret = ckcapi_return_data(attr, data, length);
+ CK_RV ret = p11c_return_data(attr, data, length);
if(ret != CKR_OK || !attr->pValue)
return ret;
- ckcapi_reverse_memory(attr->pValue, attr->ulValueLen);
+ p11c_reverse_memory(attr->pValue, attr->ulValueLen);
return CKR_OK;
}
@@ -303,7 +303,7 @@ print_zero_decimal(CK_BYTE_PTR buffer, CK_ULONG length, WORD value)
}
CK_RV
-ckcapi_return_filetime(CK_ATTRIBUTE_PTR attr, FILETIME *ftime)
+p11c_return_filetime(CK_ATTRIBUTE_PTR attr, FILETIME *ftime)
{
SYSTEMTIME stime;
CK_DATE* date;
@@ -341,7 +341,7 @@ ckcapi_return_filetime(CK_ATTRIBUTE_PTR attr, FILETIME *ftime)
/* ---------------------------------------------------------------- */
static CK_RV
-CC_C_Initialize(CK_VOID_PTR init_args)
+PC_C_Initialize(CK_VOID_PTR init_args)
{
ENTER(C_Initialize);
PREREQ(!cryptoki_initialized, CKR_CRYPTOKI_ALREADY_INITIALIZED);
@@ -382,7 +382,7 @@ CC_C_Initialize(CK_VOID_PTR init_args)
}
static CK_RV
-CC_C_Finalize(CK_VOID_PTR pReserved)
+PC_C_Finalize(CK_VOID_PTR pReserved)
{
ENTER(C_Finalize);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -390,14 +390,14 @@ CC_C_Finalize(CK_VOID_PTR pReserved)
cryptoki_initialized = 0;
- ckcapi_session_cleanup_all();
- ckcapi_token_cleanup_all();
+ p11c_session_cleanup_all();
+ p11c_token_cleanup_all();
RETURN(CKR_OK);
}
static CK_RV
-CC_C_GetInfo(CK_INFO_PTR info)
+PC_C_GetInfo(CK_INFO_PTR info)
{
ENTER(C_GetInfo);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -418,14 +418,14 @@ CC_C_GetInfo(CK_INFO_PTR info)
}
static CK_RV
-CC_C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR list)
+PC_C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR list)
{
/* This would be a strange call to receive */
return C_GetFunctionList(list);
}
static CK_RV
-CC_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR slot_list, CK_ULONG_PTR count)
+PC_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR slot_list, CK_ULONG_PTR count)
{
unsigned int n_tokens, i;
@@ -435,7 +435,7 @@ CC_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR slot_list, CK_ULONG_PTR c
/* All tokens are always present */
- n_tokens = ckcapi_token_get_count();
+ n_tokens = p11c_token_get_count();
/* Application only wants to know the number of slots. */
if(slot_list == NULL)
@@ -452,12 +452,12 @@ CC_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR slot_list, CK_ULONG_PTR c
*count = n_tokens;
for(i = 0; i < n_tokens; ++i)
- slot_list[i] = ckcapi_token_get_slot_id (i);
+ slot_list[i] = p11c_token_get_slot_id (i);
RETURN(CKR_OK);
}
static CK_RV
-CC_C_GetSlotInfo(CK_SLOT_ID id, CK_SLOT_INFO_PTR info)
+PC_C_GetSlotInfo(CK_SLOT_ID id, CK_SLOT_INFO_PTR info)
{
const char* name;
@@ -466,7 +466,7 @@ CC_C_GetSlotInfo(CK_SLOT_ID id, CK_SLOT_INFO_PTR info)
PREREQ(info, CKR_ARGUMENTS_BAD);
/* Make sure the slot ID is valid */
- if(!ckcapi_token_is_valid(id))
+ if(!p11c_token_is_valid(id))
RETURN(CKR_SLOT_ID_INVALID);
ASSERT(strlen(MANUFACTURER_ID) == 32);
@@ -482,7 +482,7 @@ CC_C_GetSlotInfo(CK_SLOT_ID id, CK_SLOT_INFO_PTR info)
info->flags = CKF_TOKEN_PRESENT;
/* Slot name is blank padded, odd */
- name = ckcapi_token_get_display_name(id);
+ name = p11c_token_get_display_name(id);
memset((char*)info->slotDescription, ' ',
sizeof(info->slotDescription));
memcpy((char*)info->slotDescription, name,
@@ -492,7 +492,7 @@ CC_C_GetSlotInfo(CK_SLOT_ID id, CK_SLOT_INFO_PTR info)
}
static CK_RV
-CC_C_GetTokenInfo(CK_SLOT_ID id, CK_TOKEN_INFO_PTR info)
+PC_C_GetTokenInfo(CK_SLOT_ID id, CK_TOKEN_INFO_PTR info)
{
const char* name;
@@ -501,7 +501,7 @@ CC_C_GetTokenInfo(CK_SLOT_ID id, CK_TOKEN_INFO_PTR info)
PREREQ(info, CKR_ARGUMENTS_BAD);
/* Make sure the slot ID is valid */
- if(!ckcapi_token_is_valid(id))
+ if(!p11c_token_is_valid(id))
RETURN(CKR_SLOT_ID_INVALID);
ASSERT(strlen(MANUFACTURER_ID) == 32);
@@ -532,7 +532,7 @@ CC_C_GetTokenInfo(CK_SLOT_ID id, CK_TOKEN_INFO_PTR info)
memset(info->utcTime, ' ', 16);
/* Slot name is blank padded, odd */
- name = ckcapi_token_get_display_name(id);
+ name = p11c_token_get_display_name(id);
memset((char*)info->label, ' ', sizeof(info->label));
memcpy((char*)info->label, name,
min(strlen(name), sizeof(info->label)));
@@ -541,7 +541,7 @@ CC_C_GetTokenInfo(CK_SLOT_ID id, CK_TOKEN_INFO_PTR info)
}
static CK_RV
-CC_C_GetMechanismList(CK_SLOT_ID id, CK_MECHANISM_TYPE_PTR mechanism_list,
+PC_C_GetMechanismList(CK_SLOT_ID id, CK_MECHANISM_TYPE_PTR mechanism_list,
CK_ULONG_PTR count)
{
CK_ULONG n_mechs;
@@ -550,7 +550,7 @@ CC_C_GetMechanismList(CK_SLOT_ID id, CK_MECHANISM_TYPE_PTR mechanism_list,
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
PREREQ(count, CKR_ARGUMENTS_BAD);
- if(!ckcapi_token_is_valid(id))
+ if(!p11c_token_is_valid(id))
RETURN(CKR_SLOT_ID_INVALID);
n_mechs = sizeof(all_mechanisms) / sizeof(all_mechanisms[0]);
@@ -574,19 +574,19 @@ CC_C_GetMechanismList(CK_SLOT_ID id, CK_MECHANISM_TYPE_PTR mechanism_list,
}
static CK_RV
-CC_C_GetMechanismInfo(CK_SLOT_ID id, CK_MECHANISM_TYPE type,
+PC_C_GetMechanismInfo(CK_SLOT_ID id, CK_MECHANISM_TYPE type,
CK_MECHANISM_INFO_PTR info)
{
ENTER(C_GetMechanismInfo);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
PREREQ(info, CKR_ARGUMENTS_BAD);
- if(!ckcapi_token_is_valid(id))
+ if(!p11c_token_is_valid(id))
RETURN(CKR_SLOT_ID_INVALID);
if(type == CKM_RSA_PKCS)
{
- ckcapi_rsa_pkcs_get_info(type, info);
+ p11c_rsa_pkcs_get_info(type, info);
RETURN(CKR_OK);
}
@@ -594,7 +594,7 @@ CC_C_GetMechanismInfo(CK_SLOT_ID id, CK_MECHANISM_TYPE type,
}
static CK_RV
-CC_C_InitToken(CK_SLOT_ID slot_id, CK_UTF8CHAR_PTR pin, CK_ULONG pin_len,
+PC_C_InitToken(CK_SLOT_ID slot_id, CK_UTF8CHAR_PTR pin, CK_ULONG pin_len,
CK_UTF8CHAR_PTR label)
{
ENTER(C_InitToken);
@@ -603,7 +603,7 @@ CC_C_InitToken(CK_SLOT_ID slot_id, CK_UTF8CHAR_PTR pin, CK_ULONG pin_len,
}
static CK_RV
-CC_C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved)
+PC_C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved)
{
ENTER(C_WaitForSlotEvent);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -622,10 +622,10 @@ CC_C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserve
}
static CK_RV
-CC_C_OpenSession(CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR application,
+PC_C_OpenSession(CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR application,
CK_NOTIFY notify, CK_SESSION_HANDLE_PTR session)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_OpenSession);
@@ -633,10 +633,10 @@ CC_C_OpenSession(CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR application,
PREREQ(session, CKR_ARGUMENTS_BAD);
PREREQ(flags & CKF_SERIAL_SESSION, CKR_SESSION_PARALLEL_NOT_SUPPORTED);
- if(!ckcapi_token_is_valid(id))
+ if(!p11c_token_is_valid(id))
RETURN(CKR_SLOT_ID_INVALID);
- ret = ckcapi_session_create(id, &sess);
+ ret = p11c_session_create(id, &sess);
if(ret != CKR_OK)
RETURN(ret);
@@ -646,7 +646,7 @@ CC_C_OpenSession(CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR application,
if(flags & CKF_RW_SESSION)
sess->read_write = TRUE;
- ret = ckcapi_session_register(sess);
+ ret = p11c_session_register(sess);
if(ret == CKR_OK)
{
/* ID should have been assigned when registering */
@@ -655,46 +655,46 @@ CC_C_OpenSession(CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR application,
}
else
{
- ckcapi_session_destroy(sess);
+ p11c_session_destroy(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_CloseSession(CK_SESSION_HANDLE session)
+PC_C_CloseSession(CK_SESSION_HANDLE session)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_CloseSession);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
- ret = ckcapi_session_remove_lock_ref(session, &sess);
+ ret = p11c_session_remove_lock_ref(session, &sess);
if(ret == CKR_OK)
{
/* This will unref and possibly destroy the session */
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_CloseAllSessions(CK_SLOT_ID id)
+PC_C_CloseAllSessions(CK_SLOT_ID id)
{
ENTER(C_CloseAllSession);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
- if(!ckcapi_token_is_valid(id))
+ if(!p11c_token_is_valid(id))
RETURN(CKR_SLOT_ID_INVALID);
- ckcapi_session_close_all(id);
+ p11c_session_close_all(id);
RETURN(CKR_OK);
}
static CK_RV
-CC_C_GetFunctionStatus(CK_SESSION_HANDLE session)
+PC_C_GetFunctionStatus(CK_SESSION_HANDLE session)
{
ENTER(C_GetFunctionStatus);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -702,7 +702,7 @@ CC_C_GetFunctionStatus(CK_SESSION_HANDLE session)
}
static CK_RV
-CC_C_CancelFunction(CK_SESSION_HANDLE session)
+PC_C_CancelFunction(CK_SESSION_HANDLE session)
{
ENTER(C_CancelFunction);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -710,27 +710,27 @@ CC_C_CancelFunction(CK_SESSION_HANDLE session)
}
static CK_RV
-CC_C_GetSessionInfo(CK_SESSION_HANDLE session, CK_SESSION_INFO_PTR info)
+PC_C_GetSessionInfo(CK_SESSION_HANDLE session, CK_SESSION_INFO_PTR info)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_GetSessionInfo);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
PREREQ(info, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ckcapi_session_get_info(sess, info);
- ckcapi_session_unref_unlock(sess);
+ p11c_session_get_info(sess, info);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_InitPIN(CK_SESSION_HANDLE session, CK_UTF8CHAR_PTR pin,
+PC_C_InitPIN(CK_SESSION_HANDLE session, CK_UTF8CHAR_PTR pin,
CK_ULONG pin_len)
{
ENTER(C_InitPIN);
@@ -741,7 +741,7 @@ CC_C_InitPIN(CK_SESSION_HANDLE session, CK_UTF8CHAR_PTR pin,
}
static CK_RV
-CC_C_SetPIN(CK_SESSION_HANDLE session, CK_UTF8CHAR_PTR old_pin,
+PC_C_SetPIN(CK_SESSION_HANDLE session, CK_UTF8CHAR_PTR old_pin,
CK_ULONG old_len, CK_UTF8CHAR_PTR new_pin, CK_ULONG new_len)
{
ENTER(C_SetPIN);
@@ -752,7 +752,7 @@ CC_C_SetPIN(CK_SESSION_HANDLE session, CK_UTF8CHAR_PTR old_pin,
}
static CK_RV
-CC_C_GetOperationState(CK_SESSION_HANDLE session, CK_BYTE_PTR operation_state,
+PC_C_GetOperationState(CK_SESSION_HANDLE session, CK_BYTE_PTR operation_state,
CK_ULONG_PTR operation_state_len)
{
ENTER(C_GetOperationState);
@@ -763,7 +763,7 @@ CC_C_GetOperationState(CK_SESSION_HANDLE session, CK_BYTE_PTR operation_state,
}
static CK_RV
-CC_C_SetOperationState(CK_SESSION_HANDLE session, CK_BYTE_PTR operation_state,
+PC_C_SetOperationState(CK_SESSION_HANDLE session, CK_BYTE_PTR operation_state,
CK_ULONG operation_state_len, CK_OBJECT_HANDLE encryption_key,
CK_OBJECT_HANDLE authentication_key)
{
@@ -775,22 +775,22 @@ CC_C_SetOperationState(CK_SESSION_HANDLE session, CK_BYTE_PTR operation_state,
}
static CK_RV
-CC_C_Login(CK_SESSION_HANDLE session, CK_USER_TYPE user_type,
+PC_C_Login(CK_SESSION_HANDLE session, CK_USER_TYPE user_type,
CK_UTF8CHAR_PTR pin, CK_ULONG pin_len)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_Login);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
switch(user_type)
{
case CKU_USER:
- ret = ckcapi_token_login(sess->slot);
+ ret = p11c_token_login(sess->slot);
break;
case CKU_SO:
ret = CKR_USER_TYPE_INVALID;
@@ -800,33 +800,33 @@ CC_C_Login(CK_SESSION_HANDLE session, CK_USER_TYPE user_type,
break;
}
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_Logout(CK_SESSION_HANDLE session)
+PC_C_Logout(CK_SESSION_HANDLE session)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_Logout);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_token_logout(sess->slot);
- ckcapi_session_unref_unlock(sess);
+ ret = p11c_token_logout(sess->slot);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_CreateObject(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR templ,
+PC_C_CreateObject(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR templ,
CK_ULONG count, CK_OBJECT_HANDLE_PTR object)
{
ENTER(C_CreateObject);
@@ -837,7 +837,7 @@ CC_C_CreateObject(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR templ,
}
static CK_RV
-CC_C_CopyObject(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
+PC_C_CopyObject(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
CK_ATTRIBUTE_PTR templ, CK_ULONG count,
CK_OBJECT_HANDLE_PTR new_object)
{
@@ -850,7 +850,7 @@ CC_C_CopyObject(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
static CK_RV
-CC_C_DestroyObject(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
+PC_C_DestroyObject(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
{
ENTER(C_DestroyObject);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -860,7 +860,7 @@ CC_C_DestroyObject(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
}
static CK_RV
-CC_C_GetObjectSize(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
+PC_C_GetObjectSize(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
CK_ULONG_PTR size)
{
ENTER(C_GetObjectSize);
@@ -871,11 +871,11 @@ CC_C_GetObjectSize(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
}
static CK_RV
-CC_C_GetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
+PC_C_GetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
CK_ATTRIBUTE_PTR templ, CK_ULONG count)
{
- CkCapiSession* sess;
- CkCapiObjectData* objdata;
+ P11cSession* sess;
+ P11cObjectData* objdata;
CK_RV ret;
ENTER(C_GetAttributeValue);
@@ -883,21 +883,21 @@ CC_C_GetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
PREREQ(object, CKR_OBJECT_HANDLE_INVALID);
PREREQ(!count || templ, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_get_object_data_for(sess, object, &objdata);
+ ret = p11c_session_get_object_data_for(sess, object, &objdata);
if(ret == CKR_OK)
- ret = ckcapi_object_data_get_attrs(objdata, templ, count);
+ ret = p11c_object_data_get_attrs(objdata, templ, count);
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_SetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
+PC_C_SetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
CK_ATTRIBUTE_PTR templ, CK_ULONG count)
{
ENTER(C_SetAttributeValue);
@@ -908,31 +908,31 @@ CC_C_SetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
}
static CK_RV
-CC_C_FindObjectsInit(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR templ,
+PC_C_FindObjectsInit(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR templ,
CK_ULONG count)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_FindObjectsInit);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
PREREQ(!count || templ, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_find_init(sess, templ, count);
- ckcapi_session_unref_unlock(sess);
+ ret = p11c_session_find_init(sess, templ, count);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_FindObjects(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE_PTR objects,
+PC_C_FindObjects(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE_PTR objects,
CK_ULONG max_object_count, CK_ULONG_PTR object_count)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_FindObjects);
@@ -940,37 +940,37 @@ CC_C_FindObjects(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE_PTR objects,
PREREQ(object_count, CKR_ARGUMENTS_BAD);
PREREQ(!max_object_count || objects, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_find(sess, objects, max_object_count, object_count);
- ckcapi_session_unref_unlock(sess);
+ ret = p11c_session_find(sess, objects, max_object_count, object_count);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_FindObjectsFinal(CK_SESSION_HANDLE session)
+PC_C_FindObjectsFinal(CK_SESSION_HANDLE session)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_FindObjectsFinal);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_find_final(sess);
- ckcapi_session_unref_unlock(sess);
+ ret = p11c_session_find_final(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_EncryptInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_EncryptInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE key)
{
ENTER(C_EncryptInit);
@@ -981,7 +981,7 @@ CC_C_EncryptInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_Encrypt(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
+PC_C_Encrypt(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
CK_BYTE_PTR encrypted_data, CK_ULONG_PTR encrypted_data_len)
{
ENTER(C_Encrypt);
@@ -992,7 +992,7 @@ CC_C_Encrypt(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
}
static CK_RV
-CC_C_EncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
+PC_C_EncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
CK_ULONG part_len, CK_BYTE_PTR encrypted_part,
CK_ULONG_PTR encrypted_part_len)
{
@@ -1004,7 +1004,7 @@ CC_C_EncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
}
static CK_RV
-CC_C_EncryptFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR last_encrypted_part,
+PC_C_EncryptFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR last_encrypted_part,
CK_ULONG_PTR last_encrypted_part_len)
{
ENTER(C_EncryptFinal);
@@ -1015,11 +1015,11 @@ CC_C_EncryptFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR last_encrypted_part,
}
static CK_RV
-CC_C_DecryptInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_DecryptInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE key)
{
- CkCapiObjectData* objdata;
- CkCapiSession* sess;
+ P11cObjectData* objdata;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_DecryptInit);
@@ -1027,24 +1027,24 @@ CC_C_DecryptInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
PREREQ(mechanism, CKR_ARGUMENTS_BAD);
PREREQ(key, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_get_object_data_for(sess, key, &objdata);
+ ret = p11c_session_get_object_data_for(sess, key, &objdata);
if(ret == CKR_OK)
- ret = ckcapi_session_decrypt_init(sess, mechanism, objdata);
+ ret = p11c_session_decrypt_init(sess, mechanism, objdata);
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_Decrypt(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_data,
+PC_C_Decrypt(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_data,
CK_ULONG encrypted_data_len, CK_BYTE_PTR data, CK_ULONG_PTR data_len)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_Decrypt);
@@ -1052,19 +1052,19 @@ CC_C_Decrypt(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_data,
PREREQ(encrypted_data, CKR_ARGUMENTS_BAD);
PREREQ(encrypted_data_len, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_decrypt(sess, encrypted_data, encrypted_data_len,
+ ret = p11c_session_decrypt(sess, encrypted_data, encrypted_data_len,
data, data_len);
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_DecryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
+PC_C_DecryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
CK_ULONG encrypted_part_len, CK_BYTE_PTR part, CK_ULONG_PTR part_len)
{
ENTER(C_DecryptUpdate);
@@ -1075,7 +1075,7 @@ CC_C_DecryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
}
static CK_RV
-CC_C_DecryptFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR pLastPart,
+PC_C_DecryptFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR pLastPart,
CK_ULONG_PTR last_part_len)
{
ENTER(C_DecryptFinal);
@@ -1086,7 +1086,7 @@ CC_C_DecryptFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR pLastPart,
}
static CK_RV
-CC_C_DigestInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism)
+PC_C_DigestInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism)
{
ENTER(C_DigestInit);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -1096,7 +1096,7 @@ CC_C_DigestInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism)
}
static CK_RV
-CC_C_Digest(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
+PC_C_Digest(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
CK_BYTE_PTR digest, CK_ULONG_PTR digest_len)
{
ENTER(C_Digest);
@@ -1107,7 +1107,7 @@ CC_C_Digest(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
}
static CK_RV
-CC_C_DigestUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
+PC_C_DigestUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
{
ENTER(C_DigestUpdate);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -1117,7 +1117,7 @@ CC_C_DigestUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len
}
static CK_RV
-CC_C_DigestKey(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key)
+PC_C_DigestKey(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key)
{
ENTER(C_DigestKey);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -1127,7 +1127,7 @@ CC_C_DigestKey(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key)
}
static CK_RV
-CC_C_DigestFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR digest,
+PC_C_DigestFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR digest,
CK_ULONG_PTR digest_len)
{
ENTER(C_DigestFinal);
@@ -1138,11 +1138,11 @@ CC_C_DigestFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR digest,
}
static CK_RV
-CC_C_SignInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_SignInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE key)
{
- CkCapiObjectData* objdata;
- CkCapiSession* sess;
+ P11cObjectData* objdata;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_SignInit);
@@ -1150,24 +1150,24 @@ CC_C_SignInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
PREREQ(mechanism, CKR_ARGUMENTS_BAD);
PREREQ(key, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_get_object_data_for(sess, key, &objdata);
+ ret = p11c_session_get_object_data_for(sess, key, &objdata);
if(ret == CKR_OK)
- ret = ckcapi_session_sign_init(sess, mechanism, objdata);
+ ret = p11c_session_sign_init(sess, mechanism, objdata);
- ckcapi_session_unref_unlock(sess);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_Sign(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
+PC_C_Sign(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
CK_BYTE_PTR signature, CK_ULONG_PTR signature_len)
{
- CkCapiSession* sess;
+ P11cSession* sess;
CK_RV ret;
ENTER(C_Sign);
@@ -1175,18 +1175,18 @@ CC_C_Sign(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
PREREQ(data, CKR_ARGUMENTS_BAD);
PREREQ(data_len, CKR_ARGUMENTS_BAD);
- ret = ckcapi_session_get_lock_ref(session, FALSE, &sess);
+ ret = p11c_session_get_lock_ref(session, FALSE, &sess);
if(ret == CKR_OK)
{
- ret = ckcapi_session_sign(sess, data, data_len, signature, signature_len);
- ckcapi_session_unref_unlock(sess);
+ ret = p11c_session_sign(sess, data, data_len, signature, signature_len);
+ p11c_session_unref_unlock(sess);
}
RETURN(ret);
}
static CK_RV
-CC_C_SignUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
+PC_C_SignUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
{
ENTER(C_SignUpdate);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -1196,7 +1196,7 @@ CC_C_SignUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
}
static CK_RV
-CC_C_SignFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
+PC_C_SignFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
CK_ULONG_PTR signature_len)
{
ENTER(C_SignFinal);
@@ -1207,7 +1207,7 @@ CC_C_SignFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
}
static CK_RV
-CC_C_SignRecoverInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_SignRecoverInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE key)
{
ENTER(C_SignRecoverInit);
@@ -1218,7 +1218,7 @@ CC_C_SignRecoverInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_SignRecover(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
+PC_C_SignRecover(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
CK_BYTE_PTR signature, CK_ULONG_PTR signature_len)
{
ENTER(C_SignRecover);
@@ -1229,7 +1229,7 @@ CC_C_SignRecover(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
}
static CK_RV
-CC_C_VerifyInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_VerifyInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE key)
{
ENTER(C_VerifyInit);
@@ -1240,7 +1240,7 @@ CC_C_VerifyInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_Verify(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
+PC_C_Verify(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
CK_BYTE_PTR signature, CK_ULONG signature_len)
{
ENTER(C_Verify);
@@ -1251,7 +1251,7 @@ CC_C_Verify(CK_SESSION_HANDLE session, CK_BYTE_PTR data, CK_ULONG data_len,
}
static CK_RV
-CC_C_VerifyUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
+PC_C_VerifyUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len)
{
ENTER(C_VerifyUpdate);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -1261,7 +1261,7 @@ CC_C_VerifyUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part, CK_ULONG part_len
}
static CK_RV
-CC_C_VerifyFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
+PC_C_VerifyFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
CK_ULONG signature_len)
{
ENTER(C_VerifyFinal);
@@ -1272,7 +1272,7 @@ CC_C_VerifyFinal(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
}
static CK_RV
-CC_C_VerifyRecoverInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_VerifyRecoverInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE key)
{
ENTER(C_VerifyRecoverInit);
@@ -1283,7 +1283,7 @@ CC_C_VerifyRecoverInit(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_VerifyRecover(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
+PC_C_VerifyRecover(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
CK_ULONG signature_len, CK_BYTE_PTR data, CK_ULONG_PTR data_len)
{
ENTER(C_VerifyRecover);
@@ -1294,7 +1294,7 @@ CC_C_VerifyRecover(CK_SESSION_HANDLE session, CK_BYTE_PTR signature,
}
static CK_RV
-CC_C_DigestEncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
+PC_C_DigestEncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
CK_ULONG part_len, CK_BYTE_PTR encrypted_part,
CK_ULONG_PTR encrypted_part_len)
{
@@ -1306,7 +1306,7 @@ CC_C_DigestEncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
}
static CK_RV
-CC_C_DecryptDigestUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
+PC_C_DecryptDigestUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
CK_ULONG encrypted_part_len, CK_BYTE_PTR part,
CK_ULONG_PTR part_len)
{
@@ -1318,7 +1318,7 @@ CC_C_DecryptDigestUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
}
static CK_RV
-CC_C_SignEncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
+PC_C_SignEncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
CK_ULONG part_len, CK_BYTE_PTR encrypted_part,
CK_ULONG_PTR encrypted_part_len)
{
@@ -1330,7 +1330,7 @@ CC_C_SignEncryptUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR part,
}
static CK_RV
-CC_C_DecryptVerifyUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
+PC_C_DecryptVerifyUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
CK_ULONG encrypted_part_len, CK_BYTE_PTR part,
CK_ULONG_PTR part_len)
{
@@ -1342,7 +1342,7 @@ CC_C_DecryptVerifyUpdate(CK_SESSION_HANDLE session, CK_BYTE_PTR encrypted_part,
}
static CK_RV
-CC_C_GenerateKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_GenerateKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_ATTRIBUTE_PTR templ, CK_ULONG count,
CK_OBJECT_HANDLE_PTR key)
{
@@ -1354,7 +1354,7 @@ CC_C_GenerateKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_GenerateKeyPair(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_GenerateKeyPair(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_ATTRIBUTE_PTR public_key_template, CK_ULONG public_key_attribute_count,
CK_ATTRIBUTE_PTR private_key_template, CK_ULONG private_key_attribute_count,
CK_OBJECT_HANDLE_PTR public_key, CK_OBJECT_HANDLE_PTR private_key)
@@ -1367,7 +1367,7 @@ CC_C_GenerateKeyPair(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_WrapKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_WrapKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE wrapping_key, CK_OBJECT_HANDLE key,
CK_BYTE_PTR wrapped_key, CK_ULONG_PTR wrapped_key_len)
{
@@ -1379,7 +1379,7 @@ CC_C_WrapKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_UnwrapKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_UnwrapKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE unwrapping_key, CK_BYTE_PTR wrapped_key,
CK_ULONG wrapped_key_len, CK_ATTRIBUTE_PTR templ,
CK_ULONG count, CK_OBJECT_HANDLE_PTR key)
@@ -1392,7 +1392,7 @@ CC_C_UnwrapKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_DeriveKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
+PC_C_DeriveKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
CK_OBJECT_HANDLE base_key, CK_ATTRIBUTE_PTR templ,
CK_ULONG count, CK_OBJECT_HANDLE_PTR key)
{
@@ -1404,7 +1404,7 @@ CC_C_DeriveKey(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
}
static CK_RV
-CC_C_SeedRandom(CK_SESSION_HANDLE session, CK_BYTE_PTR seed, CK_ULONG seed_len)
+PC_C_SeedRandom(CK_SESSION_HANDLE session, CK_BYTE_PTR seed, CK_ULONG seed_len)
{
ENTER(C_SeedRandom);
PREREQ(cryptoki_initialized, CKR_CRYPTOKI_NOT_INITIALIZED);
@@ -1418,7 +1418,7 @@ CC_C_SeedRandom(CK_SESSION_HANDLE session, CK_BYTE_PTR seed, CK_ULONG seed_len)
}
static CK_RV
-CC_C_GenerateRandom(CK_SESSION_HANDLE session, CK_BYTE_PTR random_data,
+PC_C_GenerateRandom(CK_SESSION_HANDLE session, CK_BYTE_PTR random_data,
CK_ULONG random_len)
{
ENTER(C_GenerateRandom);
@@ -1434,74 +1434,74 @@ CC_C_GenerateRandom(CK_SESSION_HANDLE session, CK_BYTE_PTR random_data,
static CK_FUNCTION_LIST functionList = {
{ 2, 11 }, /* version */
- CC_C_Initialize,
- CC_C_Finalize,
- CC_C_GetInfo,
- CC_C_GetFunctionList,
- CC_C_GetSlotList,
- CC_C_GetSlotInfo,
- CC_C_GetTokenInfo,
- CC_C_GetMechanismList,
- CC_C_GetMechanismInfo,
- CC_C_InitToken,
- CC_C_InitPIN,
- CC_C_SetPIN,
- CC_C_OpenSession,
- CC_C_CloseSession,
- CC_C_CloseAllSessions,
- CC_C_GetSessionInfo,
- CC_C_GetOperationState,
- CC_C_SetOperationState,
- CC_C_Login,
- CC_C_Logout,
- CC_C_CreateObject,
- CC_C_CopyObject,
- CC_C_DestroyObject,
- CC_C_GetObjectSize,
- CC_C_GetAttributeValue,
- CC_C_SetAttributeValue,
- CC_C_FindObjectsInit,
- CC_C_FindObjects,
- CC_C_FindObjectsFinal,
- CC_C_EncryptInit,
- CC_C_Encrypt,
- CC_C_EncryptUpdate,
- CC_C_EncryptFinal,
- CC_C_DecryptInit,
- CC_C_Decrypt,
- CC_C_DecryptUpdate,
- CC_C_DecryptFinal,
- CC_C_DigestInit,
- CC_C_Digest,
- CC_C_DigestUpdate,
- CC_C_DigestKey,
- CC_C_DigestFinal,
- CC_C_SignInit,
- CC_C_Sign,
- CC_C_SignUpdate,
- CC_C_SignFinal,
- CC_C_SignRecoverInit,
- CC_C_SignRecover,
- CC_C_VerifyInit,
- CC_C_Verify,
- CC_C_VerifyUpdate,
- CC_C_VerifyFinal,
- CC_C_VerifyRecoverInit,
- CC_C_VerifyRecover,
- CC_C_DigestEncryptUpdate,
- CC_C_DecryptDigestUpdate,
- CC_C_SignEncryptUpdate,
- CC_C_DecryptVerifyUpdate,
- CC_C_GenerateKey,
- CC_C_GenerateKeyPair,
- CC_C_WrapKey,
- CC_C_UnwrapKey,
- CC_C_DeriveKey,
- CC_C_SeedRandom,
- CC_C_GenerateRandom,
- CC_C_GetFunctionStatus,
- CC_C_CancelFunction,
- CC_C_WaitForSlotEvent
+ PC_C_Initialize,
+ PC_C_Finalize,
+ PC_C_GetInfo,
+ PC_C_GetFunctionList,
+ PC_C_GetSlotList,
+ PC_C_GetSlotInfo,
+ PC_C_GetTokenInfo,
+ PC_C_GetMechanismList,
+ PC_C_GetMechanismInfo,
+ PC_C_InitToken,
+ PC_C_InitPIN,
+ PC_C_SetPIN,
+ PC_C_OpenSession,
+ PC_C_CloseSession,
+ PC_C_CloseAllSessions,
+ PC_C_GetSessionInfo,
+ PC_C_GetOperationState,
+ PC_C_SetOperationState,
+ PC_C_Login,
+ PC_C_Logout,
+ PC_C_CreateObject,
+ PC_C_CopyObject,
+ PC_C_DestroyObject,
+ PC_C_GetObjectSize,
+ PC_C_GetAttributeValue,
+ PC_C_SetAttributeValue,
+ PC_C_FindObjectsInit,
+ PC_C_FindObjects,
+ PC_C_FindObjectsFinal,
+ PC_C_EncryptInit,
+ PC_C_Encrypt,
+ PC_C_EncryptUpdate,
+ PC_C_EncryptFinal,
+ PC_C_DecryptInit,
+ PC_C_Decrypt,
+ PC_C_DecryptUpdate,
+ PC_C_DecryptFinal,
+ PC_C_DigestInit,
+ PC_C_Digest,
+ PC_C_DigestUpdate,
+ PC_C_DigestKey,
+ PC_C_DigestFinal,
+ PC_C_SignInit,
+ PC_C_Sign,
+ PC_C_SignUpdate,
+ PC_C_SignFinal,
+ PC_C_SignRecoverInit,
+ PC_C_SignRecover,
+ PC_C_VerifyInit,
+ PC_C_Verify,
+ PC_C_VerifyUpdate,
+ PC_C_VerifyFinal,
+ PC_C_VerifyRecoverInit,
+ PC_C_VerifyRecover,
+ PC_C_DigestEncryptUpdate,
+ PC_C_DecryptDigestUpdate,
+ PC_C_SignEncryptUpdate,
+ PC_C_DecryptVerifyUpdate,
+ PC_C_GenerateKey,
+ PC_C_GenerateKeyPair,
+ PC_C_WrapKey,
+ PC_C_UnwrapKey,
+ PC_C_DeriveKey,
+ PC_C_SeedRandom,
+ PC_C_GenerateRandom,
+ PC_C_GetFunctionStatus,
+ PC_C_CancelFunction,
+ PC_C_WaitForSlotEvent
};
__declspec(dllexport) CK_RV
diff --git a/ckcapi.dep b/p11-capi.dep
index 0b2cf80..c04832a 100644
--- a/ckcapi.dep
+++ b/p11-capi.dep
@@ -1,9 +1,9 @@
-# Microsoft Developer Studio Generated Dependency File, included by ckcapi.mak
+# Microsoft Developer Studio Generated Dependency File, included by p11c.mak
-".\ckcapi-builtin.c" : \
+".\p11-capi-builtin.c" : \
"..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
- ".\ckcapi-util.h"\
- ".\ckcapi.h"\
+ ".\p11-capi-util.h"\
+ ".\p11-capi.h"\
".\pkcs11\cryptoki.h"\
".\pkcs11\pkcs11.h"\
".\pkcs11\pkcs11f.h"\
@@ -11,20 +11,20 @@
".\pkcs11\pkcs11t.h"\
-".\ckcapi-cert.c" : \
+".\p11-capi-cert.c" : \
"..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
- ".\ckcapi-util.h"\
- ".\ckcapi.h"\
+ ".\p11-capi-util.h"\
+ ".\p11-capi.h"\
".\pkcs11\cryptoki.h"\
".\pkcs11\pkcs11.h"\
".\pkcs11\pkcs11f.h"\
".\pkcs11\pkcs11t.h"\
-".\ckcapi-object.c" : \
+".\p11-capi-object.c" : \
"..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
- ".\ckcapi-util.h"\
- ".\ckcapi.h"\
+ ".\p11-capi-util.h"\
+ ".\p11-capi.h"\
".\pkcs11\cryptoki.h"\
".\pkcs11\pkcs11.h"\
".\pkcs11\pkcs11f.h"\
@@ -32,20 +32,20 @@
".\pkcs11\pkcs11t.h"\
-".\ckcapi-session.c" : \
+".\p11-capi-session.c" : \
"..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
- ".\ckcapi-util.h"\
- ".\ckcapi.h"\
+ ".\p11-capi-util.h"\
+ ".\p11-capi.h"\
".\pkcs11\cryptoki.h"\
".\pkcs11\pkcs11.h"\
".\pkcs11\pkcs11f.h"\
".\pkcs11\pkcs11t.h"\
-".\ckcapi-trust.c" : \
+".\p11-capi-trust.c" : \
"..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
- ".\ckcapi-util.h"\
- ".\ckcapi.h"\
+ ".\p11-capi-util.h"\
+ ".\p11-capi.h"\
".\pkcs11\cryptoki.h"\
".\pkcs11\pkcs11.h"\
".\pkcs11\pkcs11f.h"\
@@ -54,14 +54,14 @@
".\x509-usages.h"\
-".\ckcapi-util.c" : \
- ".\ckcapi-util.h"\
+".\p11-capi-util.c" : \
+ ".\p11-capi-util.h"\
-.\ckcapi.c : \
+.\p11-capi.c : \
"..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
- ".\ckcapi-util.h"\
- ".\ckcapi.h"\
+ ".\p11-capi-util.h"\
+ ".\p11-capi.h"\
".\pkcs11\cryptoki.h"\
".\pkcs11\pkcs11.h"\
".\pkcs11\pkcs11f.h"\
diff --git a/ckcapi.h b/p11-capi.h
index f174675..e522bfa 100644
--- a/ckcapi.h
+++ b/p11-capi.h
@@ -17,23 +17,23 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef CKCAPI_H
-#define CKCAPI_H
+#ifndef P11C_H
+#define P11C_H
/* --------------------------------------------------------------------
*
- * Session = CkCapiSession
+ * Session = P11cSession
* - A PKCS#11 Session
*
- * Objects = CkCapiObject
- * - There's a global list of objects in ckcapi-object.c indexed by
+ * Objects = P11cObject
+ * - There's a global list of objects in p11c-object.c indexed by
* object handle.
* - The object itself has no attributes or cached data, but knows how
* to load data when needed.
* - Each object has a unique key which guarantees we don't load the
* same object twice with two different object handles.
*
- * Object Data = CkCapiObjectData
+ * Object Data = P11cObjectData
* - Object Data is owned by the Session
* - Loaded data and/or attributes for an object.
*/
@@ -43,22 +43,22 @@
#include <windows.h>
#include <wincrypt.h>
-#define CKCAPI_ENCODINGS (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
+#define P11c_ENCODINGS (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
#define CRYPTOKI_EXPORTS
#include "pkcs11/pkcs11.h"
-#include "ckcapi-util.h"
+#include "p11-capi-util.h"
-struct _CkCapiSlot;
-struct _CkCapiObject;
-struct _CkCapiObjectData;
-struct _CkCapiSession;
+struct _P11cSlot;
+struct _P11cObject;
+struct _P11cObjectData;
+struct _P11cSession;
-typedef struct _CkCapiSlot CkCapiSlot;
-typedef struct _CkCapiObject CkCapiObject;
-typedef struct _CkCapiObjectData CkCapiObjectData;
-typedef struct _CkCapiSession CkCapiSession;
+typedef struct _P11cSlot P11cSlot;
+typedef struct _P11cObject P11cObject;
+typedef struct _P11cObjectData P11cObjectData;
+typedef struct _P11cSession P11cSession;
/* ------------------------------------------------------------------
* cryptoki-capi.c
@@ -66,54 +66,53 @@ typedef struct _CkCapiSession CkCapiSession;
* Module helper and logging functions.
*/
-#define DBG(args) \
- ckcapi_debug args
+#define DBG(args) p11c_debug args
-void ckcapi_debug (const char* msg, ...);
+void p11c_debug (const char* msg, ...);
/*
* Protect global data with these.
*/
-void ckcapi_lock_global (void);
-void ckcapi_unlock_global (void);
+void p11c_lock_global (void);
+void p11c_unlock_global (void);
/*
* Convert a GetLastError() windows error to a
* PKCS#11 return code.
*/
-CK_RV ckcapi_winerr_to_ckr (DWORD werr);
+CK_RV p11c_winerr_to_ckr (DWORD werr);
/*
* This stores data in the output buffer with appropriate
* PKCS#11 codes when the buffer is too short, or the caller
* just wants to know the length, etc.
*/
-CK_RV ckcapi_return_data (CK_ATTRIBUTE_PTR attr,
- CK_VOID_PTR src, DWORD slen);
+CK_RV p11c_return_data (CK_ATTRIBUTE_PTR attr,
+ CK_VOID_PTR src, DWORD slen);
-CK_RV ckcapi_return_data_raw (CK_VOID_PTR output, CK_ULONG_PTR n_output,
- CK_VOID_PTR input, CK_ULONG n_input);
+CK_RV p11c_return_data_raw (CK_VOID_PTR output, CK_ULONG_PTR n_output,
+ CK_VOID_PTR input, CK_ULONG n_input);
/*
* This stores a string in the output buffer with appropriate
* PKCS#11 codes when the buffer is too short, or the caller
* just wants to know the length, etc.
*/
-CK_RV ckcapi_return_string (CK_ATTRIBUTE_PTR attr,
- WCHAR* string);
+CK_RV p11c_return_string (CK_ATTRIBUTE_PTR attr,
+ WCHAR* string);
-CK_RV ckcapi_return_dword_as_bytes (CK_ATTRIBUTE_PTR attr,
- DWORD value);
+CK_RV p11c_return_dword_as_bytes (CK_ATTRIBUTE_PTR attr,
+ DWORD value);
-CK_RV ckcapi_return_reversed_data (CK_ATTRIBUTE_PTR attr,
- CK_VOID_PTR data, CK_ULONG length);
+CK_RV p11c_return_reversed_data (CK_ATTRIBUTE_PTR attr,
+ CK_VOID_PTR data, CK_ULONG length);
-CK_RV ckcapi_return_filetime (CK_ATTRIBUTE_PTR attr,
- FILETIME* ftime);
+CK_RV p11c_return_filetime (CK_ATTRIBUTE_PTR attr,
+ FILETIME* ftime);
/* ------------------------------------------------------------------ */
-typedef void (*CkCapiDestroyFunc)(void* data);
+typedef void (*P11cDestroyFunc)(void* data);
#ifndef ASSERT
#include "assert.h"
@@ -124,4 +123,4 @@ typedef void (*CkCapiDestroyFunc)(void* data);
#define CKO_ANY CK_INVALID_HANDLE
-#endif /* CRYPTOKI_CAPI_H */
+#endif /* P11C_CAPI_H */
diff --git a/ckcapi.vcproj b/p11-capi.vcproj
index 01ef822..7c554d1 100644
--- a/ckcapi.vcproj
+++ b/p11-capi.vcproj
@@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
- Name="ckcapi"
+ Name="p11-capi"
ProjectGUID="{5FC3E27C-F74F-41ED-8BE9-8A586AFC059A}"
- RootNamespace="ckcapi"
+ RootNamespace="p11-capi"
>
<Platforms>
<Platform
@@ -42,7 +42,7 @@
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
- TypeLibraryName=".\Debug/ckcapi.tlb"
+ TypeLibraryName=".\Debug/p11-capi.tlb"
HeaderFileName=""
/>
<Tool
@@ -52,7 +52,7 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
- PrecompiledHeaderFile=".\Debug/ckcapi.pch"
+ PrecompiledHeaderFile=".\Debug/p11-capi.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
@@ -74,12 +74,12 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib crypt32.lib advapi32.lib"
- OutputFile=".\Debug/ckcapi.dll"
+ OutputFile=".\Debug/p11-capi.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
- ProgramDatabaseFile=".\Debug/ckcapi.pdb"
- ImportLibrary=".\Debug/ckcapi.lib"
+ ProgramDatabaseFile=".\Debug/p11-capi.pdb"
+ ImportLibrary=".\Debug/p11-capi.lib"
TargetMachine="1"
/>
<Tool
@@ -94,7 +94,7 @@
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
- OutputFile=".\Debug/ckcapi.bsc"
+ OutputFile=".\Debug/p11-capi.bsc"
/>
<Tool
Name="VCFxCopTool"
@@ -137,7 +137,7 @@
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
- TypeLibraryName=".\Release/ckcapi.tlb"
+ TypeLibraryName=".\Release/p11-capi.tlb"
HeaderFileName=""
/>
<Tool
@@ -148,7 +148,7 @@
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile=".\Release/ckcapi.pch"
+ PrecompiledHeaderFile=".\Release/p11-capi.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
@@ -169,11 +169,11 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib crypt32.lib"
- OutputFile=".\Release/ckcapi.dll"
+ OutputFile=".\Release/p11-capi.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
- ProgramDatabaseFile=".\Release/ckcapi.pdb"
- ImportLibrary=".\Release/ckcapi.lib"
+ ProgramDatabaseFile=".\Release/p11-capi.pdb"
+ ImportLibrary=".\Release/p11-capi.lib"
TargetMachine="1"
/>
<Tool
@@ -188,7 +188,7 @@
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
- OutputFile=".\Release/ckcapi.bsc"
+ OutputFile=".\Release/p11-capi.bsc"
/>
<Tool
Name="VCFxCopTool"
@@ -212,7 +212,7 @@
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
- RelativePath="ckcapi-builtin.c"
+ RelativePath="p11-capi-builtin.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -232,7 +232,7 @@
</FileConfiguration>
</File>
<File
- RelativePath="ckcapi-cert.c"
+ RelativePath="p11-capi-cert.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -252,15 +252,15 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\ckcapi-der.c"
+ RelativePath=".\p11-capi-der.c"
>
</File>
<File
- RelativePath=".\ckcapi-key.c"
+ RelativePath=".\p11-capi-key.c"
>
</File>
<File
- RelativePath="ckcapi-object.c"
+ RelativePath="p11-capi-object.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -280,11 +280,11 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\ckcapi-rsa.c"
+ RelativePath=".\p11-capi-rsa.c"
>
</File>
<File
- RelativePath="ckcapi-session.c"
+ RelativePath="p11-capi-session.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -304,7 +304,7 @@
</FileConfiguration>
</File>
<File
- RelativePath="ckcapi-token.c"
+ RelativePath="p11-capi-token.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -324,11 +324,11 @@
</FileConfiguration>
</File>
<File
- RelativePath=".\ckcapi-trust.c"
+ RelativePath=".\p11-capi-trust.c"
>
</File>
<File
- RelativePath="ckcapi-util.c"
+ RelativePath="p11-capi-util.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -348,7 +348,7 @@
</FileConfiguration>
</File>
<File
- RelativePath="ckcapi.c"
+ RelativePath="p11-capi.c"
>
<FileConfiguration
Name="Debug|Win32"
@@ -373,43 +373,43 @@
Filter="h;hpp;hxx;hm;inl"
>
<File
- RelativePath=".\ckcapi-cert.h"
+ RelativePath=".\p11-capi-cert.h"
>
</File>
<File
- RelativePath=".\ckcapi-der.h"
+ RelativePath=".\p11-capi-der.h"
>
</File>
<File
- RelativePath=".\ckcapi-key.h"
+ RelativePath=".\p11-capi-key.h"
>
</File>
<File
- RelativePath=".\ckcapi-object.h"
+ RelativePath=".\p11-capi-object.h"
>
</File>
<File
- RelativePath=".\ckcapi-rsa.h"
+ RelativePath=".\p11-capi-rsa.h"
>
</File>
<File
- RelativePath=".\ckcapi-session.h"
+ RelativePath=".\p11-capi-session.h"
>
</File>
<File
- RelativePath=".\ckcapi-token.h"
+ RelativePath=".\p11-capi-token.h"
>
</File>
<File
- RelativePath=".\ckcapi-trust.h"
+ RelativePath=".\p11-capi-trust.h"
>
</File>
<File
- RelativePath="ckcapi-util.h"
+ RelativePath="p11-capi-util.h"
>
</File>
<File
- RelativePath="ckcapi.h"
+ RelativePath="p11-capi.h"
>
</File>
<File