summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2008-12-09 15:35:13 +0000
committerStef Walter <stef@memberwebs.com>2008-12-09 15:35:13 +0000
commitd44882432b1534c8cfca3057ad59765a949adacc (patch)
tree8184895d6c4d40b4a36a8c92a4ccb7dc3f68f8e2
parentc9099836f080c8bb821264050f5f6d59a1ceddba (diff)
Fixes for building on Windows, and some tweaks for testing the CAPI PKCS#11 module.
-rw-r--r--p11-tests.vcproj4
-rw-r--r--src/certificate.c12
-rw-r--r--src/module.c4
-rw-r--r--src/p11-tests.c2
4 files changed, 14 insertions, 8 deletions
diff --git a/p11-tests.vcproj b/p11-tests.vcproj
index de29a8e..d1f892d 100644
--- a/p11-tests.vcproj
+++ b/p11-tests.vcproj
@@ -196,6 +196,10 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
+ RelativePath=".\src\certificate.c"
+ >
+ </File>
+ <File
RelativePath=".\src\check.c"
>
</File>
diff --git a/src/certificate.c b/src/certificate.c
index ce4cac3..acb7b37 100644
--- a/src/certificate.c
+++ b/src/certificate.c
@@ -237,7 +237,7 @@ test_x509_certificate(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
attr.ulValueLen = sizeof(java_midp);
rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, &attr, 1);
P11T_CHECK_RV("CKA_JAVA_MIDP_SECURITY_DOMAIN", rv, CKR_OK);
- if(java_midp != 0 || java_midp != 1 || java_midp != 2 || java_midp != 3)
+ if(java_midp != 0 && java_midp != 1 && java_midp != 2 && java_midp != 3)
P11T_CHECK_FAIL_MSG("CKA_JAVA_MIDP_SECURITY_DOMAIN", "Unrecognized value");
/* CKA_ID */
@@ -251,7 +251,7 @@ test_x509_certificate(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
}
test_x509_cross_search(session, object, CKA_ID, CK_INVALID, "CKA_ID");
- test_x509_cross_search(session, object, CKA_ID, CK_INVALID, "CKA_SERIAL_NUMBER, CKA_ISSUER");
+ test_x509_cross_search(session, object, CKA_SERIAL_NUMBER, CKA_ISSUER, "CKA_SERIAL_NUMBER, CKA_ISSUER");
X509_free(cert);
free(der_value);
@@ -293,7 +293,7 @@ test_certificate_object(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
attr.pValue = &category;
rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, &attr, 1);
P11T_CHECK_RV("CKA_CERTIFICATE_CATEGORY", rv, CKR_OK);
- if(category != 1 && category != 2 && category != 3)
+ if(category != 1 && category != 2 && category != 3 && category != 0)
P11T_CHECK_FAIL_MSG("CKA_CERTIFICATE_CATEGORY", "invalid value");
attr.type = CKA_CHECK_VALUE;
@@ -309,14 +309,16 @@ test_certificate_object(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
attr.pValue = &start_date;
rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, &attr, 1);
P11T_CHECK_RV("CKA_START_DATE", rv, CKR_OK);
- P11T_CHECK_DATE("CKA_START_DATE", &start_date);
+ if(attr.ulValueLen)
+ P11T_CHECK_DATE("CKA_START_DATE", &start_date);
attr.type = CKA_END_DATE;
attr.ulValueLen = sizeof(end_date);
attr.pValue = &end_date;
rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, &attr, 1);
P11T_CHECK_RV("CKA_END_DATE", rv, CKR_OK);
- P11T_CHECK_DATE("CKA_END_DATE", &end_date);
+ if(attr.ulValueLen)
+ P11T_CHECK_DATE("CKA_END_DATE", &end_date);
}
test_x509_certificate(session, object);
diff --git a/src/module.c b/src/module.c
index 7dec518..b7a715b 100644
--- a/src/module.c
+++ b/src/module.c
@@ -283,13 +283,13 @@ p11t_module_load(const char *filename)
module = LoadLibrary(filename);
if(!module)
- p11t_msg_fatal("couldn't load library: %s: %s", filename, p11t_msg_lasterr());
+ p11t_msg_fatal("couldn't load library: %s: %s", filename, p11t_msg_os());
/* Lookup the appropriate function in the library */
get_function_list = (CK_C_GetFunctionList)GetProcAddress(module, "C_GetFunctionList");
if(!get_function_list)
p11t_msg_fatal("C_GetFunctionList: couldn't find function in library: %s: %s",
- filename, p11t_msg_lasterr());
+ filename, p11t_msg_os());
#else /* !_WIN32 */
diff --git a/src/p11-tests.c b/src/p11-tests.c
index e4e4110..0d54172 100644
--- a/src/p11-tests.c
+++ b/src/p11-tests.c
@@ -63,8 +63,8 @@ main(int argc, char* argv[])
p11t_slot_tests();
p11t_session_tests();
p11t_object_tests();
- p11t_rsa_tests();
p11t_certificate_tests();
+ p11t_rsa_tests();
/* Remaining module tests */
p11t_module_finalize();