@@ -40,6 +40,10 @@ static int oversized_priv_read_attempted;
4040static int forcezero_calls ;
4141static word32 last_forcezero_len ;
4242static word32 last_pub_read_request_sz ;
43+ static int unload_handle_calls ;
44+ static int unload_seal_blob_calls ;
45+ static int unload_policy_session_calls ;
46+ static int unload_auth_key_calls ;
4347static uint8_t test_hdr [64 ];
4448static uint8_t test_modulus [256 ];
4549static uint8_t test_exponent_der [] = { 0xAA , 0x01 , 0x00 , 0x01 , 0x7B };
@@ -119,7 +123,18 @@ int wolfTPM2_LoadKey(WOLFTPM2_DEV* dev, WOLFTPM2_KEYBLOB* keyBlob,
119123int wolfTPM2_UnloadHandle (WOLFTPM2_DEV * dev , WOLFTPM2_HANDLE * handle )
120124{
121125 (void )dev ;
122- (void )handle ;
126+ unload_handle_calls ++ ;
127+ if (handle != NULL ) {
128+ if (handle -> hndl == 1 ) {
129+ unload_policy_session_calls ++ ;
130+ }
131+ else if (handle -> hndl == 2 ) {
132+ unload_seal_blob_calls ++ ;
133+ }
134+ else {
135+ unload_auth_key_calls ++ ;
136+ }
137+ }
123138 return 0 ;
124139}
125140
@@ -488,6 +503,10 @@ static void setup(void)
488503 forcezero_calls = 0 ;
489504 last_forcezero_len = 0 ;
490505 last_pub_read_request_sz = 0 ;
506+ unload_handle_calls = 0 ;
507+ unload_seal_blob_calls = 0 ;
508+ unload_policy_session_calls = 0 ;
509+ unload_auth_key_calls = 0 ;
491510 memset (test_hdr , 0x22 , sizeof (test_hdr ));
492511 memset (test_modulus , 0x33 , sizeof (test_modulus ));
493512}
@@ -643,6 +662,8 @@ START_TEST(test_wolfBoot_unseal_blob_rejects_oversized_auth)
643662 secret , & secret_sz , auth , (int )sizeof (auth ));
644663
645664 ck_assert_int_eq (rc , BAD_FUNC_ARG );
665+ ck_assert_int_eq (unload_seal_blob_calls , 1 );
666+ ck_assert_int_eq (unload_policy_session_calls , 1 );
646667}
647668END_TEST
648669
@@ -665,6 +686,8 @@ START_TEST(test_wolfBoot_unseal_blob_rejects_negative_auth_size)
665686 secret , & secret_sz , auth , -1 );
666687
667688 ck_assert_int_eq (rc , BAD_FUNC_ARG );
689+ ck_assert_int_eq (unload_seal_blob_calls , 1 );
690+ ck_assert_int_eq (unload_policy_session_calls , 1 );
668691}
669692END_TEST
670693
0 commit comments