DEENESPTFRRUARHIKOZHNL

class ara::crypto::Serializable

[SWS_CRYPT_10700] Upstream: RS_CRYPTO_02105

class Serializable {...};

Serializable object interface.

Header-Datei#include "ara/crypto/common/serializable.h"
Forwarding-Header#include "ara/crypto/crypto_fwd.h"
Scopenamespace ara::crypto

User GuideAI-GENERATED

Defines the interface for size determination and public serialization of cryptographic objects.
AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: dacacac17ff9 Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Defines the interface for size determination and public serialization of cryptographic objects.

The interface ara::crypto::Serializable defines the uniform standard for publicly exporting cryptographic objects into format-specific byte sequences. Applications determine the required buffer size in advance via GetExportSize() and subsequently execute the actual serialization via ExportPublicly() into a provided buffer [SWS_CRYPT_10711]. All operations are exception-safe as well as thread-safe, where exporting keys strictly requires the permission kAllowPlaintextExport and errors are always subject to rollback semantics [SWS_CRYPT_50006].

Context

The interface ara::crypto::Serializable defines the abstract contract for cryptographic objects in module crypto that can be converted into a standardized byte representation. As a pure interface, it encapsulates the ability to serialize an object into an output format specified by a format identifier (FormatId) [SWS_CRYPT_10711]. Typical interaction partners include application or platform components that need to persistently store cryptographic artifacts such as keys or certificates, transmit them over communication channels, or exchange them in plain text. The interface ensures that the export is carried out in a controlled manner and in consideration of formats as well as security restrictions.

Lifecycle

Since ara::crypto::Serializable represents a purely virtual interface with pure virtual methods, the class has no instantiation logic of its own. The lifetime and creation depend entirely on the derived concrete crypto classes that implement the interface. Both specified methods of the interface, GetExportSize() [SWS_CRYPT_50006] and ExportPublicly() [SWS_CRYPT_10711], are declared as const and do not modify the internal state of the object during serialization. According to the specification, the operations are designed to be exception-safe (exception safe) and thread-safe (thread-safe) [SWS_CRYPT_10711], [SWS_CRYPT_50006], so that concurrent read accesses to the same object instance are permitted.

Usage Path

The regular flow of an export is divided into a two-stage sequence of size determination and actual serialization. To avoid buffer overflows or failing allocations, the caller queries the exact required buffer size in bytes for the desired target format in advance via the method GetExportSize() [SWS_CRYPT_50006]. Following successful feedback, the caller provides a writable memory area of type ReadWriteMemRegion. In most implementations, this memory area is presumably allocated dynamically based on the determined number of bytes or provided from a pre-reserved memory pool. Question Q-0c04ba0a352f0a37 (open)

In the subsequent step, the application calls ExportPublicly() and passes both the provided buffer and the previously selected FormatId [SWS_CRYPT_10711]. The object serializes its payload into the passed memory area and, in the success case, returns the number of bytes actually written within the return type ara::core::Result<std::size_t> [SWS_CRYPT_10711].

Serialization sequence via ara::crypto::SerializableApplicationSerializableGetExportSize(format)Result<std::size_t> (buffer size)Bereitstellung ReadWriteMemRegionExportPublicly(out, format)Result<std::size_t> (geschriebene Bytes)

Sequence diagram: Typical call sequence for serializing an object via size query and subsequent export. Sources: [SWS_CRYPT_50006], [SWS_CRYPT_10711]

Error Scenarios

The operations of the interface signal error conditions via the return type ara::core::Result, with all specified errors guaranteeing strict rollback semantics (rollback_semantics) [SWS_CRYPT_10711], [SWS_CRYPT_50006]. If a call fails, the overall system remains in a consistent state. The following error cases are defined:

  • ara::crypto::CryptoErrc::kUnsupportedFormat: Returned by both GetExportSize() [SWS_CRYPT_50006] and ExportPublicly() [SWS_CRYPT_10711] if the specified FormatId is not supported for the concrete object type.
  • ara::crypto::CryptoErrc::kInsufficientCapacity: Occurs in ExportPublicly() if the capacity of the passed ReadWriteMemRegion buffer is insufficient for the serialized data [SWS_CRYPT_10711].
  • ara::crypto::CryptoErrc::kUnsupported: Reported by ExportPublicly() if export is fundamentally not supported for the specific object [SWS_CRYPT_10711].
  • ara::crypto::CryptoErrc::kUsageViolation: Occurs with ExportPublicly() if the object is a key whose usage rules do not permit plaintext export (the permitted usage does not include kAllowPlaintextExport) [SWS_CRYPT_10711].

This guide is based on the AUTOSAR R25-11 specification.

UML class diagram

Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.

G nara__crypto__Serializable855 Serializable + ExportPublicly() + GetExportSize() nara__crypto__cryp__CryptoObject679 CryptoObject nara__crypto__cryp__CryptoObject679->nara__crypto__Serializable855 nara__crypto__x509__CertSignRequest934 CertSignRequest nara__crypto__x509__CertSignRequest934->nara__crypto__Serializable855 nara__crypto__x509__Certificate240 Certificate nara__crypto__x509__Certificate240->nara__crypto__Serializable855 nara__crypto__x509__X509DN930 X509DN nara__crypto__x509__X509DN930->nara__crypto__Serializable855

