Skip to main content
← Back to Blog
Embedded SoftwareApril 30, 2026 • 12 min read

AUTOSAR Crypto Stack: Csm, CryIf, KeyM — Implementation Guide for Automotive ECUs

By Shreyansh, Founder & CTO, Agnile Technologies

Key Takeaways

TL;DR — The AUTOSAR Classic Crypto Stack layers four cooperating modules: Csm (application-facing job-based crypto operations plus a direct key-management API), CryIf (channel and key-slot routing), the Crypto Driver (Hardware Security Module-backed or software fallback), and KeyM (certificate and key lifecycle). Done right, it gives Secure Onboard Communication, secure boot, and secure diagnostics a single crypto API structured for audit review and a clean ASIL-grade qualification path. Done wrong — soft-fallback overuse, async callback races, broken key-slot routing — it generates the most expensive integration debt in a Classic Platform programme.

  1. 1.The AUTOSAR Classic Crypto Stack consists of four cooperating modules: Csm (Crypto Service Manager), CryIf (Crypto Interface), the Crypto Driver (vendor Hardware Security Module driver or software fallback), and KeyM (Key Manager).
  2. 2.Csm exposes a job-based API for cryptographic operations, with each job configured for asynchronous processing (priority queues and callback notifications) or synchronous processing for low-latency primitives such as a hash on a small buffer, plus a direct synchronous API mainly for key management.
  3. 3.CryIf maps Csm jobs to channels, channels to Crypto Driver Objects, and key slots to driver instances; misconfiguration here is one of the two recurring sources of integration bugs, alongside async callback races.
  4. 4.The Crypto Driver typically arrives as a vendor Basic Software package for the silicon's Hardware Security Module; a pure software driver provides a development fallback but should not hold high-value keys in production.
  5. 5.KeyM handles X.509 certificate chains, trusted-time evaluation, and key element storage; it is the right module to centralise key-lifecycle code rather than spreading it across applications.
  6. 6.Secure Onboard Communication, secure diagnostics with UDS service 0x29 authentication, and post-boot signature verification all flow through the same Crypto Stack, which provides a single audit point for ISO/SAE 21434 Clause 10 cryptographic-control evidence.
  7. 7.AUTOSAR Adaptive's ara::crypto Functional Cluster preserves the same architectural intent — application-facing API, internal routing, driver-level execution, key lifecycle — with a C++ object-oriented surface.

At a Glance

One-Sentence Answer
AUTOSAR Crypto Stack components such as CSM, CryIf, Crypto Driver, and KeyM help structure cryptographic services in automotive software.
Who This Is For
AUTOSAR engineers, crypto-stack integrators, ECU software teams, cybersecurity engineers, and embedded platform teams.
Last Reviewed
October 2026
Primary References
AUTOSAR Classic, CSM, CryIf, Crypto Driver, KeyM, HSM, automotive cryptography.
Practical Use
Use this guide to understand how cryptographic requests, key management, and hardware-backed crypto fit into ECU software.

Editorial Process: Written and reviewed by Agnile engineers working day-to-day in automotive cybersecurity and safety. AI tooling is used to assist with drafting, outlining, and copy-editing; every claim, standards reference, and technical statement is verified by a human engineer before publication.

Why AUTOSAR Classic Needs a Dedicated Crypto Stack

Crypto in an automotive ECU has three constraints that general-purpose libraries do not handle well: keys must never reach application memory, primitives must execute on dedicated hardware whenever it exists, and operations must be sequenced with hard real-time requirements. A monolithic crypto library either pulls keys into RAM and defeats the threat model, or executes primitives on the MCU and misses control-loop deadlines. The AUTOSAR Classic Crypto Stack is the architectural answer: a layered set of modules where the application sees a uniform job-based API, the Hardware Security Module sees a direct primitive dispatch, and the key material never crosses the boundary in either direction.

The stack also serves a second purpose. ISO/SAE 21434 Clause 10 requires evidence that cryptographic protections are correctly specified, implemented, and verified. A single Crypto Stack — with documented configuration, deterministic dispatch, and qualifiable modules — gives the cybersecurity case a single point of audit rather than a tour of every Software Component that happens to call AES.

Layered Architecture

AUTOSAR Classic Crypto Stack — module boundaries

Application / Software Components / SecOC / Diagnostics

callers of Csm_* APIs and KeyM services

↓

Csm — Crypto Service Manager

job queue, priorities, synchronous or asynchronous jobs, direct API for key management

↓

CryIf — Crypto Interface

channel mapping, key-slot routing, multiplexing across Crypto Driver Objects

↓

Crypto Driver(s)

vendor Hardware Security Module driver and / or software fallback driver

↓

Hardware — HSM, AES engine, SHA accelerator, TRNG

