DEENESPTFRRUARHIKOZHNL

AUTOSAR Classic Crypto Services

Cluster GuideKI-GENERIERT

Stellt standardisierte kryptografische Rechen- und Schlüsselverwaltungsdienste über Hard- und Softwaretreiber bereit.
KI-GENERIERT ungeprüft Modell: gemini-3.8-flash-medium · Aufwand: medium · Temperatur: nicht steuerbar · Prompt: b0f0d6315c89 Herkunft Offene Fragen (1)
Kausaler Anker: R20-11 Gültig ab R20-11 Neu synthetisiert für diesen Spezifikationsstand.
KI-generiertgemini-3.8-flash-medium · 2026-10-13

Stellt standardisierte kryptografische Rechen- und Schlüsselverwaltungsdienste über Hard- und Softwaretreiber bereit.

Das Cluster bündelt die Module CSM, CryIf und Crypto Driver zur hardwareunabhängigen Bereitstellung kryptografischer Dienste und Schlüsselverwaltungsfunktionen in der AUTOSAR Classic Platform EXP_UtilizationOfCryptoServices S. 8. Kryptografische Jobs werden über den CSM priorisiert, im CryIf auf logische Kanäle geroutet und im Crypto Driver synchron oder asynchron ausgeführt [SWS_CryIf_91003]. Schlüsselpersistierungen im NVM erfolgen aus Konsistenzgründen strikt erst nach erfolgreicher Validierung mittels KeySetValid SWS_CryptoDriver S. 37.

Das Modulcluster „Crypto Services & Hardware Abstraction“ umfasst die AUTOSAR Classic Module Crypto Service Manager (csm), Crypto Interface (cryif) und Crypto Driver (crypto) EXP_UtilizationOfCryptoServices S. 8. Es stellt eine hardwareunabhängige Abstraktionsschicht für kryptografische Operationen (u. a. Verschlüsselung, Signaturen, MAC-Berechnung und Zufallszahlengenerierung) sowie für ein sicheres Schlüsselmanagement bereit [SWS_Csm_00982], [SWS_Csm_00984], SWS_CryptoDriver S. 15.

Kryptografische Anforderungen werden als Crypto_JobType gekapselt, welcher Prioritäten, Ein- und Ausgabepuffer sowie Betriebsmodi (Start, Update, Finish für Streaming oder SingleCall) definiert [SWS_Csm_01013], [SWS_Csm_01039]. Der CSM nimmt Aufträge entgegen, ordnet sie softwareseitigen Warteschlangen zu und leitet sie über CryIf_ProcessJob() weiter [SWS_Csm_00017], [SWS_CryIf_91003]. Das CryIf übernimmt das Kanal-Routing zu den Treibern und übersetzt CSM-Schlüsselkennungen in modulspezifische Treiber-Schlüssel-IDs [SWS_CryIf_00133].

CryptoArchitecture cluster_app Application Layer / BSW Users cluster_csm Service Layer cluster_cryif ECU Abstraction Layer cluster_crypto Microcontroller Abstraction Layer (MCAL) SecOC SecOC / TLS / SW-C CSM Crypto Service Manager (csm) - Service-APIs (Csm_MacGenerate, ...) - Priorisierte Job-Queues - Csm_MainFunction SecOC->CSM Job / Service Request CSM->SecOC Application Callback CryIf Crypto Interface (cryif) - Channel Dispatching (CryIf_ProcessJob) - Key-ID Mapping (cryIfKeyId -> cryptoKeyId) - Callback Notification Dispatching CSM->CryIf CryIf_ProcessJob() / CryIf_Key*() CryIf->CSM Csm_CallbackNotification() CryptoDrv1 Crypto Driver (crypto) - HW - Crypto Driver Object 0 (z.B. AES / HSM) - NVM Synchronisation CryIf->CryptoDrv1 Crypto_ProcessJob() [Kanal 0] CryptoDrv2 Crypto Driver (crypto) - SW - Crypto Driver Object 1 (z.B. Software RSA) CryIf->CryptoDrv2 Crypto_ProcessJob() [Kanal 1] CryptoDrv1->CryIf CryIf_CallbackNotification() CryptoDrv2->CryIf CryIf_CallbackNotification()

Kontextdiagramm: Schichtenarchitektur und Schnittstellenkaskade des AUTOSAR Crypto-Stacks. Quellen: SWS_CryptoDriver S. 15, SWS_CryptoServiceManager S. 29

Zur Synchronisation asynchroner Krypto-Aufträge dient die periodische Csm_MainFunction(), welche die Warteschlangen leert und anstehende Berechnungen anstößt [SWS_Csm_00479]. Nach Abschluss einer asynchronen Hardware-Berechnung benachrichtigt der Crypto Driver das CryIf über CryIf_CallbackNotification(), das die Meldung an Csm_CallbackNotification() und letztlich an die aufrufende Applikation weiterreicht [SWS_CryIf_91013], [SWS_Csm_00970].

Asynchroner Krypto-Auftragsablauf im Crypto-ClusterApplicationcsmcryifcryptoCsm_MacGenerate(jobId, mode, ...)Job prüfen / Queue-CheckaltTreiberobjekt freiCryIf_ProcessJob(channelId, job)Key-ID Mapping (cryIfKeyId -> cryptoKeyId)Crypto_ProcessJob(objectId, job)E_OK (Auftrag angenommen)E_OKTreiberobjekt belegt / Queuing aktivJob in CSM-Queue einreihenE_OK (Asynchron gepuffert)Csm_MainFunction(): Dequeue JobCryIf_ProcessJob(channelId, job)Crypto_ProcessJob(objectId, job)E_OKUse Case: Hardware-/Treiber-Berechnung & AbschlussKrypto-Primitive berechnen (HW/ISR)CryIf_CallbackNotification(job, result)Csm_CallbackNotification(job, result)CallbackNotification(result)

Sequenzdiagramm: Asynchroner Krypto-Auftragsablauf mit Queuing und Callback-Kaskade. Quellen: [SWS_Csm_00970], [SWS_CryIf_91013], AUTOSAR_CP_SWS_CryptoServiceManager S. 146