Methods

Serialize object using the provided format.

virtual ara::core::Result< std::size_t > ExportPublicly (ReadWriteMem Region out, FormatId format) const noexcept=0;
GetExportSize function

Get the size in bytes of the object when serialized in the provided format using ExportPublicly()

virtual ara::core::Result< std::size_t > GetExportSize (FormatId format) const noexcept=0;

Method documentation

function ExportPublicly [SWS_CRYPT_10711] Upstream: RS_CRYPTO_02112

virtual ara::core::Result< std::size_t > ExportPublicly (ReadWriteMem Region out, FormatId format) const noexcept=0;

Serialize object using the provided format.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 499fb38eb87a Provenance Open questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

use

The synchronous member function ExportPublicly of interface ara::crypto::Serializable serializes the object in the specified output format [SWS_CRYPT_10711]. Passed as parameters are the format identifier format (type FormatId) and the target memory area out (type ReadWriteMem Region). Upon successful execution, the function returns the actual number of bytes written in a ara::core::Result<std::size_t> [SWS_CRYPT_10711].

Interaction with related functions

The function is directly related to GetExportSize [SWS_CRYPT_50006], which can be used to determine the byte size required for a specific format. Callers are likely typically to query GetExportSize first before providing the output buffer out in order to ensure sufficient buffer capacity. Question Q-394ae08d9d7e6fa7 (open)

Error handling

In case of error, rollback semantics take effect and a corresponding error code is returned [SWS_CRYPT_10711]:

  • ara::crypto::CryptoErrc::kInsufficientCapacity: The passed output buffer out is sized too small [SWS_CRYPT_10711].
  • ara::crypto::CryptoErrc::kUnsupportedFormat: The passed format identifier is not supported for this object type [SWS_CRYPT_10711].
  • ara::crypto::CryptoErrc::kUnsupported: Exporting the object is not supported in general [SWS_CRYPT_10711].
  • ara::crypto::CryptoErrc::kUsageViolation: The object to be exported is a key whose usage rules do not permit plaintext export (kAllowPlaintextExport) [SWS_CRYPT_10711].

Concurrency and Constraints

The method is specified as const, noexcept, thread-safe, and exception-safe [SWS_CRYPT_10711]. Consequently, it can be executed concurrently and throws no C++ exceptions.

This usage note was generated by an AI based on the AUTOSAR specification R25-11.

Implementer's Guide to follow (complexity I1)

Header-Datei#include "ara/crypto/common/serializable.h"
Scopeclass ara::crypto::Serializable
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
formatidentifier of the output format

Parameter (out)

ParameterBeschreibung
outan output buffer that the serialized object will be written to

Rückgabewert

TypBeschreibung
ara::core::Result<std::size_t >A result containing the size in bytes of the serialized object or an error.

Fehler

FehlercodeBeschreibung
ara::crypto::CryptoErrc::kInsufficientCapacityrollback_semantics if the output buffer is too small
ara::crypto::CryptoErrc::kUnsupportedFormatrollback_semantics if the specified format ID is not supported for this object type
ara::crypto::CryptoErrc::kUnsupportedrollback_semantics if exporting the object is not supported
ara::crypto::CryptoErrc::kUsageViolationrollback_semantics if the object to be exported is a key and the allowed usage of the key does not include kAllowPlaintextExport

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CRYPT_10711
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_10711@rel:R25-11#6e8a805e
Content hash
6e8a805e
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_10711
Status: valid/unmigrated Version: rel:R25-11#c8dd72d0 Versionshistorie & Revisions (1 transition, 8 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CRYPT_10711@rel:R25-11#c8dd72d0
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#6e8a805e2026-09-30
  • R19-11rel:R19-11#fe62960e2026-10-14
  • R20-11rel:R20-11#4cac78d62026-10-14
  • R21-11rel:R21-11#13d51a182026-10-14
  • R22-11rel:R22-11#3bb1942d2026-10-14
  • R23-11rel:R23-11#ee143e792026-10-14
  • R24-11rel:R24-11#761192782026-10-14
  • R25-11rel:R25-11#c8dd72d02026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

function GetExportSize [SWS_CRYPT_50006] Upstream: RS_CRYPTO_02112

virtual ara::core::Result< std::size_t > GetExportSize (FormatId format) const noexcept=0;

Get the size in bytes of the object when serialized in the provided format using ExportPublicly()

Header-Datei#include "ara/crypto/common/serializable.h"
Scopeclass ara::crypto::Serializable
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
formatidentifier of the output format

Rückgabewert

TypBeschreibung
ara::core::Result<std::size_t >A result containing the size in bytes of the serialized object or an error.

Fehler

FehlercodeBeschreibung
ara::crypto::CryptoErrc::kUnsupportedFormatrollback_semantics if the specified format ID is not supported for this object type

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CRYPT_50006
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_50006@rel:R25-11#6c5e92f9
Content hash
6c5e92f9
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_50006
Status: valid/unmigrated Version: rel:R25-11#6c5e92f9 Versionshistorie & Revisions (1 transition)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_CRYPT_50006@rel:R25-11#6c5e92f9
Point-in-Time History:
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill