@@ -45,6 +45,15 @@ int WP11_Library_Init(void);
4545
4646#ifdef EXT_ENCRYPTED
4747#include "encrypt.h"
48+
49+ static void wolfBoot_zeroize (void * ptr , size_t len )
50+ {
51+ volatile uint8_t * p = (volatile uint8_t * )ptr ;
52+
53+ while (len -- > 0 ) {
54+ * p ++ = 0 ;
55+ }
56+ }
4857#endif /* EXT_ENCRYPTED */
4958
5059#ifdef MMU
@@ -307,8 +316,8 @@ static int RAMFUNCTION wolfBoot_copy_sector(struct wolfBoot_image *src,
307316out :
308317#endif
309318#ifdef EXT_ENCRYPTED
310- ForceZero (key , sizeof (key ));
311- ForceZero (nonce , sizeof (nonce ));
319+ wolfBoot_zeroize (key , sizeof (key ));
320+ wolfBoot_zeroize (nonce , sizeof (nonce ));
312321#endif
313322 return ret ;
314323}
@@ -365,8 +374,8 @@ static int RAMFUNCTION wolfBoot_backup_last_boot_sector(uint32_t sector)
365374 ret = wolfBoot_copy_sector (src , dst , sector );
366375 }
367376out :
368- ForceZero (key , sizeof (key ));
369- ForceZero (nonce , sizeof (nonce ));
377+ wolfBoot_zeroize (key , sizeof (key ));
378+ wolfBoot_zeroize (nonce , sizeof (nonce ));
370379 return ret ;
371380}
372381#else
@@ -722,8 +731,8 @@ static int wolfBoot_delta_update(struct wolfBoot_image *boot,
722731 }
723732out :
724733#ifdef EXT_ENCRYPTED
725- ForceZero (key , sizeof (key ));
726- ForceZero (nonce , sizeof (nonce ));
734+ wolfBoot_zeroize (key , sizeof (key ));
735+ wolfBoot_zeroize (nonce , sizeof (nonce ));
727736#endif
728737#ifdef EXT_FLASH
729738 ext_flash_lock ();
0 commit comments