From: Stef Walter Date: Wed, 5 Jun 2013 20:01:31 +0000 (+0200) Subject: Merge branch 'stable' X-Git-Tag: 0.19.2~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=125aa8b136fa950172c3946ca4768cf4750b697a;p=p11-kit Merge branch 'stable' --- 125aa8b136fa950172c3946ca4768cf4750b697a diff --cc NEWS index f7aa050,be0e3b4..ea42c8a --- a/NEWS +++ b/NEWS @@@ -1,14 -1,8 +1,19 @@@ +0.19.0 (unstable) + * Refactor API to be able to handle managed modules + * Deprecate much of old p11-kit API + * Implement concept of managed modules + * Make C_CloseAllSessions function work for multiple callers + * New dependency on libffi + * Fix possible threading problems reported by hellgrind + * Add log-calls option + * Mark p11_kit_message() as a stable function + * Use our own unit testing framework + + 0.18.3 (stable) + * Fix reinitialization of trust module [#65401] + * Fix crash in trust module C_Initialize + * Mac OS fixes [#57714] + 0.18.2 (stable) * Build fixes [#64378 ...] diff --cc trust/module.c index 109ff5c,ba41884..abfabae --- a/trust/module.c +++ b/trust/module.c @@@ -350,9 -436,11 +366,11 @@@ sys_C_Initialize (CK_VOID_PTR init_args * We support setting the socket path and other arguments from from the * pReserved pointer, similar to how NSS PKCS#11 components are initialized. */ - if (rv == CKR_OK) { + } else if (rv == CKR_OK) { + p11_debug ("doing initialization"); + if (args->pReserved) - parse_arguments ((const char*)args->pReserved); + p11_argv_parse ((const char*)args->pReserved, parse_argument, NULL); gl.sessions = p11_dict_new (p11_dict_ulongptr_hash, p11_dict_ulongptr_equal, diff --cc trust/tests/test-module.c index 45ec74d,472263a..bf28124 --- a/trust/tests/test-module.c +++ b/trust/tests/test-module.c @@@ -132,15 -134,82 +132,80 @@@ test_get_slot_list (void count = NUM_SLOTS; memset (slots, 0, sizeof (slots)); rv = test.module->C_GetSlotList (TRUE, slots, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (NUM_SLOTS, count); for (i = 0; i < NUM_SLOTS; i++) - CuAssertTrue (cu, slots[i] != 0); - - teardown (cu); + assert (slots[i] != 0); } + static void -test_null_initialize (CuTest *cu) ++test_null_initialize (void) + { + CK_FUNCTION_LIST *module; + CK_RV rv; + + /* This is the entry point of the trust module, linked to this test */ + rv = C_GetFunctionList (&module); - CuAssertTrue (cu, rv == CKR_OK); ++ assert_num_eq (rv, CKR_OK); + + rv = module->C_Initialize (NULL); - CuAssertTrue (cu, rv == CKR_OK); ++ assert_num_eq (rv, CKR_OK); + + rv = module->C_Finalize (NULL); - CuAssertIntEquals (cu, CKR_OK, rv); ++ assert_num_eq (CKR_OK, rv); + } + + static void -test_multi_initialize (CuTest *cu) ++test_multi_initialize (void) + { + static CK_C_INITIALIZE_ARGS args = + { NULL, NULL, NULL, NULL, CKF_OS_LOCKING_OK, NULL, }; + CK_FUNCTION_LIST *module; + CK_SESSION_HANDLE session; + CK_SLOT_ID slots[8]; + CK_SESSION_INFO info; + CK_ULONG count; + CK_RV rv; + + /* This is the entry point of the trust module, linked to this test */ + rv = C_GetFunctionList (&module); - CuAssertTrue (cu, rv == CKR_OK); ++ assert_num_eq (rv, CKR_OK); + + rv = module->C_Initialize (&args); - CuAssertTrue (cu, rv == CKR_OK); ++ assert_num_eq (rv, CKR_OK); + + count = 8; + rv = module->C_GetSlotList (CK_TRUE, slots, &count); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertTrue (cu, count > 0); ++ assert_num_eq (rv, CKR_OK); ++ assert_num_cmp (count, >, 0); + + rv = module->C_OpenSession (slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); ++ assert_num_eq (rv, CKR_OK); + + rv = module->C_GetSessionInfo (session, &info); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertTrue (cu, info.slotID == slots[0]); ++ assert_num_eq (rv, CKR_OK); ++ assert_num_eq (info.slotID, slots[0]); + + rv = module->C_Initialize (&args); - CuAssertTrue (cu, rv == CKR_OK); ++ assert_num_eq (rv, CKR_OK); + + rv = module->C_GetSessionInfo (session, &info); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertTrue (cu, info.slotID == slots[0]); ++ assert_num_eq (rv, CKR_OK); ++ assert_num_eq (info.slotID, slots[0]); + + rv = module->C_Finalize (NULL); - CuAssertIntEquals (cu, CKR_OK, rv); ++ assert_num_eq (CKR_OK, rv); + + rv = module->C_Finalize (NULL); - CuAssertIntEquals (cu, CKR_OK, rv); ++ assert_num_eq (CKR_OK, rv); + + rv = module->C_Finalize (NULL); - CuAssertIntEquals (cu, CKR_CRYPTOKI_NOT_INITIALIZED, rv); ++ assert_num_eq (CKR_CRYPTOKI_NOT_INITIALIZED, rv); + } + static void -test_get_slot_info (CuTest *cu) +test_get_slot_info (void) { CK_SLOT_ID slots[NUM_SLOTS]; CK_SLOT_INFO info; @@@ -923,35 -1065,44 +988,37 @@@ test_login_logout (void } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); p11_library_init (); - SUITE_ADD_TEST (suite, test_null_initialize); - SUITE_ADD_TEST (suite, test_multi_initialize); - SUITE_ADD_TEST (suite, test_get_slot_list); - SUITE_ADD_TEST (suite, test_get_slot_info); - SUITE_ADD_TEST (suite, test_get_token_info); - SUITE_ADD_TEST (suite, test_get_session_info); - SUITE_ADD_TEST (suite, test_close_all_sessions); - SUITE_ADD_TEST (suite, test_find_certificates); - SUITE_ADD_TEST (suite, test_find_builtin); - SUITE_ADD_TEST (suite, test_lookup_invalid); - SUITE_ADD_TEST (suite, test_remove_token); - SUITE_ADD_TEST (suite, test_setattr_token); - SUITE_ADD_TEST (suite, test_session_object); - SUITE_ADD_TEST (suite, test_session_find); - SUITE_ADD_TEST (suite, test_session_find_no_attr); - SUITE_ADD_TEST (suite, test_session_copy); - SUITE_ADD_TEST (suite, test_session_remove); - SUITE_ADD_TEST (suite, test_session_setattr); - SUITE_ADD_TEST (suite, test_find_serial_der_decoded); - SUITE_ADD_TEST (suite, test_find_serial_der_mismatch); - SUITE_ADD_TEST (suite, test_login_logout); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_fixture (setup, teardown); + p11_test (test_get_slot_list, "/module/get_slot_list"); + p11_test (test_get_slot_info, "/module/get_slot_info"); + + p11_fixture (NULL, NULL); ++ p11_test (test_null_initialize, "/module/initialize-null"); ++ p11_test (test_multi_initialize, "/module/initialize-multi"); + p11_test (test_get_token_info, "/module/get_token_info"); + + p11_fixture (setup, teardown); + p11_test (test_get_session_info, "/module/get_session_info"); + p11_test (test_close_all_sessions, "/module/close_all_sessions"); + p11_test (test_find_certificates, "/module/find_certificates"); + p11_test (test_find_builtin, "/module/find_builtin"); + p11_test (test_lookup_invalid, "/module/lookup_invalid"); + p11_test (test_remove_token, "/module/remove_token"); + p11_test (test_setattr_token, "/module/setattr_token"); + p11_test (test_session_object, "/module/session_object"); + p11_test (test_session_find, "/module/session_find"); + p11_test (test_session_find_no_attr, "/module/session_find_no_attr"); + p11_test (test_session_copy, "/module/session_copy"); + p11_test (test_session_remove, "/module/session_remove"); + p11_test (test_session_setattr, "/module/session_setattr"); + p11_test (test_find_serial_der_decoded, "/module/find_serial_der_decoded"); + p11_test (test_find_serial_der_mismatch, "/module/find_serial_der_mismatch"); + p11_test (test_login_logout, "/module/login_logout"); + + return p11_test_run (argc, argv); }