summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/pkcs11-coverage.txt19
-rw-r--r--src/object.c53
2 files changed, 37 insertions, 35 deletions
diff --git a/doc/pkcs11-coverage.txt b/doc/pkcs11-coverage.txt
index 295df9f..2c1abec 100644
--- a/doc/pkcs11-coverage.txt
+++ b/doc/pkcs11-coverage.txt
@@ -35,8 +35,6 @@ C_Finalize
C_FindObjects
- Invalid session
- Null object count
-- Retrieve count of objects, using NULL buffer
-- Retrieve count of objects
- Retrieve a single object before remainder
- Retrieve remaining objects
- Extra call after retrieving all objects.
@@ -52,6 +50,20 @@ C_FindObjectsInit
- Attribute count without buffer
- Double call.
+C_GetAttributeValue
+- Invalid session
+- Invalid object
+- No template
+- Buffer too small
+- Retrieve attribute length
+- Retrieve single attribute
+- With one invalid attribute, no buffer.
+- With one invalid attribute, with buffer.
+- Multiple attributes, no buffer.
+- Multiple attributes, some buffers
+- Multiple attributes, one small buffer
+- Multiple attributes, with buffers
+
C_GetFunctionList
- See if returns same data as library entry point
@@ -73,6 +85,9 @@ C_GetMechanismList
- Zero count but buffer present
- Low count but buffer present
+C_GetObjectSize
+- Not Implemented
+
C_GetOperationState
- Not Implemented
diff --git a/src/object.c b/src/object.c
index 71e6a0d..adfd86e 100644
--- a/src/object.c
+++ b/src/object.c
@@ -40,7 +40,7 @@ destroy_object(CK_SESSION_HANDLE session_rw, CK_SESSION_HANDLE session_ro)
static void
find_objects(CK_SESSION_HANDLE session)
{
- CK_OBJECT_HANDLE_PTR objects;
+ CK_OBJECT_HANDLE objects[1024];
CK_OBJECT_HANDLE extra;
CK_ATTRIBUTE dummy;
CK_ULONG object_count, count;
@@ -85,33 +85,20 @@ find_objects(CK_SESSION_HANDLE session)
rv = (p11t_module_funcs->C_FindObjects)(session, NULL, 0, NULL);
p11t_check_returns("C_FindObjects: invalid session", rv, CKR_ARGUMENTS_BAD);
- /** - Retrieve count of objects, using NULL buffer */
- rv = (p11t_module_funcs->C_FindObjects)(session, NULL, 0, &object_count);
- p11t_check_returns("C_FindObjects: retrieve count", rv, CKR_OK);
+ /** - Retrieve a single object before remainder */
+ rv = (p11t_module_funcs->C_FindObjects)(session, objects, 1, &count);
+ p11t_check_returns("C_FindObjects: single object", rv, CKR_OK);
+ if(count != 0)
+ p11t_check_ulong("C_FindObjects: should return one object", count, 1);
}
- /** - Retrieve count of objects */
- rv = (p11t_module_funcs->C_FindObjects)(session, &extra, 0, &object_count);
- p11t_check_returns("C_FindObjects: retrieve count", rv, CKR_OK);
-
- if(object_count > 0)
+ do
{
- if(p11t_test_unexpected)
- {
- /** - Retrieve a single object before remainder */
- rv = (p11t_module_funcs->C_FindObjects)(session, &extra, 1, &count);
- p11t_check_returns("C_FindObjects: single object", rv, CKR_OK);
- p11t_check_ulong("C_FindObjects: should return one object", count, 1);
- --object_count;
- }
-
/** - Retrieve remaining objects */
- objects = calloc(object_count, sizeof(CK_OBJECT_HANDLE));
- assert(objects);
- rv = (p11t_module_funcs->C_FindObjects)(session, objects, object_count, &count);
+ rv = (p11t_module_funcs->C_FindObjects)(session, objects, 1024, &count);
p11t_check_returns("C_FindObjects: all objects", rv, CKR_OK);
- p11t_check_ulong("C_FindObjects: should return one object", count, object_count);
}
+ while(count == 1024);
if(p11t_test_unexpected)
{
@@ -152,7 +139,7 @@ static void
test_get_attribute_value(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
{
CK_OBJECT_CLASS klass;
- CK_ATTRIBUTE attrs[4];
+ CK_ATTRIBUTE attrs[5];
CK_BYTE buffer[8];
CK_BBOOL bools[3];
CK_RV rv;
@@ -349,6 +336,9 @@ p11t_object_tests(void)
if(!p11t_session_login(session_ro))
continue;
+ find_objects(session_ro);
+ test_objects(session_ro);
+
if(session_rw != CK_INVALID)
{
find_objects(session_rw);
@@ -371,7 +361,6 @@ p11t_object_find(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR attrs,
CK_ULONG n_attrs, CK_ULONG_PTR n_objects)
{
CK_OBJECT_HANDLE_PTR objects;
- CK_OBJECT_HANDLE dummy_obj;
CK_ATTRIBUTE dummy_attr;
CK_ULONG count;
@@ -383,22 +372,20 @@ p11t_object_find(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR attrs,
if((p11t_module_funcs->C_FindObjectsInit)(session, attrs, n_attrs) != CKR_OK)
return NULL;
- if((p11t_module_funcs->C_FindObjects)(session, &dummy_obj, 0, &count) != CKR_OK)
- return NULL;
-
- if(!count)
+ objects = calloc(1024, sizeof(CK_OBJECT_HANDLE));
+ if((p11t_module_funcs->C_FindObjects)(session, objects, 1024, n_objects) != CKR_OK)
+ {
+ free(objects);
return NULL;
+ }
- objects = calloc(count, sizeof(CK_OBJECT_HANDLE));
- assert(objects);
-
- if((p11t_module_funcs->C_FindObjects)(session, objects, count, n_objects) != CKR_OK)
+ if((p11t_module_funcs->C_FindObjectsFinal)(session) != CKR_OK)
{
free(objects);
return NULL;
}
- if((p11t_module_funcs->C_FindObjectsFinal)(session) != CKR_OK)
+ if(!count)
{
free(objects);
return NULL;