Das Schlüsselmanagement erfolgt über standardisierte Schnittstellen wie Csm_KeyElementSet() und CryIf_KeyElementCopy() unter strikter Beachtung konfigurierter Zugriffsrechte [SWS_Csm_00957], [SWS_CryIf_91015], [SWS_Crypto_00219]. Eine Persistierung im NVM wird erst bei expliziter Validierung über Crypto_KeySetValid() angestoßen, wodurch unvollständige Schlüsselspeicherungen vermieden werden [SWS_Crypto_91014], SWS_CryptoDriver S. 37. Fehler wie Überlastungen oder ungültige Schlüsselzustände werden über CRYPTO_E_BUSY bzw. CRYPTO_E_KEY_NOT_VALID robust abgefangen [SWS_Csm_00018], [SWS_CryIf_91003].

1. Systemarchitektur & Rolle des Modulclusters

Das Modulcluster „Crypto Services & Hardware Abstraction“ bildet das funktionale Fundament für kryptografische Operationen, software- und hardwaregestützte Schlüsselverwaltung sowie sichere On-Board-Kommunikation in der AUTOSAR Classic Platform EXP_UtilizationOfCryptoServices S. 8. Die Architektur gliedert sich streng entlang des AUTOSAR-Schichtenmodells in drei standardisierte BSW-Module: den Crypto Service Manager (csm) in der Service-Schicht, das Crypto Interface (cryif) in der ECU Abstraction Layer sowie mindestens einen Crypto Driver (crypto) auf der Microcontroller Abstraction Layer (MCAL) SWS_CryptoDriver S. 15. Dieses Schichtengefüge abstrahiert Sicherheitsanwendungen (beispielsweise SecOC, TLS-Verbindungsaufbauten und UDS-Diagnoseauthentifizierung) vollständig von proprietären Krypto-Coprozessoren wie Hardware Security Modules (HSM) oder Secure Hardware Extensions (SHE) SWS_SecureOnboardCommunication S. 78.

Der Crypto Service Manager (CSM) fungiert als primärer Diensteanbieter für Applikationskomponenten (SW-Cs) und höher gelagerte BSW-Module. Er stellt standardisierte Programmierschnittstellen für symmetrische und asymmetrische Algorithmen (z. B. AES, RSA), Hashing, Message Authentication Codes (MAC), Zufallszahlengenerierung (RNG) und AEAD-Verfahren bereit [SWS_Csm_00980], [SWS_Csm_00982], [SWS_Csm_00984], [SWS_Csm_01023]. Zudem realisiert der CSM softwareseitige Job-Warteschlangen und steuert die Priorisierung paralleler Krypto-Aufträge [SWS_Csm_00022], SWS_CryptoServiceManager S. 29.

Das Crypto Interface (CryIf) stellt als Abstraktionsschicht eine einheitliche 1:n-Schnittstelle zwischen dem CSM und beliebig vielen Krypto-Treibern bereit. Seine zentrale Aufgabe ist das Dispatching: Es leitet Aufträge anhand konfigurierter logischer Kanäle (channelId) an die korrespondierende Crypto Driver Instanz weiter und transformiert logische Schlüsselreferenzen (cryIfKeyId) in treiberspezifische Identifikatoren (cryptoKeyId) [SWS_CryIf_00133], [SWS_CryIf_91003]. Der Crypto Driver kapselt die physische Ausführungseinheit (Crypto Driver Object) und bedient entweder reine Software-Kryptoprimitive oder spezielle Hardware-Sicherheitsmodule [SWS_Crypto_00224], SWS_CryptoDriver S. 15.

CryptoArchitecture cluster_app Application Layer / BSW Users cluster_csm Service Layer cluster_cryif ECU Abstraction Layer cluster_crypto Microcontroller Abstraction Layer (MCAL) SecOC SecOC / TLS / SW-C CSM Crypto Service Manager (csm) - Service-APIs (Csm_MacGenerate, ...) - Priorisierte Job-Queues - Csm_MainFunction SecOC->CSM Job / Service Request CSM->SecOC Application Callback CryIf Crypto Interface (cryif) - Channel Dispatching (CryIf_ProcessJob) - Key-ID Mapping (cryIfKeyId -> cryptoKeyId) - Callback Notification Dispatching CSM->CryIf CryIf_ProcessJob() / CryIf_Key*() CryIf->CSM Csm_CallbackNotification() CryptoDrv1 Crypto Driver (crypto) - HW - Crypto Driver Object 0 (z.B. AES / HSM) - NVM Synchronisation CryIf->CryptoDrv1 Crypto_ProcessJob() [Kanal 0] CryptoDrv2 Crypto Driver (crypto) - SW - Crypto Driver Object 1 (z.B. Software RSA) CryIf->CryptoDrv2 Crypto_ProcessJob() [Kanal 1] CryptoDrv1->CryIf CryIf_CallbackNotification() CryptoDrv2->CryIf CryIf_CallbackNotification()

Kontextdiagramm: Schichtenarchitektur und Schnittstellenkaskade des AUTOSAR Crypto-Stacks. Quellen: SWS_CryptoDriver S. 15, SWS_CryptoServiceManager S. 29

2. Zusammenspiel & Interaktionspfade zwischen den Modulen

Die Auftragsverarbeitung innerhalb des Clusters erfolgt primär über das job-basierte Modell mittels der Struktur Crypto_JobType [SWS_Csm_01013], AUTOSAR_CP_SWS_CryptoServiceManager S. 21. Ein Krypto-Job bündelt die Job-ID, Prioritätsinformationen, Schlüsselreferenzen, primitive Metadaten und die Struktur Crypto_JobPrimitiveInputOutputType zur Zeigerverwaltung von Eingabe-, Ausgabe- und Längenparametern [SWS_Csm_01012]. Durch das Bitmasken-Feld Crypto_OperationModeType (mit den Flags START, UPDATE, FINISH) wird gesteuert, ob ein Auftrag als zusammenhängender Einzelaufruf (SINGLECALL) oder inkrementell im Streaming-Modus berechnet wird [SWS_Csm_01039], [SWS_Csm_01029].

