Add guarded nRF52 OTA rescue and SF5 test mode
This commit is contained in:
1 parent
710a6e02c5
commit
4a3d86ef98
14 files changed
+225
-47
No files matched your search
@@ -12,6 +12,7 @@
|
||||
#include "helpers/ota/OtaStore.h"
|
||||
#include "helpers/ota/OtaProtocol.h"
|
||||
#include "helpers/ota/OtaManager.h"
|
||||
#include "helpers/ota/OtaApply.h"
|
||||
#include "mota_vectors.h" // auto-generated by tools/mota/gen_vectors.py
|
||||
|
||||
extern "C" {
|
||||
@@ -64,6 +65,26 @@ TEST(OtaParse, ParsesReferenceContainer) {
|
||||
EXPECT_FALSE(m.is_approved());
|
||||
}
|
||||
|
||||
TEST(OtaRescue, RequiresInvalidSelfExactBaseAndExactTarget) {
|
||||
const uint8_t package_base[8] = {0x63, 0xd8, 0xdf, 0x63, 1, 2, 3, 4};
|
||||
const uint8_t operator_base[8] = {0x63, 0xd8, 0xdf, 0x63, 1, 2, 3, 4};
|
||||
const uint8_t wrong_base[8] = {0x63, 0xd8, 0xdf, 0x63, 1, 2, 3, 5};
|
||||
const uint32_t target_id = 0x2FA509C1u;
|
||||
|
||||
EXPECT_EQ(ota_nrf52_rescue_gate(false, package_base, operator_base,
|
||||
target_id, target_id), NRF52_RESCUE_OK);
|
||||
EXPECT_EQ(ota_nrf52_rescue_gate(true, package_base, operator_base,
|
||||
target_id, target_id), NRF52_RESCUE_SELF_VALID);
|
||||
EXPECT_EQ(ota_nrf52_rescue_gate(false, nullptr, operator_base,
|
||||
target_id, target_id), NRF52_RESCUE_BASE_MISSING);
|
||||
EXPECT_EQ(ota_nrf52_rescue_gate(false, package_base, wrong_base,
|
||||
target_id, target_id), NRF52_RESCUE_BASE_MISMATCH);
|
||||
EXPECT_EQ(ota_nrf52_rescue_gate(false, package_base, operator_base,
|
||||
target_id, target_id + 1), NRF52_RESCUE_TARGET_MISMATCH);
|
||||
EXPECT_EQ(ota_nrf52_rescue_gate(false, package_base, operator_base,
|
||||
target_id, 0), NRF52_RESCUE_TARGET_MISMATCH);
|
||||
}
|
||||
|
||||
TEST(OtaParse, RejectsTampering) {
|
||||
MotaManifest m;
|
||||
// bad magic
|
||||
|
||||
Reference in new issue
Block a user