Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

0x27 SecurityAccess Protocol Flow

SecurityAccess Two-Step Exchange
  Tester → ECU:  0x27 0x01          (requestSeed; subFunction = level*2-1)
  ECU → Tester:  0x67 0x01 [seed]   (positive: 4–16 random seed bytes)
       │
       ├── Tester computes: key = f(seed, secret_constant)
       │
  Tester → ECU:  0x27 0x02 [key]    (sendKey; subFunction = level*2)
  ECU verifies:  expected_key = f(seed, secret_constant)

  ┌─────────────────────────────────────────────────────────────────┐
  │ Match   → ECU → Tester: 0x67 0x02  (positive; no data)         │
  │ Mismatch→ ECU → Tester: 0x7F 0x27 0x35 (NRC: invalidKey)       │
  │ 5 failures → ECU → Tester: 0x7F 0x27 0x36 (exceededAttempts)   │
  │            → ECU enters 10-minute lockout                       │
  └─────────────────────────────────────────────────────────────────┘

  Security levels:
  Level 1: subFunction 0x01/0x02 — workshop access (write DID, IO control)
  Level 2: subFunction 0x03/0x04 — reprogramming access (download/transfer)
  Levels can be OEM-extended to 0x41–0x5E (unlimited levels)

Seed-Key Algorithm Design

Cseed_key_algo.c
/* Seed-key algorithm: NEVER use the examples below in production!
   These illustrate the pattern; real algorithms are OEM-proprietary secrets. */
#include 

/* PROHIBITED example (trivially cracked): key = seed + constant
   Real attack: extract seed from CAN trace; add known constant = instant bypass */
uint32_t bad_seed_key(uint32_t seed) {
    return seed + 0x12345678u;  /* do NOT use this */
}

/* BETTER: HMAC-SHA256 based seed-key (ISO 26021-compliant pattern)
   Secret is a 256-bit OEM key stored in HSM; never in application flash */
#include "Csm.h"

Std_ReturnType SecAcc_ComputeKey(const uint8* seed, uint8 seed_len,
                                  uint8* key_out, uint8* key_len_out)
{
    uint8 hmac_result[32];
    /* Csm_MacGenerate: uses HSM key slot; secret never leaves HSM */
    Std_ReturnType r = Csm_MacGenerate(
        CSM_JOB_SECACC_HMAC,      /* pre-configured HMAC-SHA256 job */
        CRYPTO_OPERATIONMODE_SINGLECALL,
        seed, seed_len,
        hmac_result, NULL
    );
    if (r != E_OK) return E_NOT_OK;

    /* Truncate to 4 bytes for CAN compatibility (classic UDS key length) */
    key_out[0] = hmac_result[0]; key_out[1] = hmac_result[1];
    key_out[2] = hmac_result[2]; key_out[3] = hmac_result[3];
    *key_len_out = 4;
    return E_OK;
}

/* Seed generation: MUST use TRNG, not pseudo-random
   Predictable seed → known-plaintext attack on seed-key function */
Std_ReturnType SecAcc_GenerateSeed(uint8* seed_out, uint8 seed_len) {
    return Csm_RandomGenerate(CSM_JOB_SECACC_TRNG, seed_out, seed_len);
}

Lockout and Delay Mechanisms

ParameterISO 14229 RequirementTypical OEM Value
Max attempts before lockoutNot specified; typically 53–5 failed sendKey attempts
Lockout durationNot specified10 minutes; persists across ECU reset in NvM
Delay after failed attemptrequiredTimeDelayNotExpired (NRC 0x37)10 seconds between attempts during lockout
Lockout scopePer security level; Level 1 lockout does not affect Level 2 seed requestOEM-specific
ECU reset during lockoutLockout persists (NvM-stored)Required by most OEMs to prevent reset-to-bypass

AUTOSAR DCM Security Access Configuration

XMLDcm_Security.arxml


  SecurityLevel1
  0x01   
  4   
  4    
  5  
  600000   
  true

  
  SecAcc_L1_GetSeed
  SecAcc_L1_CompareKey

  
  
    ExtendedDiagnosticSession
  

Summary

SecurityAccess 0x27 is symmetric key authentication — the shared secret is the seed-key algorithm and its constants. The algorithm MUST be HSM-backed: storing the secret in application flash allows firmware extraction attacks to recover it. A 256-bit HMAC-SHA256 seed-key (truncated to 4 bytes for CAN) provides far better security than any XOR/shift algorithm — the difference is that breaking HMAC requires breaking SHA-256; breaking an XOR algorithm requires one known seed-key pair from a CAN trace. NRC 0x37 (delay not expired) and NvM-persisted lockout counters are the brute-force countermeasures.

🔬 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

  1. 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'.
  2. 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.
  3. 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.
  4. 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.

← PreviousHands-On: DTC Configuration & TestingNext →Authentication (0x29) Certificate-Based