| Component | Specification | Role in Secure Boot |
|---|---|---|
| eHSM CPU | ARM Cortex-M @ 200 MHz; fully isolated from TC397 app CPUs | Boots first; verifies application before releasing CPU execution |
| Crypto engines | AES-128/256, RSA-2048, ECDSA P-256, SHA-256/512, TRNG | All crypto offloaded; no secret key material ever in application CPU RAM |
| HSM RAM | 512 kB dedicated; no shared memory with application | Key material and verification code inaccessible to application CPU |
| Key fusing | OTP one-time-programmable fuses for ECDSA public key SHA-256 hash | Hardware root of trust; irreversible after production fusing |
| SHE+ compat | SHE-compatible CMD interface + RSA/ECC extensions | Existing SHE tools work; eHSM adds asymmetric capability |
Target Hardware: Infineon Aurix TC397 eHSM
HSM Configuration and Boot MAC Programming
/* Aurix TC3xx eHSM: secure boot MAC programming */
/* Steps: 1) Enable SecureBoot in HSM_SB_CTRL 2) Program BOOT_MAC 3) Fuse ECDSA pubkey hash */
#include "HSM_Api.h"
/* Step 1: Enable secure boot mode */
void HSM_EnableSecureBoot(void) {
HSM_WriteSBControl(HSM_SB_CTRL_ENABLE | HSM_SB_CTRL_CMAC_VERIFY_APP);
}
/* Step 2: Compute and store BOOT_MAC in protected NVM slot */
/* BOOT_MAC = AES-128-CMAC(BOOT_MAC_KEY, addr[4] || len[4] || SHA-256(BootSW)[32]) */
void HSM_ProgramBootMAC(uint32 boot_start, uint32 boot_len, const uint8* sha256)
{
uint8 input[48], mac[16];
memcpy(input, &boot_start, 4);
memcpy(input+4, &boot_len, 4);
memcpy(input+8, sha256, 32);
HSM_CMAC_Generate(SHE_BOOT_MAC_KEY, input, 48, mac);
HSM_WriteProtectedNVM(HSM_NVM_BOOT_MAC, mac, 16);
HSM_LockSlot(SHE_BOOT_MAC_KEY, HSM_LOCK_WRITE); /* irreversible */
}
/* Step 3: Fuse ECDSA P-256 public key SHA-256 hash into OTP (irreversible) */
void HSM_FuseECDSAPublicKeyHash(const uint8* pubkey_sha256_32B) {
HSM_OTP_Write(OTP_PAGE_PUBKEY_HASH_0, pubkey_sha256_32B, 16);
HSM_OTP_Write(OTP_PAGE_PUBKEY_HASH_1, pubkey_sha256_32B+16, 16);
HSM_OTP_LockPage(OTP_PAGE_PUBKEY_HASH_0);
HSM_OTP_LockPage(OTP_PAGE_PUBKEY_HASH_1);
}AUTOSAR SecBoot Module Configuration
SecBootConfig_TCU
AES128_CMAC
/Crypto/Keys/HSM_BOOT_MAC_KEY
0x80000000
0x00100000
ECDSA_P256_SHA256
/Crypto/Keys/HSM_OTA_ECDSA_PUBKEY
/BswM/BswMConfig/Modes/BOOT_FAILURE
Secure Boot Test Cases and Attack Simulation
#!/usr/bin/env python3
test_cases = [
{"id":"SB-01","type":"positive",
"name":"Valid signed firmware -- normal boot",
"action":"Flash ECDSA-signed image; power cycle",
"expected":"E_OK; BOOT_VERIFIED DET log; normal BSW init"},
{"id":"SB-02","type":"negative",
"name":"Single-byte flash corruption",
"action":"Flip bit 3 of byte at 0x80001000",
"expected":"HSM CMAC mismatch; BOOT_FAILURE state; DCM activates programming session"},
{"id":"SB-03","type":"negative",
"name":"Wrong signing key",
"action":"Load image signed with non-OEM test key",
"expected":"ECDSA verification fails; BOOT_FAILURE; no application execution"},
{"id":"SB-04","type":"attack",
"name":"BOOT_MAC NVM overwrite via UDS",
"action":"Send UDS WriteMemoryByAddress targeting BOOT_MAC NVM; no SecurityAccess",
"expected":"NRC 0x31; HSM write-protection blocks; BOOT_MAC unchanged"},
{"id":"SB-05","type":"attack",
"name":"Version rollback via OTA",
"action":"Deliver OTA package with version 0x0201 when ECU has 0x0302",
"expected":"Anti-rollback check fails; package rejected; current firmware unchanged"},
]
for tc in test_cases:
icon = "✓" if tc["type"]=="positive" else ("⚠" if tc["type"]=="negative" else "🔴")
print(f"[{icon}] {tc['id']} [{tc['type'].upper()}]: {tc['name']}")
print(f" Action: {tc['action']}")
print(f" Expected: {tc['expected']}")
print()Summary
Aurix TC3xx eHSM secure boot is a chained verification model: each stage must pass before the next executes, and failure halts execution and triggers a recovery programming session. The OTP-fused ECDSA public key hash is the only truly immutable component -- it cannot be overridden by OTA, software exploit, or NVM write. All five test categories must pass: positive (valid image), corruption detection, wrong-key rejection, NVM write protection, and version rollback prevention.
🔬 Deep Dive — Core Concepts Expanded
This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.
Key principles to reinforce:
- Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
- Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
- Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.
🏭 How This Topic Appears in Production Projects
- Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
- Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
- Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.
⚠️ Common Mistakes and How to Avoid Them
- Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
- Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
- Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
- Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.
📊 Industry Note
Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.