@@ -692,11 +692,11 @@ boot_image_check(struct boot_loader_state *state, struct image_header *hdr,
692692 */
693693#if defined(MCUBOOT_ENC_IMAGES ) && !defined(MCUBOOT_RAM_LOAD )
694694 if (MUST_DECRYPT (fap , BOOT_CURR_IMG (state ), hdr )) {
695- rc = boot_enc_load (state , 1 , hdr , fap , bs );
695+ rc = boot_enc_load (state , BOOT_SLOT_SECONDARY , hdr , fap , bs );
696696 if (rc < 0 ) {
697697 FIH_RET (fih_rc );
698698 }
699- if (rc == 0 && boot_enc_set_key (BOOT_CURR_ENC (state ), 1 , bs )) {
699+ if (rc == 0 && boot_enc_set_key (BOOT_CURR_ENC (state ), BOOT_SLOT_SECONDARY , bs )) {
700700 FIH_RET (fih_rc );
701701 }
702702 }
@@ -1547,7 +1547,7 @@ boot_copy_image(struct boot_loader_state *state, struct boot_status *bs)
15471547 if (rc < 0 ) {
15481548 return BOOT_EBADIMAGE ;
15491549 }
1550- if (rc == 0 && boot_enc_set_key (BOOT_CURR_ENC (state ), 1 , bs )) {
1550+ if (rc == 0 && boot_enc_set_key (BOOT_CURR_ENC (state ), BOOT_SLOT_SECONDARY , bs )) {
15511551 return BOOT_EBADIMAGE ;
15521552 }
15531553 }
@@ -1665,17 +1665,17 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
16651665#ifdef MCUBOOT_ENC_IMAGES
16661666 if (IS_ENCRYPTED (hdr )) {
16671667 fap = BOOT_IMG_AREA (state , BOOT_SLOT_PRIMARY );
1668- rc = boot_enc_load (state , 0 , hdr , fap , bs );
1668+ rc = boot_enc_load (state , BOOT_SLOT_PRIMARY , hdr , fap , bs );
16691669 assert (rc >= 0 );
16701670
16711671 if (rc == 0 ) {
1672- rc = boot_enc_set_key (BOOT_CURR_ENC (state ), 0 , bs );
1672+ rc = boot_enc_set_key (BOOT_CURR_ENC (state ), BOOT_SLOT_PRIMARY , bs );
16731673 assert (rc == 0 );
16741674 } else {
16751675 rc = 0 ;
16761676 }
16771677 } else {
1678- memset (bs -> enckey [0 ], 0xff , BOOT_ENC_KEY_ALIGN_SIZE );
1678+ memset (bs -> enckey [BOOT_SLOT_PRIMARY ], 0xff , BOOT_ENC_KEY_ALIGN_SIZE );
16791679 }
16801680#endif
16811681
@@ -1689,17 +1689,17 @@ boot_swap_image(struct boot_loader_state *state, struct boot_status *bs)
16891689 hdr = boot_img_hdr (state , BOOT_SLOT_SECONDARY );
16901690 if (IS_ENCRYPTED (hdr )) {
16911691 fap = BOOT_IMG_AREA (state , BOOT_SLOT_SECONDARY );
1692- rc = boot_enc_load (state , 1 , hdr , fap , bs );
1692+ rc = boot_enc_load (state , BOOT_SLOT_SECONDARY , hdr , fap , bs );
16931693 assert (rc >= 0 );
16941694
16951695 if (rc == 0 ) {
1696- rc = boot_enc_set_key (BOOT_CURR_ENC (state ), 1 , bs );
1696+ rc = boot_enc_set_key (BOOT_CURR_ENC (state ), BOOT_SLOT_SECONDARY , bs );
16971697 assert (rc == 0 );
16981698 } else {
16991699 rc = 0 ;
17001700 }
17011701 } else {
1702- memset (bs -> enckey [1 ], 0xff , BOOT_ENC_KEY_ALIGN_SIZE );
1702+ memset (bs -> enckey [BOOT_SLOT_SECONDARY ], 0xff , BOOT_ENC_KEY_ALIGN_SIZE );
17031703 }
17041704#endif
17051705
0 commit comments