keys never leave the Hardware Security Module domain

KeyM — Key Manager. Service module beside the stack that calls Csm; provisions and updates key elements and verifies certificates, with validity time from StbM.

The four-module Crypto Stack in AUTOSAR Classic. KeyM sits beside the call chain rather than inside it: it is a user of Csm that manages keys and certificates, not a layer that application jobs pass through.

Csm — Crypto Service Manager

Csm is the application-facing module. It exposes two API shapes. The job-based API — Csm_Encrypt(), Csm_Decrypt(), Csm_MacGenerate(), Csm_MacVerify(), Csm_SignatureGenerate(), Csm_SignatureVerify() — submits a job descriptor that names the primitive, the input buffer, the output buffer, and the key slot. Each job is configured for asynchronous or synchronous processing; an asynchronous call returns immediately and completion arrives through a configured callback. Job priorities are configured per job and queue depths per queue; high-priority jobs (a brake command MAC verify, for instance) are queued ahead of lower-priority telemetry hashing.

The direct API serves a narrower purpose: synchronous key-management calls — setting, validating and reading key elements — that map one-to-one onto CryIf and the Crypto Driver. Low-latency primitives use a job configured for synchronous processing instead, where the caller can afford to block and the buffer is small. A typical use is a one-shot SHA-256 over a 64-byte challenge during diagnostic authentication. Synchronous jobs keep call sites simpler when async overhead is not justified.

CryIf — Crypto Interface

CryIf is the routing layer. It binds Csm jobs to channels, channels to Crypto Driver Objects, and key slots to driver instances. A typical configuration has one Crypto Driver Object for the Hardware Security Module path and one for the software fallback path; CryIf dispatches a given job to the Crypto Driver Object of the channel its Csm queue maps to, not based on the job content, and translates the job’s key reference into that driver’s key. This is the right place to enforce the rule that production key slots only ever route to the HSM driver.

CryIf also handles multiplexing. Multiple Csm jobs can be in flight against the same Crypto Driver Object, limited by driver queue depth; CryIf serialises them in configured order and propagates completions back through Csm. Misconfiguration in this layer is the failure mode that loses days during integration: a job that “should” run on the HSM but actually runs on the software driver produces correct functional output and silently undermines every cybersecurity claim built on it.

Crypto Driver — Vendor and Software

The Crypto Driver implements the actual primitives. In production, the driver is a vendor Basic Software package supplied for the silicon’s Hardware Security Module — for AURIX HSM, for the S32 family’s embedded security module, for RH850’s ICUM, for STM Chorus and Microchip parts. These vendor drivers expose a uniform interface to CryIf, so the higher layers do not need to be rewritten when silicon changes; the configuration changes, the application code does not.

A pure software driver is provided as a fallback. It executes AES, SHA, CMAC, HMAC, ECDSA, and RSA on the MCU using a vetted library. Its role is development and non-sensitive workloads only. Long-term keys, SecOC session keys, and secure-boot verification keys must live in HSM-protected storage; if the software driver touches them, the threat model collapses.

KeyM — Key Manager

KeyM owns the lifecycle. Key elements are referenced by identifier, never by raw value, throughout the rest of the stack. KeyM writes key elements into Csm keys held by the HSM-backed Crypto Driver (or in NvM), maintains certificate chains and validates them against a trusted-time source, surfaces revocation and renewal events, and brokers key derivation through Csm. Applications and Basic Software modules never handle key material: each Csm job references its key by identifier in configuration, and KeyM updates the key elements behind that identifier.

The trusted-time source is the integration question that programmes underestimate. KeyM cannot evaluate X.509 notBefore / notAfter windows without one. A defensible architecture sources signed timestamps from a backend over an authenticated channel, caches them with a bounded staleness, and gates certificate validation on time-source health. Without that, a stale certificate either slips through or every boot fails, and neither outcome is acceptable.

Job-API Call Sequence

