Learning objectives and scope
This guide explains how automotive ECUs protect messages exchanged over in-vehicle networks. It distinguishes authenticity, integrity, freshness and confidentiality; describes message-level protection; and examines key management, replay handling, timing and verification.
The design examples are conceptual. The exact mechanism depends on the network technology, communication stack, threat analysis, timing budget, ECU resources and OEM security architecture. A MAC-based protection profile is not interchangeable with transport security such as TLS, and neither should be selected without considering the communication endpoints and system requirements.
1. Security properties
A secure communication design may require one or more of the following properties:
| Property | Engineering meaning | Typical mechanism |
|---|---|---|
| Authenticity | The receiver can verify that a message was produced by an authorized entity | MAC or digital signature, supported by key management |
| Integrity | Unauthorized modification of protected data can be detected | MAC or authenticated encryption |
| Freshness | Previously valid traffic cannot simply be replayed as current | Counter, timestamp, nonce or challenge-based state |
| Confidentiality | Message content is concealed from unauthorized observers | Encryption, commonly symmetric encryption for constrained endpoints |
| Availability | Required communication remains available within defined limits | Resilience, rate limiting, fault handling and network design |
Authenticity and integrity are often provided together by a Message Authentication Code (MAC). A MAC does not encrypt the payload. Encryption addresses confidentiality, but encryption without authentication may still permit manipulation or replay depending on the mode and protocol. Authenticated encryption can provide confidentiality and integrity/authenticity when correctly configured, but freshness and key lifecycle still need explicit design.
2. Threats on in-vehicle networks
A threat analysis should consider the attacker’s access, capabilities and objectives. Relevant threats can include:
- Message injection: introducing fabricated messages onto a network.
- Message modification: changing signal or control data in transit.
- Replay: retransmitting a previously valid message.
- Impersonation: sending messages while claiming to be another ECU.
- Key compromise: obtaining a secret that enables creation of valid protected traffic.
- Denial of service: consuming bandwidth or ECU processing resources so legitimate traffic is delayed or lost.
- Gateway abuse: exploiting routing, filtering or protocol translation between network segments.
Protection at message level does not eliminate all these threats. For example, a valid MAC does not prevent a compromised authorized sender from transmitting unsafe values, and message authentication alone does not guarantee network availability.
3. Message-level protection architecture
A typical message-level design places protection logic at the sending and receiving communication endpoints. The sender constructs the data to be protected, associates freshness information, calculates an authenticator using a configured key and transmits the protected message. The receiver validates freshness and the authenticator before making the data available to the consuming function.
This is a conceptual architecture, not a mandatory placement for every vehicle network. Protection may be implemented in an AUTOSAR communication stack, a network protocol, a gateway, a transport layer or dedicated hardware. The placement determines which fields are authenticated and which components are trusted.
3.1 Sender processing
A typical sender-side sequence is:
- Obtain the application data and identify the configured message.
- Obtain or update the freshness value according to the sender's state-management policy.
- Construct the authenticated data according to the agreed profile. This may include selected payload bytes, message identity, freshness information and other context.
- Calculate the MAC or authenticated-encryption tag using the configured cryptographic key.
- Assemble the transmitted message, including the fields required by the receiver.
- Transmit within the configured cycle time and deadline.
3.2 Receiver processing
A typical receiver-side sequence is:
- Receive the message and perform basic format and length checks.
- Reconstruct or validate the freshness context using receiver state and the configured synchronization policy.
- Recreate the authenticated input exactly as specified by the profile.
- Calculate or verify the authenticator using the corresponding key.
- Accept the data only if all required checks pass.
- Update freshness state only according to the specified acceptance procedure.
- On failure, reject or invalidate the data and apply the defined diagnostic and application reaction.
The order and exact freshness algorithm are profile-dependent. In particular, freshness state must not be advanced merely because a frame arrived; state updates need to follow the defined successful-validation rules.
4. MAC, hash, signature and encryption
These cryptographic primitives serve different purposes:
- Cryptographic hash: maps input data to a fixed-length digest. A hash alone does not identify who created the data.
- MAC: uses a shared secret key to authenticate data and detect modification. Any party holding the shared key may be able to generate a valid MAC.
- Digital signature: uses a private signing key and corresponding public verification key. It is commonly used for software authenticity and other cases where asymmetric verification is appropriate.
- Encryption: transforms plaintext into ciphertext to protect confidentiality. Encryption by itself should not be treated as proof of sender authenticity.
- Authenticated encryption: combines encryption and integrity/authenticity protection under a defined algorithm and usage profile.
For many cyclic in-vehicle signals, a MAC-based mechanism can be more practical than a digital signature on every message because of payload size, execution time and key-management considerations. This is a design choice, not a universal rule.
5. Freshness and replay protection
A message that was valid yesterday—or even one communication cycle ago—may be dangerous if accepted as current. Freshness allows a receiver to distinguish new traffic from previously accepted traffic.
Common freshness inputs include:
- Rolling counters: increment as messages are sent.
- Timestamps: represent a time value, requiring a suitable time base and synchronization.
- Nonces or challenges: values intended for one-time use or a defined session.
- Combined freshness values: may combine a transmitted portion with receiver-maintained state.
5.1 Counter-window example
Assume a protected cyclic message carries a rolling counter. The receiver maintains freshness state and accepts values according to a configured synchronization and loss policy. For a conceptual example, if the receiver expects counter 100 and the configured acceptance window permits a small forward gap, a message carrying 101 may be accepted while an already accepted value 99 is rejected.
A receiver that accepts an excessively wide window may admit stale traffic. A receiver that requires every counter value in strict sequence may reject legitimate traffic after ordinary frame loss. The counter width, window, rollover, persistence, synchronization and resynchronization behavior must be derived from the threat analysis and network behavior.
5.2 Loss, restart and rollover
The design must define behavior for:
- Lost or delayed frames.
- Multiple consecutive message drops.
- Counter wraparound.
- Sender reset while receiver remains active.
- Receiver reset while sender continues transmitting.
- Sleep/wake transitions and power loss.
- Re-establishment of freshness after service or recovery.
Do not assume that resetting a counter to zero is safe. If freshness state is resettable by an attacker, old captured traffic may become valid again. Protected persistent state, controlled synchronization or a protocol-specific recovery procedure may be required.
6. Key management and compromise containment
Cryptographic protection is only as strong as its key lifecycle. The project should document:
- Generation: approved entropy source, algorithm and key-generation process.
- Provisioning: secure association of keys with ECU identity, vehicle variant and communication role.
- Storage: protected storage such as an HSM or secure element where supported; restrict software access to key material.
- Use: define which software components may request cryptographic operations and for which message profiles.
- Rotation: define key replacement intervals or triggering events.
- Revocation and compromise response: define how a compromised or obsolete key is disabled and replaced.
- Decommissioning: securely remove or invalidate keys when an ECU or vehicle leaves service.
Shared group keys reduce provisioning complexity but increase compromise blast radius: compromise of one member may enable impersonation within the group. Pairwise or sender-specific keys can improve isolation but increase key-management complexity. Choose the model based on threat analysis, ECU count, communication topology and recovery requirements.
Never expose secret key material in logs, diagnostic responses, calibration interfaces or test reports. Manufacturing, development and service modes must have explicit access controls and must not silently weaken production security policy.
7. AUTOSAR SecOC and other protection approaches
In AUTOSAR Classic, Secure Onboard Communication (SecOC) is a standardized mechanism for authenticating selected I-PDUs using freshness information and an authenticator. Its configuration defines such items as the protected PDU, authenticated data, freshness handling and cryptographic profile. The exact configuration and module interactions depend on the AUTOSAR release, ECU configuration and vendor implementation.
SecOC is not synonymous with all automotive secure communication. Other systems may use authenticated transport protocols, secure diagnostic sessions, SOME/IP protection profiles, IPsec, TLS or mechanisms defined by the relevant network technology. Select the mechanism at the layer that matches the threat model and endpoints; avoid stacking protections without understanding their combined latency, overhead and failure behavior.
A conceptual AUTOSAR communication path may involve COM, PduR, SecOC and lower communication interface/driver modules. The exact direction and module path depend on the configured architecture and PDU routing. Do not infer a universal call sequence from a simplified diagram.
8. Performance and network integration
Protection introduces computational and communication overhead. Evaluate the complete worst-case path, not only average CPU utilization.
| Design parameter | Engineering question |
|---|---|
| Tag length | Is the selected authenticator length sufficient for the threat model and profile? |
| Freshness length | How much freshness information is transmitted, and how is the remainder reconstructed? |
| Payload overhead | Does the protected message still fit the network's frame and segmentation constraints? |
| Bus load | What is the effect on utilization, arbitration and lower-priority message latency? |
| Execution time | Can sender and receiver cryptographic operations meet their deadlines under worst-case load? |
| Startup synchronization | How long until protected communication is available after ECU wake-up? |
| Failure handling | What happens after repeated authentication failures or freshness loss? |
| Gateway behavior | Are authenticated fields preserved, transformed or re-authenticated across segments? |
For CAN or CAN FD, additional bytes can affect frame selection, bus load and timing. For Ethernet-based communication, consider endpoint authentication, session establishment, packet processing and gateway policy. Do not assume that a mechanism designed for one network can be moved to another without re-evaluating its constraints.
9. Worked replay-protection verification example
Consider a cyclic message carrying a signal and a rolling counter. The receiver has an established freshness state.
| Test step | Stimulus | Expected result |
|---|---|---|
| 1 | Send a valid message with an acceptable fresh counter and correct MAC | Message accepted |
| 2 | Replay the exact previously accepted frame | Rejected as stale/replayed |
| 3 | Modify a protected payload bit without recalculating the MAC | Authentication fails |
| 4 | Send a counter outside the configured acceptance window | Defined reject or resynchronization behavior |
| 5 | Drop several consecutive frames | Receiver follows the specified loss policy |
| 6 | Exercise counter rollover | Freshness remains unambiguous under the defined algorithm |
| 7 | Reset sender or receiver | Freshness is re-established without accepting old traffic |
| 8 | Use an incorrect key | Authentication fails |
| 9 | Cause repeated invalid messages | Defined diagnostic, rate-limit and application reaction occurs |
The test report should record the configured profile, key reference (never the key itself), freshness state, input frame, expected result, observed result and relevant timing. Use controlled test keys and isolated test environments.
10. Authentication failure handling
A security failure must be translated into a defined system response. Possible actions include rejecting the message, marking the signal invalid, reporting a diagnostic event, applying a timeout strategy or transitioning the consuming function to a defined degraded state.
The correct response depends on the signal's role. A non-critical comfort feature may tolerate a temporary loss of data; a safety-related control function may require a different timeout and fallback strategy. Security logic must coordinate with functional-safety requirements rather than inventing an independent fallback.
Avoid logging raw secrets or excessive attacker-controlled payload data. Diagnostics should provide enough context to support service and engineering investigation without exposing sensitive information or creating a denial-of-service amplification path.
11. Common design mistakes
- Treating encryption as a substitute for message authentication.
- Omitting freshness from a replay-sensitive design.
- Reusing a shared key without evaluating compromise blast radius.
- Failing to define counter rollover, loss tolerance and restart synchronization.
- Updating receiver freshness state before successful validation.
- Authenticating payload bytes but overlooking security-relevant identifiers or metadata.
- Measuring average CPU load instead of worst-case execution time.
- Ignoring gateway transformations and routing behavior.
- Allowing manufacturing or debug modes to bypass production policy.
- Defining authentication-failure behavior without coordinating with safety and availability requirements.
12. Engineering design checklist
For every protected message, document:
- Sender identity and authorized receiver set.
- Network, message identifier and communication cycle.
- Fields included in authenticated data.
- Freshness source, counter width, window and synchronization procedure.
- Cryptographic algorithm, tag length and key reference.
- Key provisioning, storage, rotation and revocation process.
- Added payload bytes, bus load and worst-case processing time.
- Startup, sleep/wake, reset and recovery behavior.
- Gateway handling and trust boundaries.
- Failure reaction, diagnostics and application timeout behavior.
- Positive, negative, boundary, fault-injection and regression tests.
FAQ
Does a MAC encrypt data?
No. A MAC authenticates data and detects unauthorized modification; it does not conceal the payload.
Can freshness be implemented using a counter?
Yes. Counter width, persistence, synchronization, loss tolerance and rollover policy must be designed for the specific network and threat model.
Is TLS suitable for every in-vehicle message?
No. TLS is designed for transport-layer security in suitable client/server or endpoint communication architectures. Many cyclic in-vehicle signals use different message-level protection mechanisms.
Does message authentication prevent denial of service?
No. Authentication can reject forged or modified traffic, but it does not by itself guarantee bandwidth or processing availability.
Is AUTOSAR SecOC the same as secure boot?
No. Secure boot authenticates software during startup. SecOC protects configured communication messages during operation.
References and project caveat
Use the applicable AUTOSAR specification and release, network-protocol specification, cryptographic library documentation, OEM security architecture and key-management policy. Treat the diagrams and sequences in this article as conceptual engineering examples, not normative profiles. Confirm exact algorithms, configuration parameters, module interfaces and failure behavior against the licensed specifications and project requirements.