Wird eine CSM-Dienstfunktion synchron aufgerufen, prüft der CSM den Jobstatus. Ist der Treiber frei oder der Auftrag als synchron konfiguriert, ruft der CSM direkt CryIf_ProcessJob() auf [SWS_Csm_00017], [SWS_CryIf_91003]. Das CryIf mappt die Schlüssel-IDs und dispatcht den Job an die zugeordnete Treiberinstanz via Crypto_ProcessJob() [SWS_CryIf_00133]. Bei asynchronen Anforderungen wird der Job bei belegtem Treiberobjekt in die CSM-Queue eingereiht [SWS_Csm_00018], AUTOSAR_CP_SWS_CryptoServiceManager S. 30. Nach Abschluss der asynchronen Treiberberechnung triggert der Treiber CryIf_CallbackNotification() [SWS_CryIf_91013], das CryIf leitet die Meldung an Csm_CallbackNotification() weiter [SWS_Csm_00970], und der CSM benachrichtigt schließlich die anfordernde Anwendung über deren konfigurierten Callback [SWS_Csm_01044], [SWS_Csm_00928].

Asynchroner Krypto-Auftragsablauf im Crypto-ClusterApplicationcsmcryifcryptoCsm_MacGenerate(jobId, mode, ...)Job prüfen / Queue-CheckaltTreiberobjekt freiCryIf_ProcessJob(channelId, job)Key-ID Mapping (cryIfKeyId -> cryptoKeyId)Crypto_ProcessJob(objectId, job)E_OK (Auftrag angenommen)E_OKTreiberobjekt belegt / Queuing aktivJob in CSM-Queue einreihenE_OK (Asynchron gepuffert)Csm_MainFunction(): Dequeue JobCryIf_ProcessJob(channelId, job)Crypto_ProcessJob(objectId, job)E_OKUse Case: Hardware-/Treiber-Berechnung & AbschlussKrypto-Primitive berechnen (HW/ISR)CryIf_CallbackNotification(job, result)Csm_CallbackNotification(job, result)CallbackNotification(result)

Sequenzdiagramm: Asynchroner Krypto-Auftragsablauf mit Queuing und Callback-Kaskade. Quellen: [SWS_Csm_00970], [SWS_CryIf_91013], AUTOSAR_CP_SWS_CryptoServiceManager S. 146

Neben der primären Krypto-Ausführung bildet das Schlüsselmanagement einen integralen Interaktionspfad des Clusters SWS_CryptoDriver S. 24. Ein Schlüssel besteht aus mehreren logischen Schlüsselelementen (wie Schlüsselmaterial, Initialisierungsvektoren oder Iterationswerten) [SWS_Csm_00954], [SWS_Csm_01022]. Operationen wie das Setzen von Schlüsselmaterial via Csm_KeyElementSet(), das Kopieren mittels Csm_KeyElementCopy() oder die Schlüsselableitung über Csm_KeyDerive() werden synchron über das CryIf (CryIf_KeyElementCopy(), CryIf_KeyDerive()) an die Treiberfunktionen weitergeleitet [SWS_Csm_00957], [SWS_Csm_00969], [SWS_CryIf_91015], [SWS_CryIf_91009]. Der Zugriff auf Schlüsselelemente wird dabei streng anhand konfigurierter Zugriffsrechte (CRYPTO_RA_ALLOWED, CRYPTO_RA_ENCRYPTED, CRYPTO_RA_INTERNAL_COPY) überwacht [SWS_Crypto_00219].

3. Synchronisation, Reentranz und Task-Kontexte

Kryptografische Operationen variieren drastisch in ihrer Ausführungsdauer. Während schnelle Blockchiffren oder Hashberechnungen synchron im Task-Kontext des Aufrufers ausgeführt werden können, erfordern asymmetrische Berechnungen (z. B. RSA-Signaturgenerierung) oder zeitintensive Hardware-Abläufe eine asynchrone Bearbeitung [SWS_Csm_00984], [SWS_Csm_00992]. Für die Entkopplung stellt der CSM die zyklisch aufgerufene Hauptfunktion Csm_MainFunction() bereit [SWS_Csm_00479]. Diese überwacht Warteschlangen, dispatcht anstehende Jobs an das CryIf und treibt interne Zustandsmaschinen asynchroner Primitiven voran [SWS_Csm_00019].

In modernen Mehrkern- und Multisektor-Architekturen unterstützt der CSM mehrere Instanzen Csm_MainFunction_<shortName>(), die dedizierten OS-Partitionen zugeordnet werden [SWS_Csm_00479], AUTOSAR_SWS_CryptoServiceManager S. 170. Bei asynchroner Treiberausführung werden die Berechnungen entweder durch Polling in der Treiber-MainFunction oder durch Interrupt Service Routinen (ISR) hardwarebasierter Krypto-Engines beendet [SWS_Crypto_00027], [SWS_Crypto_00028]. Ein einzelnes Crypto Driver Object kann per Definition jeweils genau einen Krypto-Job zeitgleich bearbeiten; ein Treiber mit n Objekten verarbeitet n Aufträge echt parallel [SWS_Crypto_00014], [SWS_Crypto_00117].

Bezüglich der Reentranz sind Dienstschnittstellen wie Csm_MacGenerate() oder CryIf_ProcessJob() reentrant für unterschiedliche Jobs konzipiert, verbieten jedoch die parallele Mehrfachbeauftragung derselben Job-Instanz [SWS_Csm_00016], [SWS_CryIf_91003]. Schlüsselverwaltungsfunktionen wie Csm_KeyElementCopy(), CryIf_KeyElementCopy() oder Crypto_KeyCopy() sind reentrant implementiert, dürfen jedoch nicht nebenläufig auf dieselbe Quell-Schlüsselkennung (keyId bzw. cryptoKeyId) angewendet werden, um Dateninkonsistenzen und Race Conditions zu vermeiden [SWS_Csm_00969], [SWS_CryIf_91015], [SWS_Crypto_00155]. Hardwaretreiber dürften für die Modifikation interner Arbeitsbereiche und Schlüsselregister interne exklusive Bereiche (Exclusive Areas) nutzen, um Race Conditions zwischen ISR und Task-Ebene abzufangen SWS_CryptoDriver S. 27. Frage Q-b1e9578255723a0e (offen)

