File tree 1 file changed +8
-7
lines changed
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)
1279
1279
} else {
1280
1280
rc = 0 ;
1281
1281
}
1282
-
1283
1282
#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
+ }
1289
1290
#endif
1290
-
1291
1291
} else {
1292
1292
memset (bs -> enckey [1 ], 0xff , BOOT_ENC_KEY_SIZE );
1293
1293
}
@@ -1323,6 +1323,7 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
1323
1323
boot_enc_set_key (BOOT_CURR_ENC (state ), slot , bs );
1324
1324
#ifdef MCUBOOT_ENC_SCRATCH
1325
1325
if (slot == BOOT_SECONDARY_SLOT ) {
1326
+ memcpy (bs -> enckey [2 ], bs -> enckey [1 ], BOOT_ENC_KEY_SIZE );
1326
1327
boot_enc_set_key (BOOT_CURR_ENC (state ), 2 , bs );
1327
1328
}
1328
1329
#endif
You can’t perform that action at this time.
0 commit comments