5 #include "sw/device/silicon_creator/lib/boot_svc/boot_svc_ownership_unlock.h"
9 #include "gtest/gtest.h"
10 #include "sw/device/silicon_creator/lib/boot_svc/mock_boot_svc_header.h"
11 #include "sw/device/silicon_creator/testing/rom_test.h"
13 namespace boot_svc_ownership_unlock_unittest {
15 using ::testing::ElementsAreArray;
19 rom_test::MockBootSvcHeader boot_svc_header_;
24 constexpr uint32_t unlock_mode = kBootSvcUnlockAny;
27 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
29 107, 108, 109, 110, 111, 112, 113,
31 EXPECT_CALL(boot_svc_header_, Finalize(kBootSvcOwnershipUnlockReqType,
32 sizeof(msg), &msg.header));
34 boot_svc_ownership_unlock_req_init(unlock_mode,
nonce, &next_owner_key,
37 EXPECT_EQ(msg.unlock_mode, unlock_mode);
38 EXPECT_EQ(msg.nonce.value[0],
nonce.value[0]);
39 EXPECT_EQ(msg.nonce.value[1],
nonce.value[1]);
41 memcmp(&msg.next_owner_key, &next_owner_key,
sizeof(next_owner_key)), 0);
42 EXPECT_EQ(
memcmp(&msg.signature, &signature,
sizeof(signature)), 0);
45 TEST_F(BootSvcOwnershipUnlockTest, ResInit) {
47 constexpr rom_error_t kStatus = kErrorOk;
48 EXPECT_CALL(boot_svc_header_, Finalize(kBootSvcOwnershipUnlockResType,
49 sizeof(msg), &msg.header));
51 boot_svc_ownership_unlock_res_init(kStatus, &msg);
53 EXPECT_EQ(msg.status, kStatus);