CsmDispatchLogic Start Eintritt Csm_<Service>() CheckActive Job aktiv? (jobState == ACTIVE) Start->CheckActive CheckSync Synchroner Modus? (CRYPTO_PROCESSING_SYNC) CheckActive->CheckSync Nein DirectCall CryIf_ProcessJob() ausführen CheckActive->DirectCall Ja (Streaming Update/Finish) CheckSync->DirectCall Ja CheckQueueEmpty CSM-Queue leer? CheckSync->CheckQueueEmpty Nein (Asynchron) CheckPrio Priorität höher als höchster Queue-Job? CheckQueueEmpty->CheckPrio Nein ForwardCryIf Job sofort dispatchen: CryIf_ProcessJob() CheckQueueEmpty->ForwardCryIf Ja CheckQueueFull CSM-Queue voll? CheckPrio->CheckQueueFull Nein CheckPrio->ForwardCryIf Ja EnqueueJob Job in CSM-Queue einreihen Return E_OK CheckQueueFull->EnqueueJob Nein ReturnBusy Return CRYPTO_E_BUSY (DET: CSM_E_QUEUE_FULL) CheckQueueFull->ReturnBusy Ja

Aktivitätsdiagramm: Entscheidungslogik und Queuing-Entkopplung bei Auftragsannahme im CSM. Quellen: AUTOSAR_CP_SWS_CryptoServiceManager S. 30, [SWS_Csm_00017], [SWS_Csm_00018]

4. Typische Lebenszyklen und Betriebsmodi

Die Initialisierung des Krypto-Clusters erfolgt während des BSW-Hochlaufs in hierarchischer Reihenfolge. Zunächst initialisiert der EcuM oder BswM die Treiberstufe via Crypto_Init() unter Übergabe der Konfiguration Crypto_ConfigType [SWS_Crypto_91016], gefolgt von der Schnittstellenschicht via CryIf_Init() mit CryIf_ConfigType [SWS_CryIf_91118]. Schließlich wird der CSM mittels Csm_Init() gestartet, wobei dessen Konfigurationszeiger gemäß Spezifikation stets auf NULL_PTR gesetzt werden muss [SWS_Csm_00646]. Erst nach vollständiger Initialisierung aller Schichten dürfen kryptografische Aufträge oder Schlüsselzugriffe angenommen werden [SWS_CryIf_00076], [SWS_Crypto_00196].

Ein zentraler Aspekt des Schlüssel-Lebenszyklus ist die Validierung und Persistierung in nichtflüchtigem Speicher (NVM). Nach dem Laden neuer Schlüsselwerte über Csm_KeyElementSet() verbleibt der Schlüssel im Status „unvollständig bzw. unbekannt“ [SWS_Csm_00957]. Erst der explizite Aufruf von Csm_JobKeySetValid() bzw. Crypto_KeySetValid() prüft die Konsistenz und wechselt den Schlüsselstatus auf gültig [SWS_Csm_91027], [SWS_Crypto_91014]. Bei persistierten Schlüsseln löst ausschließlich diese Validierung die Speicherung im NVM aus [SWS_Crypto_91026], SWS_CryptoDriver S. 37. Dies verhindert mehrfache fragmentierte NVM-Schreibzyklen und schützt vor unvollständigen Schlüsselsätzen SWS_CryptoDriver S. 37. Für die Synchronisation mit dem NVRAM Manager bedient sich der Crypto Driver der Callbacks Crypto_<vi>_<ai>_NvBlock_ReadFrom_<NvBlock>() und Crypto_<vi>_<ai>_NvBlock_WriteTo_<NvBlock>() sowie NvM_WriteBlock() [SWS_Crypto_91024], [SWS_Crypto_91025], [SWS_Crypto_91017].

Laufende Streaming-Aufträge können bei Bedarf über Csm_SaveContextJob() unterbrochen, in einem applikationseigenen Puffer gesichert und später per Kontext-Wiederherstellung fortgeführt werden [SWS_Csm_91063], [SWS_Csm_01029]. Vor einem Steuergeräte-Shutdown oder einem Übergang in Low-Power-Modi können asynchrone Aufträge kontrolliert via Csm_CancelJob() abgebrochen werden, wodurch das CryIf über CryIf_CancelJob() die Jobs aus Treiberwarteschlangen und Hardwarekanälen entfernt [SWS_Csm_00968], [SWS_CryIf_91014].

5. Fehlerbehandlung, DET-Tracing und Degradation

Das Cluster implementiert eine mehrstufige Fehlererkennungs- und Abwehrstrategie. Entwicklungsfehler werden bei aktiviertem Tracing direkt an das Default Error Tracer (DET) Modul gemeldet [SWS_Csm_91101], [SWS_Crypto_91017]. Zu den typischen DET-Ereignissen zählen Modulaufrufe vor erfolgter Initialisierung (CRYIF_E_UNINIT, CRYPTO_E_UNINIT), ungültige Handle- oder Schlüsselparameter (CRYIF_E_PARAM_HANDLE, CRYPTO_E_PARAM_HANDLE) sowie Nullzeiger-Übergaben [SWS_CryIf_00076], [SWS_CryIf_00134], [SWS_Crypto_00196], [SWS_Crypto_00217].

Laufzeitüberlastungen und Ressourcenengpässe werden deterministisch über definierte Rückgabewerte abgefangen. Ist die CSM-Warteschlange für einen asynchronen Job erschöpft, weist der CSM den Auftrag mit dem Statuscode CRYPTO_E_BUSY ab und generiert den Laufzeitfehler CSM_E_QUEUE_FULL [SWS_Csm_00018], [SWS_Csm_01089]. Ist ein bereitgestellter Ergebnispuffer unzureichend dimensioniert, bricht der Treiber die Operation mit CRYPTO_E_SMALL_BUFFER ab [SWS_Crypto_00195]. Verweist ein kryptografischer Dienst auf einen uninitialisierten oder explizit invalidierten Schlüssel (beispielsweise nach Aufruf von Csm_JobKeySetInvalid() oder Crypto_KeySetInvalid()), schlagen Serviceanforderungen kontrolliert mit CRYPTO_E_KEY_NOT_VALID oder CRYPTO_E_KEY_EMPTY fehl [SWS_Csm_91002], [SWS_CryIf_91003], [SWS_Crypto_91020].

