commit a6db576700648d8ad2b31a10a3dbda9ca9fd2b80 Author: Ingo Tuchscherer <[email protected]> Date: Mon Aug 10 09:41:56 2015 +0200
Improved sess_mgmt testcase Added check to ensure if mechanism under test is supported. Signed-off-by: Ingo Tuchscherer <[email protected]> diff --git a/testcases/pkcs11/sess_mgmt.c b/testcases/pkcs11/sess_mgmt.c index b21e24a..f7ea505 100644 --- a/testcases/pkcs11/sess_mgmt.c +++ b/testcases/pkcs11/sess_mgmt.c @@ -10,6 +10,7 @@ #include "pkcs11types.h" #include "regress.h" +#include "common.c" // // @@ -552,6 +553,14 @@ CK_RV do_OperationState1( void ) mech.ulParameterLen = 0; mech.pParameter = NULL; + if (!mech_supported(slot_id, mech.mechanism)){ + printf("Mechanism %ld not supported. (skipped)\n", + mech.mechanism); + funcs->C_CloseSession( session1 ); + funcs->C_CloseSession( session2 ); + return 0; + } + rc = funcs->C_GenerateKey( session1, &mech, NULL, 0, &h_key ); if (rc != CKR_OK) { show_error(" C_GenerateKey #1", rc ); @@ -771,6 +780,15 @@ CK_RV do_OperationState2( void ) mech.pParameter = NULL; mech.ulParameterLen = 0; + if (!mech_supported(slot_id, mech.mechanism)){ + printf("Mechanism %ld not supported. (skipped)\n", + mech.mechanism); + funcs->C_CloseSession( session1 ); + funcs->C_CloseSession( session2 ); + funcs->C_CloseSession( session3 ); + return 0; + } + rc = funcs->C_DigestInit( session1, &mech ); if (rc != CKR_OK) { show_error(" C_DigestInit #1", rc ); @@ -1009,6 +1027,15 @@ CK_RV do_OperationState3( void ) mech1.pParameter = NULL; mech1.ulParameterLen = 0; + if (!mech_supported(slot_id, mech1.mechanism)){ + printf("Mechanism %ld not supported. (skipped)\n", + mech1.mechanism); + funcs->C_CloseSession(session1); + funcs->C_CloseSession(session2); + funcs->C_CloseSession(session3); + return 0; + } + rc = funcs->C_GenerateKey( session1, &mech1, NULL, 0, &key ); if (rc != CKR_OK) { show_error(" C_GenerateKey #1", rc ); @@ -1020,6 +1047,14 @@ CK_RV do_OperationState3( void ) mech1.pParameter = NULL; mech1.ulParameterLen = 0; + if (!mech_supported(slot_id, mech1.mechanism)){ + printf("Mechanism %ld not supported. (skipped)\n", + mech1.mechanism); + funcs->C_CloseSession(session1); + funcs->C_CloseSession(session2); + funcs->C_CloseSession(session3); + return 0; + } rc = funcs->C_EncryptInit( session1, &mech1, key ); if (rc != CKR_OK) { show_error(" C_EncryptInit #1", rc ); ------------------------------------------------------------------------------ _______________________________________________ Opencryptoki-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech
