File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,9 @@ endif()
122122
123123if (BUILD_TEST_APPS)
124124 message (STATUS "Building wolfBoot test apps" )
125+ if (WOLFCRYPT_TZ_PKCS11 AND NOT TZEN)
126+ message (FATAL_ERROR "WOLFCRYPT_TZ_PKCS11 requires TZEN=ON for test-app builds" )
127+ endif ()
125128 add_executable (image )
126129
127130 target_sources (image PRIVATE ${APP_SOURCES} )
@@ -176,7 +179,7 @@ if(BUILD_TEST_APPS)
176179 target_include_directories (image PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} /wcs )
177180 endif ()
178181
179- if (WOLFCRYPT_TZ_PKCS11)
182+ if (TZEN AND WOLFCRYPT_TZ_PKCS11)
180183 target_include_directories (image PRIVATE ../lib/wolfPKCS11 )
181184 endif ()
182185
@@ -204,7 +207,7 @@ if(BUILD_TEST_APPS)
204207 list (APPEND TEST_APP_COMPILE_DEFINITIONS WOLFBOOT_SECURE_CALLS)
205208 endif ()
206209
207- if (WOLFCRYPT_TZ_PKCS11)
210+ if (TZEN AND WOLFCRYPT_TZ_PKCS11)
208211 list (APPEND TEST_APP_COMPILE_DEFINITIONS
209212 WOLFBOOT_PKCS11_APP
210213 SECURE_PKCS11
Original file line number Diff line number Diff line change @@ -481,6 +481,7 @@ int test_pkcs11_start(void)
481481 int key_state ;
482482 int data_state ;
483483 int result = PKCS11_TEST_FAIL ;
484+ int session_logged_in = 0 ;
484485
485486 memset (& blob , 0 , sizeof (blob ));
486487
@@ -513,6 +514,7 @@ int test_pkcs11_start(void)
513514 ret = -1 ;
514515 goto cleanup ;
515516 }
517+ session_logged_in = 1 ;
516518
517519 key_state = test_pkcs11_find_keypair (session , & pub_obj , & priv_obj );
518520 if (key_state < 0 ) {
@@ -570,8 +572,11 @@ int test_pkcs11_start(void)
570572 }
571573
572574cleanup :
573- (void )wolfpkcs11nsFunctionList .C_Logout (session );
574- (void )wolfpkcs11nsFunctionList .C_CloseSession (session );
575+ if (session != CK_INVALID_HANDLE ) {
576+ if (session_logged_in )
577+ (void )wolfpkcs11nsFunctionList .C_Logout (session );
578+ (void )wolfpkcs11nsFunctionList .C_CloseSession (session );
579+ }
575580 (void )wolfpkcs11nsFunctionList .C_Finalize (NULL );
576581 (void )wolfCrypt_Cleanup ();
577582
You can’t perform that action at this time.
0 commit comments