summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-12-08 18:34:14 +0000
committerStef Walter <stef@memberwebs.com>2008-12-08 18:34:14 +0000
commit697c4dc2d26bfb41206475f39a584bb0a177d605 (patch)
tree4e9a5d1a8e6605835c09e583542a53a92cc78262
parentb81f8c4510eab19a108673578af8dbe306c42532 (diff)
Support non certificate store slots properly throughout the code.
-rw-r--r--ckcapi-session.c26
-rw-r--r--ckcapi-token.c3
2 files changed, 16 insertions, 13 deletions
diff --git a/ckcapi-session.c b/ckcapi-session.c
index 0745cb7..6142760 100644
--- a/ckcapi-session.c
+++ b/ckcapi-session.c
@@ -51,6 +51,7 @@ CK_RV
ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
{
CkCapiSession* sess;
+ const char *store;
DWORD err;
sess = calloc(1, sizeof(CkCapiSession));
@@ -70,19 +71,22 @@ ckcapi_session_create(CK_SLOT_ID slot, CkCapiSession** ret)
return CKR_HOST_MEMORY;
}
- sess->store = CertOpenSystemStore((HCRYPTPROV)NULL,
- ckcapi_token_get_store_name(slot));
- if(sess->store == NULL)
+ store = ckcapi_token_get_store_name(slot);
+ if(store)
{
- err = GetLastError();
-
- /* Store not found, we don't care */
- if(err != ERROR_FILE_NOT_FOUND)
+ sess->store = CertOpenSystemStore((HCRYPTPROV)NULL, store);
+ if(sess->store == NULL)
{
- ckcapi_hash_free(sess->object_data, NULL);
- CloseHandle(sess->mutex);
- free(sess);
- return ckcapi_winerr_to_ckr(err);
+ err = GetLastError();
+
+ /* Store not found, we don't care */
+ if(err != ERROR_FILE_NOT_FOUND)
+ {
+ ckcapi_hash_free(sess->object_data, NULL);
+ CloseHandle(sess->mutex);
+ free(sess);
+ return ckcapi_winerr_to_ckr(err);
+ }
}
}
diff --git a/ckcapi-token.c b/ckcapi-token.c
index acebd16..a2beb74 100644
--- a/ckcapi-token.c
+++ b/ckcapi-token.c
@@ -42,7 +42,7 @@ static const SlotInfo slot_info[] = {
{ "Trust", "Trust", CKCAPI_SLOT_CERTS },
{ "TrustedPeople", "Trusted People", CKCAPI_SLOT_TRUSTED | CKCAPI_SLOT_CERTS },
{ "AuthRoot", "Auth Root", CKCAPI_SLOT_CERTS },
- { "", "All User Keys", CKCAPI_SLOT_ANYKEY }
+ { NULL, "All User Keys", CKCAPI_SLOT_ANYKEY }
};
#define SLOT_TO_OFFSET(slot) \
@@ -85,7 +85,6 @@ ckcapi_token_get_store_name(CK_SLOT_ID slot)
{
unsigned int offset = SLOT_TO_OFFSET(slot);
ASSERT(ckcapi_token_is_valid(slot));
- ASSERT(slot_info[offset].capi_store);
return slot_info[offset].capi_store;
}