File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 2323#include <inttypes.h>
2424
2525#define PUBKEYS 5
26- #define EXP_PUBKEYS 5
26+ #define BLK_v2_0_0_PUBKEYS 5
2727#define PUBKEY_LENGTH 65
2828#define SIGNATURES 3
2929
Original file line number Diff line number Diff line change @@ -84,9 +84,18 @@ static bool canDropPrivs(void) {
8484 case BLK_v1_1_0 :
8585 return true;
8686 case BLK_v2_0_0 :
87- case BLK_v2_1_0 :
87+ case BLK_v2_1_0 : {
8888 // sigs already checked in bootloader. If a sig is present we are in priv mode, drop privs.
89- return * ((uint8_t * )FLASH_META_SIGINDEX1 ) != 0 ;
89+ fi_defense_delay (); // delay before the fetch from flash
90+ uint8_t sigindex1 = * ((uint8_t * )FLASH_META_SIGINDEX1 );
91+ // Future signature format enhancements may use higher indexes for different keys, but
92+ // existing v2 bootloaders only recognize signatures up to BLK_v2_0_0_PUBKEYS. As such,
93+ // even if a sig with a higher index is present, these bootloaders will have dropped privs
94+ // by this point already, and trying to drop privs *again* will cause a fault.
95+ bool sigPresent = sigindex1 >= 1 && sigindex1 <= BLK_v2_0_0_PUBKEYS ;
96+ // delay before the security-critical branch instruction
97+ return !fi_defense_delay (sigPresent );
98+ }
9099 }
91100 __builtin_unreachable ();
92101}
You can’t perform that action at this time.
0 commit comments