@@ -228,6 +228,61 @@ int wolfTPM2_PolicyRefMake(TPM_ALG_ID pcrAlg, byte* digest, word32* digestSz,
228228 return 0 ;
229229}
230230
231+ int TPM2_GetHashDigestSize (TPMI_ALG_HASH hashAlg )
232+ {
233+ (void )hashAlg ;
234+ return 32 ;
235+ }
236+
237+ int wolfTPM2_GetKeyTemplate_KeySeal (TPMT_PUBLIC * publicTemplate ,
238+ TPM_ALG_ID nameAlg )
239+ {
240+ memset (publicTemplate , 0 , sizeof (* publicTemplate ));
241+ publicTemplate -> nameAlg = nameAlg ;
242+ return 0 ;
243+ }
244+
245+ int wolfTPM2_PolicyAuthorizeMake (TPM_ALG_ID hashAlg , const TPM2B_PUBLIC * pub ,
246+ byte * digest , word32 * digestSz , const byte * policyRef ,
247+ word32 policyRefSz )
248+ {
249+ (void )hashAlg ;
250+ (void )pub ;
251+ (void )policyRef ;
252+ (void )policyRefSz ;
253+ memset (digest , 0x11 , * digestSz );
254+ return 0 ;
255+ }
256+
257+ int wolfTPM2_CreateKeySeal_ex (WOLFTPM2_DEV * dev , WOLFTPM2_KEYBLOB * keyBlob ,
258+ WOLFTPM2_HANDLE * parent , TPMT_PUBLIC * publicTemplate , const byte * auth ,
259+ int authSz , TPM_ALG_ID alg , byte * pcrSel ,
260+ word32 pcrSelSz , const byte * sealData , int sealSize )
261+ {
262+ (void )dev ;
263+ (void )keyBlob ;
264+ (void )parent ;
265+ (void )publicTemplate ;
266+ (void )auth ;
267+ (void )authSz ;
268+ (void )alg ;
269+ (void )pcrSel ;
270+ (void )pcrSelSz ;
271+ (void )sealData ;
272+ (void )sealSize ;
273+ unexpected_nvcreate_calls ++ ;
274+ ck_abort_msg ("Unexpected wolfTPM2_CreateKeySeal_ex call" );
275+ return -1 ;
276+ }
277+
278+ int wolfTPM2_GetNvAttributesTemplate (TPM_HANDLE authHandle ,
279+ word32 * attr )
280+ {
281+ (void )authHandle ;
282+ * attr = 0 ;
283+ return 0 ;
284+ }
285+
231286TPM_RC TPM2_Unseal (Unseal_In * in , Unseal_Out * out )
232287{
233288 (void )in ;
@@ -492,6 +547,27 @@ START_TEST(test_wolfBoot_delete_blob_rejects_oversized_auth)
492547}
493548END_TEST
494549
550+ START_TEST (test_wolfBoot_seal_auth_rejects_oversized_auth )
551+ {
552+ uint8_t auth [sizeof (((WOLFTPM2_KEYBLOB * )0 )-> handle .auth .buffer ) + 1 ];
553+ uint8_t pubkey_hint [WOLFBOOT_SHA_DIGEST_SIZE ] = {0 };
554+ uint8_t policy [sizeof (uint32_t ) + 4 ] = {0 };
555+ uint8_t secret [8 ] = {0 };
556+ int rc ;
557+
558+ memset (auth , 0x77 , sizeof (auth ));
559+
560+ rc = wolfBoot_seal_auth (pubkey_hint , policy , sizeof (policy ), 0 ,
561+ secret , sizeof (secret ), auth , (int )sizeof (auth ));
562+
563+ ck_assert_int_eq (rc , BAD_FUNC_ARG );
564+ ck_assert_int_eq (unexpected_nvcreate_calls , 0 );
565+ ck_assert_int_eq (unexpected_nvwrite_calls , 0 );
566+ ck_assert_int_eq (unexpected_nvopen_calls , 0 );
567+ ck_assert_int_eq (unexpected_nvdelete_calls , 0 );
568+ }
569+ END_TEST
570+
495571START_TEST (test_wolfBoot_unseal_blob_zeroes_unseal_output )
496572{
497573 uint8_t secret [WOLFBOOT_MAX_SEAL_SZ ];
@@ -575,6 +651,7 @@ static Suite *tpm_blob_suite(void)
575651 tcase_add_test (tc , test_wolfBoot_store_blob_rejects_oversized_auth );
576652 tcase_add_test (tc , test_wolfBoot_read_blob_rejects_oversized_auth );
577653 tcase_add_test (tc , test_wolfBoot_delete_blob_rejects_oversized_auth );
654+ tcase_add_test (tc , test_wolfBoot_seal_auth_rejects_oversized_auth );
578655 tcase_add_test (tc , test_wolfBoot_read_blob_rejects_oversized_public_area );
579656 tcase_add_test (tc , test_wolfBoot_read_blob_rejects_oversized_private_area );
580657 tcase_add_test (tc , test_wolfBoot_unseal_blob_zeroes_unseal_output );
0 commit comments