The numbered sequence below traces a single job-based Csm_Encrypt() call from application to Hardware Security Module and back. The same shape applies to MAC generation, signature verification, and key derivation jobs.

  1. 1

    Application calls Csm_Encrypt(jobId, mode, dataPtr, dataLength, resultPtr, resultLengthPtr)

    Job descriptor was configured at design time with primitive (AES-128 CBC), key slot identifier, callback function, and priority. Application supplies the operation mode, the plaintext pointer and length, and the output buffer for the ciphertext.

  2. 2

    Csm queues the job and returns E_OK

    Csm enqueues the job at its configured priority. The function returns synchronously without blocking; the application proceeds with other work.

  3. 3

    Csm dispatches to CryIf_ProcessJob()

    On the next dispatch tick, Csm calls CryIf_ProcessJob() with the dequeued descriptor. CryIf resolves the job's channel to its Crypto Driver Object and translates the key reference to that driver's key.

  4. 4

    CryIf invokes Crypto_ProcessJob() on the Hardware Security Module driver

    The vendor Crypto Driver receives the job, marshals input into HSM-accessible memory (typically a shared mailbox), and triggers the HSM via its mailbox or interrupt mechanism.

  5. 5

    Hardware Security Module executes AES-CBC with the in-HSM key

    The HSM core retrieves the key from its protected slot, executes the AES-CBC encryption on the supplied plaintext, and writes the ciphertext into the shared mailbox. Key material never leaves the HSM.

  6. 6

    HSM signals completion; Crypto Driver picks up the result

    An interrupt or completion bit notifies the driver. The driver copies the ciphertext output into the buffer the application supplied, sets the result code, and calls back into CryIf.

  7. 7

    CryIf notifies Csm; Csm invokes the configured callback

    Csm dispatches the completion to the application-registered callback on the configured task. The callback receives the result code and may now consume the ciphertext.

Job-based Csm_Encrypt()call sequence: application → Csm queue → CryIf routing → Crypto Driver → Hardware Security Module → callback. Reentrancy and ordering bugs hide between steps 5 and 7.

Common Crypto Primitives

Modern Csm implementations supply a stable set of primitives drawn from NIST FIPS 197 (AES), FIPS 180-4 (SHA-2), FIPS 186-5 (ECDSA), and SP 800-38B (CMAC). In practice every Crypto Stack provides:

  • Symmetric cipher: AES-128, AES-256 in ECB, CBC, CTR, GCM, GMAC, and CCM modes.
  • Message authentication: CMAC-AES128, HMAC-SHA256, HMAC-SHA384.
  • Hash: SHA-256, SHA-384, SHA-512; SHA-3 in newer drivers.
  • Asymmetric: ECDSA-P256, ECDSA-P384, ECDH-P256, RSA-PSS-2048/3072/4096.
  • Key derivation: PBKDF2, HKDF, KDF in counter mode.
  • Random number generation: DRBG sourced from a hardware true random number generator on the Hardware Security Module.

Integration With SecOC, Secure Boot, Secure Diagnostics

The Crypto Stack is the single point of contact for every cybersecurity-relevant Basic Software module on the ECU. Three patterns recur:

  • SecOC. Calls Csm_MacGenerate() on transmit and Csm_MacVerify() on receive, against a key slot allocated for the communication relationship. Detailed in the companion guide on AUTOSAR SecOC.
  • Secure boot. Calls Csm_SignatureVerify() on each boot stage’s manifest against the chained verification keys held in KeyM. The chain of trust walkthrough lives in the post on secure boot for automotive ECUs.
  • Secure diagnostics (UDS service 0x29). Authentication challenges and response signature verification flow through Csm using ECDSA-P256 against the OEM diagnostic-tester certificate validated by KeyM.

Tool Qualification and Clause 10 Evidence

When the Crypto Stack participates in a function with an Automotive Safety Integrity Level above QM, every module in the stack inherits that requirement. Csm, CryIf, and KeyM packages are available from Basic Software vendors with ASIL-B and ASIL-D qualification reports; the Crypto Driver comes from the BSW vendor or the silicon vendor with its own report. The qualification is per supplier, per target, per release, and the release recommendation in WP-06-04 must reference the specific report version. Custom adaptations — non-trivial configuration deltas, custom callbacks, custom Crypto Driver Objects — require explicit qualification treatment in the project Cybersecurity Plan and may shift evidence work onto the project rather than the tool.

The Clause 10 cybersecurity case benefits from the Crypto Stack’s centralisation. Rather than enumerating cryptographic correctness in every Software Component, the case can reference the Crypto Stack qualification and the project-specific configuration; reviewers see a single audit point rather than dozens.

Implementation Pitfalls

PitfallImpactFix
Key slot bound to software driverProduction key in MCU memory; Hardware Security Module bypassed silently.Add CryIf configuration check in CI: every production key slot must resolve to the HSM Crypto Driver Object.
Async callback reentrancyRace conditions between SecOC, secure boot, and KeyM jobs completing on shared task contexts.Document task contexts for every callback; restrict callback bodies to short, non-blocking work; queue follow-up actions explicitly.
Trusted-time absent in KeyMX.509 validity windows unenforceable; certificate revocation impossible in field.Provision an authenticated time source with bounded staleness; gate KeyM certificate validation on time-source health.
Job priority inversionSafety-critical MAC verify queued behind low-priority telemetry hashes; control loop overruns.Tier the Csm job priorities by criticality; reserve a high-priority lane for SecOC on safety-critical PDUs.
Software-fallback overuseLatency budget met in benchmarks; cybersecurity property absent in production.Production builds disable the software Crypto Driver for any key slot above a documented sensitivity threshold.
Five recurring Crypto Stack pitfalls and the configuration or process discipline that catches each one before integration test.