Degradations- und Fallback-Mechanismen werden auf Systemebene ermöglicht: Anwendungen können über Csm_KeyGetStatus() den Integritätsstatus von Schlüsseln vor Auftragsübermittlung prüfen [SWS_Csm_91047], [SWS_CryIf_91012]. Sollte ein Hardware-Krypto-Beschleuniger dauerhaft belegt sein oder ausfallen, erlaubt die CryIf-Kanalkonfiguration eine softwarebasierte Ausweichroute, sofern ein redundanter Software-Treiber integriert ist SWS_CryptoDriver S. 15.

Dieser Leitfaden basiert ausschließlich auf der AUTOSAR Classic Spezifikation R20-11 und wurde durch den autodocs-Kurationsassistenten generiert.

Die Crypto Services bieten hardware- und softwaregestützte Kryptographie-Primitive (CSM, CryIf, Crypto-Treiber) für symmetrische/asymmetrische Verschlüsselung, Signaturen und Hashing.

Module im Cluster

Crypto Abstraction Library (Cal)

AUTOSAR Classic Crypto Services-Modul Crypto Abstraction Library (Cal, Spezifikation: AUTOSAR_SWS_CryptoAbstractionLibrary.pdf).

BSW ID 206 Keine C-API · 0 Records #include "Cal.h"

Crypto Interface (CryIf)

Abstracts cryptographic hardware and software acceleration engines.

BSW ID 112 19 APIs (18 Funktionen, 1 Typen) #include "CryIf.h"

Crypto Driver (Crypto)

Low-level driver executing cryptographic primitives on hardware security modules (HSM) or software libraries.

BSW ID 114 20 APIs (19 Funktionen, 1 Typen) #include "Crypto.h"

Crypto Service Manager (CSM)

Provides standardized cryptographic services (encryption, hashing, digital signatures, key management) to applications and BSW.

BSW ID 110 82 APIs (38 Funktionen, 44 Typen) #include "Csm.h"

Themenkarte

Csm

82
<Csm_ApplicationCallbackNotification>Csm_AEADDecryptCsm_AEADEncryptCsm_CallbackNotificationCsm_CancelJobCsm_DecryptCsm_EncryptCsm_GetVersionInfoCsm_HashCsm_InitCsm_JobKeyDeriveCsm_JobKeyExchangeCalcPubValCsm_JobKeyExchangeCalcSecretCsm_JobKeyGenerateCsm_JobKeySetInvalidCsm_JobKeySetValidCsm_JobRandomSeedCsm_KeyCopyCsm_KeyDeriveCsm_KeyElementCopyCsm_KeyElementCopyPartialCsm_KeyElementGetCsm_KeyElementSetCsm_KeyExchangeCalcPubValCsm_KeyExchangeCalcSecretCsm_KeyGenerateCsm_KeyGetStatusCsm_KeySetInvalidCsm_KeySetValidCsm_MacGenerateCsm_MacVerifyCsm_MainFunctionCsm_RandomGenerateCsm_RandomSeedCsm_RestoreContextJobCsm_SaveContextJobCsm_SignatureGenerateCsm_SignatureVerifyCrypto_AlgorithmFamilyTypeCrypto_AlgorithmInfoTypeCrypto_AlgorithmModeTypeCrypto_InputOutputRedirectionConfigTypeCrypto_JobPrimitiveInfoTypeCrypto_JobPrimitiveInputOutputTypeCrypto_JobRedirectionInfoTypeCrypto_JobStateTypeCrypto_JobTypeCrypto_KeyStatusTypeCrypto_OperationModeTypeCrypto_PrimitiveInfoTypeCrypto_ProcessingTypeCrypto_ResultTypeCrypto_ServiceInfoTypeCrypto_VerifyResultTypeCsm_AEADDecryptAssociatedDataTypeCsm_AEADDecryptCiphertextTypeCsm_AEADDecryptPlaintextTypeCsm_AEADDecryptTagTypeCsm_AEADEncryptAssociatedDataTypeCsm_AEADEncryptCiphertextTypeCsm_AEADEncryptPlaintextTypeCsm_AEADEncryptTagTypeCsm_ConfigIdTypeCsm_ConfigTypeCsm_DecryptDataTypeCsm_DecryptResultTypeCsm_EncryptDataTypeCsm_EncryptResultTypeCsm_HashDataTypeCsm_HashResultTypeCsm_KeyDataTypeCsm_LengthPtrCsm_MacGenerateDataTypeCsm_MacGenerateResultTypeCsm_MacVerifyCompareTypeCsm_MacVerifyDataTypeCsm_RandomGenerateResultTypeCsm_SignatureGenerateDataTypeCsm_SignatureGenerateResultTypeCsm_SignatureVerifyCompareTypeCsm_SignatureVerifyDataTypeCsm_VerifyResultPtr

Detailansicht

Wähle in der Gliederung einen Eintrag aus.

CryIf

Notifies the CRYIF about the completion of the request with the result of the cryptographic operation.

void CryIf_CallbackNotification (Crypto_JobType* job, Crypto_ResultType result);

This interface dispatches the job cancellation function to the configured crypto driver object.

Std_ReturnType CryIf_CancelJob (uint32 channelId, Crypto_JobType* job);

Returns the version information of this module.

void CryIf_GetVersionInfo (Std_VersionInfoType* versioninfo);
CryIf_Init function

Initializes the CRYIF module. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_CryptoInterface

void CryIf_Init (const CryIf_ConfigType* configPtr);
CryIf_KeyCopy function

This function shall co py all key elements from the source key to a target key.

Std_ReturnType CryIf_KeyCopy (uint32 cryIfKeyId, uint32 targetCryIfKeyId);

This function shall dispatch th e key derive function to the configured crypto driver object.

Std_ReturnType CryIf_KeyDerive (uint32 cryIfKeyId, uint32 targetCryIfKeyId);

Service CryIf_KeyElementCopy.

Std_ReturnType CryIf_KeyElementCopy (uint32 cryIfKeyId, uint32 keyElementId, uint32 targetCryIfKeyId, uint32 targetKeyElementId);

Service CryIf_KeyElementCopyPartial.

Std_ReturnType CryIf_KeyElementCopyPartial (uint32 cryIfKeyId, uint32 keyElementId, uint32 keyElementSourceOffset, uint32 keyElementTargetOffset, uint32 keyElementCopyLength, uint32 targetCryIfKeyId, uint32 targetKeyElementId);

This function shall dispatch the get key ele ment function to the configured crypto driver object.

Std_ReturnType CryIf_KeyElementGet (uint32 cryIfKeyId, uint32 keyElementId, uint8* resultPtr, uint32* resultLengthPtr);

This function shall dispatch the set key element function to the configured crypto driver object.

Std_ReturnType CryIf_KeyElementSet (uint32 cryIfKeyId, uint32 keyElementId, const uint8* keyPtr, uint32 keyLength);

This function shall dispatch the key exchange public value calculation function to the configured crypto driver object. Available

Std_ReturnType CryIf_KeyExchangeCalcPubVal (uint32 cryIfKeyId, uint8* publicValuePtr, uint32* publicValueLengthPtr);

This function shall dispatch the key exchange common shared secret calculation function to the configured crypto driver object.

Std_ReturnType CryIf_KeyExchangeCalcSecret (uint32 cryIfKeyId, const uint8* partnerPublicValuePtr, uint32 partnerPublicValueLength);

This function shall dispatch the key generate function to the configured crypto driver object.

Std_ReturnType CryIf_KeyGenerate (uint32 cryIfKeyId);

Returns the key state of the key identified by cry If Key Id.

Std_ReturnType CryIf_KeyGetStatus (uint32 cryIfKeyId, Crypto_KeyStatusType* keyStatusPtr);

Sets invalid for the status of the key identifi ed by cry If Key Id.

Std_ReturnType CryIf_KeySetInvalid (uint32 cryIfKeyId);

This function shall dispatch the set key valid function to the configured crypto driver object.

Std_ReturnType CryIf_KeySetValid (uint32 cryIfKeyId);

Service CryIf_ProcessJob.

Std_ReturnType CryIf_ProcessJob (uint32 channelId, Crypto_JobType* job);

This function shall dispatch the random seed function to the configured crypto driver object.

Std_ReturnType CryIf_RandomSeed (uint32 cryIfKeyId, const uint8* seedPtr, uint32 seedLength);

Configuration data structure of Cry If module

Crypto

This interface removes the provided job from the queue and cancels the processing of the job if possible.

Std_ReturnType Crypto_CancelJob (uint32 objectId, Crypto_JobType* job);

Returns the version information of this module.

void Crypto_GetVersionInfo (Std_VersionInfoType* versioninfo);
Crypto_Init function

Initializes the Crypto Driver.

void Crypto_Init (const Crypto_ConfigType* configPtr);

Copies a key with all its elements to another key in the same crypto driver. Note: If the actual key element is directly mapped to flash memory, there could be a bigger delay when calling this function (synchronous operation)

Std_ReturnType Crypto_KeyCopy (uint32 cryptoKeyId, uint32 targetCryptoKeyId);

Derives a new key by using the key elements in the given key identified by the crypto Key Id. The given key contains the key elements for the password, salt. The derived key is stored in the key element with the id 1 of the key identified by target Crypto Key Id. The number of iterations is given in the key element CRYPTO_ KE_ KEYDERIVATION_ ITERATIONS.

Std_ReturnType Crypto_KeyDerive (uint32 cryptoKeyId, uint32 targetCryptoKeyId);

Service Crypto_KeyElementCopy.

Std_ReturnType Crypto_KeyElementCopy (uint32 cryptoKeyId, uint32 keyElementId, uint32 targetCryptoKeyId, uint32 targetKeyElementId);

Service Crypto_KeyElementCopyPartial.

Std_ReturnType Crypto_KeyElementCopyPartial (uint32 cryptoKeyId, uint32 keyElementId, uint32 keyElementSourceOffset, uint32 keyElementTargetOffset, uint32 keyElementCopyLength, uint32 targetCryptoKeyId, uint32 targetKeyElementId);

This interface shall be used to get a key element of the key identified by the crypto

Std_ReturnType Crypto_KeyElementGet (uint32 cryptoKeyId, uint32 keyElementId, uint8* resultPtr, uint32* resultLengthPtr);

Used to retrieve information which key elements are available in a given key.

Std_ReturnType Crypto_KeyElementIdsGet (uint32 cryptoKeyId, uint32* keyElementIdsPtr, uint32* keyElementIdsLengthPtr);

Sets the given key element bytes to the key identified by crypto Key Id.

Std_ReturnType Crypto_KeyElementSet (uint32 cryptoKeyId, uint32 keyElementId, const uint8* keyPtr, uint32 keyLength);

Calculates the public value for the key exchange a nd stores the public key in the memory location pointed by the public value pointer.

Std_ReturnType Crypto_KeyExchangeCalcPubVal (uint32 cryptoKeyId, uint8* publicValuePtr, uint32* publicValueLengthPtr);

Calculates the shared secret key for the key exchange with the key material of the key identified by the crypto Key Id and the partner public key. The shared secret key is stored as a key element in the same key.

Std_ReturnType Crypto_KeyExchangeCalcSecret (uint32 cryptoKeyId, const uint8* partnerPublicValuePtr, uint32 partnerPublicValueLength);

Generates new key material store it in the key identified by crypto Key Id.

Std_ReturnType Crypto_KeyGenerate (uint32 cryptoKeyId);

Returns the key state of the key identified by crypto Key Id.

Std_ReturnType Crypto_KeyGetStatus (uint32 cryptoKeyId, Crypto_KeyStatusType* keyStatusPtr);

Sets invalid for the status of the key identifi ed by crypto Key Id.

Std_ReturnType Crypto_KeySetInvalid (uint32 cryptoKeyId);

Sets the key state of the key identified by crypto Key Id to valid.

Std_ReturnType Crypto_KeySetValid (uint32 cryptoKeyId);

If asynchronous job processing is configured and there are job queues, the function is called cyclically to process queued jobs. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_CryptoDriver

void Crypto_MainFunction (void);

Service Crypto_ProcessJob.

Std_ReturnType Crypto_ProcessJob (uint32 objectId, Crypto_JobType* job);

This function generates the internal seed state using the pro vided entropy source. Furthermore, this function can be used to update the seed state with new entropy

Std_ReturnType Crypto_RandomSeed (uint32 cryptoKeyId, const uint8* seedPtr, uint32 seedLength);

Configuration data structure of Cry If module

Csm

CSM notifies the application that a job has finished. The function name is configurable. The function name itself is derived from "{Csm Job/ Csm Job Primitive Callback Ref}/Csm Callback Func".

void <Csm_ApplicationCallbackNotification> (uint32 jobId, Crypto_ResultType result);

Service Csm_AEADDecryptManager.

Std_ReturnType Csm_AEADDecrypt (uint32 jobId, Crypto_OperationModeType mode, const uint8* ciphertextPtr, uint32 ciphertextLength, const uint8* associatedDataPtr, uint32 associatedDataLength, const uint8* tagPtr, uint32 tagLength, uint8* plaintextPtr, uint32* plaintextLengthPtr, Crypto_VerifyResultType* verifyPtr);

Service Csm_AEADEncrypt.

Std_ReturnType Csm_AEADEncrypt (uint32 jobId, Crypto_OperationModeType mode, const uint8* plaintextPtr, uint32 plaintextLength, const uint8* associatedDataPtr, uint32 associatedDataLength, uint8* ciphertextPtr, uint32* ciphertextLengthPtr, uint8* tagPtr, uint32* tagLengthPtr);

Notifies the CSM that a job has finished. This function is used by the underlying layer (CRYIF).

void Csm_CallbackNotification (Crypto_JobType* job, Crypto_ResultType result);
Csm_CancelJob function

Cancels the job processing from asynchronous or streaming jobs .

Csm_Decrypt function

Service Csm_Decrypt.

Std_ReturnType Csm_Decrypt (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, uint8* resultPtr, uint32* resultLengthPtr);
Csm_Encrypt function

Service Csm_Encrypt.

Std_ReturnType Csm_Encrypt (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, uint8* resultPtr, uint32* resultLengthPtr);

Returns the version information of this module.

void Csm_GetVersionInfo (Std_VersionInfoType* versioninfo);
Csm_Hash function

Uses the given data to perform the hash calculation and stores the hash.

Std_ReturnType Csm_Hash (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, uint8* resultPtr, uint32* resultLengthPtr);
Csm_Init function

Initializes the CSM module. In configurations, in which Csm is assigned to more than one partition (i.e. Csm_ Main Functions are mapped to partitions), Csm may provide one init function per partition.

void Csm_Init (const Csm_ConfigType* configPtr);

Derives a new key by using the key elements in the given key identified by the key Id. The given key contains the key elements for the password and salt. The derived key is stored in the key element with the id 1 of the key identified by target Crypto

Std_ReturnType Csm_JobKeyDerive (uint32 jobId, uint32 keyId, uint32 targetKeyId);

Calculates the public value of the current user for the key exchange and stores the

Std_ReturnType Csm_JobKeyExchangeCalcPubVal (uint32 jobId, uint32 keyId, uint8* publicValuePtr, uint32* publicValueLengthPtr);

Calculates the shared secret key for the key exchange with the key material of the key identified by the key Id and the partner public key. The shared secret key is stored as a key element in the same key.

Std_ReturnType Csm_JobKeyExchangeCalcSecret (uint32 jobId, uint32 keyId, const uint8* partnerPublicValuePtr, uint32 partnerPublicValueLength);

Generates new key material and stores it in the key identified by key Id.

Std_ReturnType Csm_JobKeyGenerate (uint32 jobId, uint32 keyId);

Sets the key status to invalid. The key cannot be used any longer for cryptographic operations until it has been set to valid state again.

Std_ReturnType Csm_JobKeySetInvalid (uint32 jobId, uint32 keyId);

Stores the key if necessary and sets the key state of the key identified by key Id to valid.

Std_ReturnType Csm_JobKeySetValid (uint32 jobId, uint32 keyId);

Provides a new seed for the specified key that is used for an associated random number generator.

Std_ReturnType Csm_JobRandomSeed (uint32 jobId, uint32 keyId, const uint8* seedPtr, Manager uint32 seedLength);
Csm_KeyCopy function

This function shall copy all key elements from the source key to a target key. Ava ilable via Csm.h

Std_ReturnType Csm_KeyCopy (const uint32 keyId, const uint32 targetKeyId);
Csm_KeyDerive function

Derives a new key by using the key elements in the given key identified by the key Id. The given key contains the key elements for the password and salt. The derived key is stored in the k ey element with the id 1 of the key identified by target Crypto Key Id.

Std_ReturnType Csm_KeyDerive (uint32 keyId, uint32 targetKeyId);

Service Csm_KeyElementCopyManager.

Std_ReturnType Csm_KeyElementCopy (const uint32 keyId, const uint32 keyElementId, const uint32 targetKeyId, const uint32 targetKeyElementId);

Service Csm_KeyElementCopyPartial.

Std_ReturnType Csm_KeyElementCopyPartial (uint32 keyId, uint32 keyElementId, uint32 keyElementSourceOffset, uint32 keyElementTargetOffset, uint32 keyElementCopyLength, uint32 targetKeyId, uint32 targetKeyElementId);

Service Csm_KeyElementGet.

Std_ReturnType Csm_KeyElementGet (uint32 keyId, uint32 keyElementId, uint8* keyElementPtr, Manager uint32* keyElementLengthPtr);

