Skip to content

Commit 73497f4

Browse files
jonathannilsenrlubos
authored andcommitted
[nrf noup] ironside_counters: use IronSide support package
Use the IronSide support package APIs instead of the counter API that was temporarily added in the zephyr repository. This consists of a few naming changes without any change in functionality. Signed-off-by: Jonathan Nilsen <jonathan.nilsen@nordicsemi.no>
1 parent 9425ecb commit 73497f4

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

boot/zephyr/ironside_counters/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
config NRF_MCUBOOT_IRONSIDE_COUNTERS
88
bool "Use IronSide counters for MCUBoot hardware downgrade prevention"
9-
depends on MCUBOOT_HW_DOWNGRADE_PREVENTION && NRF_IRONSIDE_COUNTER_SERVICE
9+
depends on MCUBOOT_HW_DOWNGRADE_PREVENTION && IRONSIDE_SE_CALL
1010
imply MCUBOOT_HW_DOWNGRADE_PREVENTION_LOCK
1111
help
1212
Use IronSide SE hardware counters to prevent rollback of firmware images

boot/zephyr/ironside_counters/ironside_counters.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
#include <stdint.h>
13-
#include <nrf_ironside/counter.h>
13+
#include <ironside/se/api.h>
1414
#include "bootutil/fault_injection_hardening.h"
1515
#include "bootutil/bootutil_public.h"
1616

@@ -30,15 +30,15 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
3030
FIH_RET(FIH_FAILURE);
3131
}
3232

33-
if (image_id > IRONSIDE_COUNTER_NUM) {
33+
if (image_id > IRONSIDE_SE_COUNTER_NUM) {
3434
FIH_RET(FIH_FAILURE);
3535
}
3636

3737
/* Since the IronSide service is not protected against fault injection,
3838
* read the counter multiple times and compare the results.
3939
*/
4040
for (i = 0; i < IRONSIDE_COUNTER_READ_RETRIES; i++) {
41-
if (ironside_counter_get(image_id, &cur_sec_cnt[i]) != 0) {
41+
if (ironside_se_counter_get(image_id, &cur_sec_cnt[i]) != 0) {
4242
FIH_RET(FIH_FAILURE);
4343
}
4444
}
@@ -49,7 +49,7 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
4949
}
5050
}
5151

52-
if (cur_sec_cnt[0] <= IRONSIDE_COUNTER_MAX_VALUE) {
52+
if (cur_sec_cnt[0] <= IRONSIDE_SE_COUNTER_MAX_VALUE) {
5353
*security_cnt = fih_int_encode(cur_sec_cnt[0]);
5454
FIH_RET(FIH_SUCCESS);
5555
}
@@ -59,11 +59,12 @@ fih_int boot_nv_security_counter_get(uint32_t image_id, fih_int *security_cnt)
5959

6060
int32_t boot_nv_security_counter_update(uint32_t image_id, uint32_t img_security_cnt)
6161
{
62-
if ((img_security_cnt > IRONSIDE_COUNTER_MAX_VALUE) || (image_id > IRONSIDE_COUNTER_NUM)) {
62+
if ((img_security_cnt > IRONSIDE_SE_COUNTER_MAX_VALUE) ||
63+
(image_id > IRONSIDE_SE_COUNTER_NUM)) {
6364
return -BOOT_EBADARGS;
6465
}
6566

66-
if (ironside_counter_set(image_id, img_security_cnt) != 0) {
67+
if (ironside_se_counter_set(image_id, img_security_cnt) != 0) {
6768
return -BOOT_EBADSTATUS;
6869
}
6970

@@ -79,7 +80,7 @@ fih_int boot_nv_security_counter_is_update_possible(uint32_t image_id, uint32_t
7980
if (FIH_EQ(fih_err, FIH_SUCCESS)) {
8081
int cnt = fih_int_decode(security_cnt);
8182

82-
if ((cnt <= IRONSIDE_COUNTER_MAX_VALUE) && (cnt <= img_security_cnt)) {
83+
if ((cnt <= IRONSIDE_SE_COUNTER_MAX_VALUE) && (cnt <= img_security_cnt)) {
8384
FIH_RET(FIH_SUCCESS);
8485
}
8586
}
@@ -89,11 +90,11 @@ fih_int boot_nv_security_counter_is_update_possible(uint32_t image_id, uint32_t
8990

9091
int32_t boot_nv_security_counter_lock(uint32_t image_id)
9192
{
92-
if (image_id > IRONSIDE_COUNTER_NUM) {
93+
if (image_id > IRONSIDE_SE_COUNTER_NUM) {
9394
return -BOOT_EBADARGS;
9495
}
9596

96-
if (ironside_counter_lock(image_id) != 0) {
97+
if (ironside_se_counter_lock(image_id) != 0) {
9798
return -BOOT_EBADSTATUS;
9899
}
99100

0 commit comments

Comments
 (0)