AUTOSAR Adaptive: ara::crypto in 60 Seconds

The Adaptive Platform’s ara::crypto Functional Cluster preserves the Classic stack’s architectural intent in a different API style. C++ objects replace job descriptors; synchronous calls that return ara::core::Result replace callbacks; keys and certificates live in the Key Storage Provider and X.509 provider, with access control through Identity and Access Management, rather than a standalone KeyM. The Hardware Security Module remains the root of trust, and the same primitive set (AES, SHA-2, ECDSA, CMAC, HMAC) is exposed. Programmes that run mixed Classic and Adaptive ECUs typically maintain the same key hierarchy across both, with cross-platform services anchored in the Hardware Security Module on each side. The trade-offs are detailed in the comparison of AUTOSAR Classic vs Adaptive.

Take-Aways for an Architect-Grade Crypto Stack Programme

The Crypto Stack is one of the highest-leverage parts of an AUTOSAR Classic Basic Software stack: it is the single audit point for cryptographic claims, the integration boundary for the Hardware Security Module, and the call site for every other cybersecurity Basic Software module on the ECU. Get the configuration right — production key slots routed only to the HSM driver, KeyM anchored to a trusted-time source, priority lanes that respect safety criticality — and the rest of the cybersecurity stack inherits a clean foundation. Get it wrong, and every downstream claim becomes contestable.

Agnile Technologies provides AUTOSAR Crypto Stack integration across the major silicon families used in Tier-1 ECU programmes. Engage us before you freeze the CryIf channel map — that is the design moment when the wrong default sets up integration debt for the programme’s lifetime.

Frequently Asked Questions

Csm direct API or job-based API?

Cryptographic operations always use the job-based API; the direct API is mainly for key management and is always synchronous. The real choice is per job: synchronous processing for low-latency primitives where the call site can afford to block briefly (a hash on a small buffer, for example); asynchronous processing for everything else, especially MAC, signature verification, and any operation routed to the Hardware Security Module. Asynchronous jobs return immediately and the caller is notified through a callback, which fits the AUTOSAR Classic event-driven runtime far better than blocking primitives.

Can KeyM run without a trusted time source?

It can run, but X.509 validity windows then cannot be enforced. KeyM relies on a trusted time service to evaluate notBefore and notAfter on certificates; without it, every certificate either has to be treated as currently valid or rejected, neither of which is acceptable in production. A trusted time source — typically a backend-anchored, signed timestamp — is part of any defensible KeyM integration.

When is the software Crypto Driver appropriate?

Development, hardware-in-the-loop simulation, and ECUs without a Hardware Security Module where the keys involved are not high-value. A software Crypto Driver should never hold long-term Secure Onboard Communication keys, secure-boot root verification keys, or signing keys in production; it is a development convenience and a fallback for non-sensitive workloads.

How does the Crypto Stack relate to Secure Onboard Communication?

Secure Onboard Communication calls Csm for MAC compute and verify operations; Csm routes those jobs through CryIf to the Hardware Security Module-backed Crypto Driver. The SecOC module never touches keys directly; KeyM owns the key lifecycle, CryIf owns the channel mapping, and the Crypto Driver owns the actual primitive execution.

Is there a Crypto Stack in AUTOSAR Adaptive?

Yes — the ara::crypto Functional Cluster. The architectural intent is the same (application-facing API, internal routing, driver-level execution, key lifecycle service), but the API surface is C++ object-based and synchronous rather than C job-based, and keys and certificates live in the Key Storage Provider and X.509 provider, with access control enforced through Identity and Access Management.

What about post-quantum crypto?

Post-quantum primitives will arrive as additional Csm primitives — likely ML-KEM for key establishment and ML-DSA for signing as those become AUTOSAR-standardised. Architectures should be designed today to accept new primitives without re-architecting call sites: avoid hardcoding algorithm identifiers in application code, and route all crypto through Csm rather than direct primitive calls.

Where do most projects struggle?

Two failure modes recur. First, async callback races: SecOC, secure boot, and KeyM all submit jobs that complete on a different task; reentrancy and ordering bugs surface late and are hard to reproduce. Second, key-slot and channel misconfiguration: a SecOC PDU routed to the wrong key slot, or a Csm job routed to a software driver instead of the HSM, both produce silent functional success with no real cybersecurity property.

Need Help Applying This to a Real Programme?

Agnile supports engineering teams from architecture and requirements through implementation, validation, release, and evidence preparation.