Sets the given key element bytes to the key identified by key Id.

Std_ReturnType Csm_KeyElementSet (uint32 keyId, uint32 keyElementId, const uint8* keyElementPtr, uint32 keyElementLength);

Calculates the public value of the current user for the key exchange and stores the pub lic key in the memory location pointed by the public value pointer.

Std_ReturnType Csm_KeyExchangeCalcPubVal (uint32 keyId, uint8* publicValuePtr, uint32* publicValueLengthPtr);

Calculates the shared secret key for the key exchange with the key material of the key identified by the key Id and the partner public key. The shared secret key is stored as a key element in the same key.

Std_ReturnType Csm_KeyExchangeCalcSecret (uint32 keyId, const uint8* partnerPublicValuePtr, uint32 partnerPublicValueLength);

Generates new key material and store it in the key identified by key Id.

Std_ReturnType Csm_KeyGenerate (uint32 keyId);

Returns the key state of the key identified by key Id.

Std_ReturnType Csm_KeyGetStatus (uint32 keyId, Crypto_KeyStatusType* keyStatusPtr);

Sets the key status to invalid. The key cannot be used any longer for cryptographic operations until it has been set to valid state again.

Std_ReturnType Csm_KeySetInvalid (uint32 keyId);

Sets the key state of the key identified by key Id to valid.

Std_ReturnType Csm_KeySetValid (uint32 keyId);

Service Csm_MacGenerate.

Std_ReturnType Csm_MacGenerate (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, uint8* macPtr, uint32* macLengthPtr);
Csm_MacVerify function

Service Csm_MacVerify.

Std_ReturnType Csm_MacVerify (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, const uint8* macPtr, const uint32 macLength, Crypto_VerifyResultType* verifyPtr);

API to be called cyclically to process the requested jobs. The Csm_ Main Function shall check the queues for jobs to pass to the underlying CRYIF. Per configured Csm Main Function ins tance one Csm_ Main Function_ shall be implemented. Hereby is the short name of the Csm Main Function configuration container in the ECU configuration.

void Csm_MainFunction (void);

Generate a random number and stores it in the memory location pointed by th e result pointer.

Std_ReturnType Csm_RandomGenerate (uint32 jobId, uint8* resultPtr, uint32* resultLengthPtr);

Feeds the key element CRYPTO_ KE_ RANDOM_ SEED with a random seed. Manager AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_CryptoServiceManager

Std_ReturnType Csm_RandomSeed (uint32 keyId, const uint8* seedPtr, uint32 seedLength);

The Crypto Driver extracts the context data from the context Buffer and restores the internal state so that further crypto operation of this crypto service will continue at the exact point when the context was taken.

Std_ReturnType Csm_RestoreContextJob (uint32 jobId, uint8* contextBufferPtr, uint32 contextBufferLength);

The Crypto Driver stores the internal context of the respective crypto operation to the context Buffer.

Std_ReturnType Csm_SaveContextJob (uint32 jobId, uint8* contextBufferPtr, uint32* contextBufferLengthPtr);

Service Csm_SignatureGenerate.

Std_ReturnType Csm_SignatureGenerate (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, uint8* signaturePtr, uint32* signatureLengthPtr);

Service Csm_SignatureVerify.

Std_ReturnType Csm_SignatureVerify (uint32 jobId, Crypto_OperationModeType mode, const uint8* dataPtr, uint32 DataLength, const uint8* signaturePtr, uint32 signatureLength, Crypto_VerifyResultType* verifyPtr);

Type Crypto_AlgorithmFamilyType.

Structure which determines the exact algorithm. Note, not every algorithm needs to specify all fields. AUTOSAR shall only allow valid combinations.

Type Crypto_AlgorithmModeType.

Defines which of the input/ output parameters are re - directed to a key element. The values can be combined to define a bit field.

Structure which contains further information, which depends on the job and the crypto primitive.

Type Crypto_JobPrimitiveInputOutputType.

Type Crypto_JobRedirectionInfoType.

Enumeration of the current job state.

Structure which contains further information, which depends on the job and the crypto primitive.

Enumeration for key status.

Enume ration which operation shall be performed. This enumeration is constructed from a bit mask, where the first bit indicates "Start", the second "Update" and the third "Finish".

Structure which contains basic information about the crypto primitive. Manager AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_CryptoServiceManager

Enumeration of the processing type.

Return for Std_ Return Type for Cryptostack.

Enumeration of the kind of the service.

Enumeration of the result type of verification operations.

Array long enough to store the data of the header.

Array long enough to store the ciphertext to be decrypted with AEAD.

Array long enough to store the data of the plaintext.

Array long enough to store the data of the Tag.

Array long enough to store the data of the header.

Array long enough to store the data of the cipher.

Array long enough to store the plaintext to be encrypted with AEAD.

Array long enough to store the data of the Tag.

Identification of a CSM service configuration via a numeric identifier, that is unique within a service. The name of a CSM service configuration, i.e. the name of the container Csm_Config, shall serve as a symbolic name for this parameter Avail able via Csm.h

Configuration data structure of Csm module

Array long enough to store the data to be decrypted.

Array long enough to store the data of the decrypted plaintext.

Array long enough to store the data to be encrypted.

Array long enough to store the data of the cipher.

Array long enough to store the data which shall be hashed.

Array long enough to store the data of the hash.

Array long enough to store any key element of the considered key

Implementation Data Type of category DATA_ REFERENCE with the pointer target uint32 to be able to return asynchronously the length.

Array long enough to store the data from which a MAC shall be generated.

Array long enough to store the data of the MAC.

Array long enough to store a MAC to be verified.

Array long enough to store the data for whichs MAC shall be verified.

Array long enough to store the data of the random number.

Array long enough to store the data from which the signature shall be generated.

Array long enough to store the signature and its length.

Array long enough to store a signature to be verified.

Array long enough to store the data for whichs signature shall be verified.

Implementation Data Type of category DATA_ REFERENCE with the pointer target Csm_ Verify Result Type to be able to return asynchronously the verify result.