File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -1279,15 +1279,15 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
12791279 } else {
12801280 rc = 0 ;
12811281 }
1282-
12831282#ifdef MCUBOOT_ENC_SCRATCH
1284- rc = boot_enc_init (BOOT_CURR_ENC (state ), 2 );
1285- assert (rc == 0 );
1286-
1287- rc = boot_enc_set_key (BOOT_CURR_ENC (state ), 2 , bs );
1288- assert (rc == 0 );
1283+ if (BOOT_CURR_ENC (state )[1 ].valid ) {
1284+ memcpy (bs -> enckey [2 ], bs -> enckey [1 ], BOOT_ENC_KEY_SIZE );
1285+ rc = boot_enc_init (BOOT_CURR_ENC (state ), 2 );
1286+ assert (rc == 0 );
1287+ rc = boot_enc_set_key (BOOT_CURR_ENC (state ), 2 , bs );
1288+ assert (rc == 0 );
1289+ }
12891290#endif
1290-
12911291 } else {
12921292 memset (bs -> enckey [1 ], 0xff , BOOT_ENC_KEY_SIZE );
12931293 }
@@ -1323,6 +1323,7 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
13231323 boot_enc_set_key (BOOT_CURR_ENC (state ), slot , bs );
13241324#ifdef MCUBOOT_ENC_SCRATCH
13251325 if (slot == BOOT_SECONDARY_SLOT ) {
1326+ memcpy (bs -> enckey [2 ], bs -> enckey [1 ], BOOT_ENC_KEY_SIZE );
13261327 boot_enc_set_key (BOOT_CURR_ENC (state ), 2 , bs );
13271328 }
13281329#endif
You can’t perform that action at this time.
0 commit comments