DEENESPTFRRUARHIKOZHNL

class ara::crypto::Formatter

[SWS_CRYPT_50190] Upstream: RS_CRYPTO_02105

class Formatter {...};

Formatter object interface.

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

User GuideAI-GENERATED

Enables thread-safe conversion and serialization of cryptographic data between different formats.
AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: f0bec470b702 Provenance Open questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

Enables thread-safe conversion and serialization of cryptographic data between different formats.

The interface ara::crypto::Formatter enables thread-safe conversion and serialization of cryptographic data between raw, DER, and PEM formats [SWS_CRYPT_50197]. After determining the target format and determining the required buffer size, the method Convert transfers the source data into the prepared output buffer [SWS_CRYPT_50198]. An essential prerequisite for successful execution is a sufficiently dimensioned target memory and the formal compliance of the input data with the configured source format.

Context

The interface ara::crypto::Formatter defines the uniform interface for the formatting, transformation, and serialization of cryptographic data structures in the module crypto. Its primary task is to convert payload data and cryptographic objects between representations such as pure raw data (kFormatRawValueOnly), ASN.1 DER encodings (kFormatDerEncoded), and textual PEM formats (kFormatPemEncoded) taking into account an algorithm identifier (AlgId) [SWS_CRYPT_50197]. In doing so, the formatter acts as a link between cryptographic objects and memory buffers by reading data via ReadOnlyMemRegion and outputting it to ReadWriteMemRegion [SWS_CRYPT_50198].

Lifecycle

Since ara::crypto::Formatter is declared as a pure virtual interface, it provides the canonical smart pointer type alias Sptr, defined as std::shared_ptr<Formatter>, for referencing and lifecycle management [SWS_CRYPT_50191]. In practice, concrete instances of the interface are presumed to be provided via factory methods of higher-level crypto components. Question Q-99e96992d02b9c13 (open) After creation, a formatter is initially in an unconfigured initial state before it is prepared for conversions via configuration calls.

With regard to the execution environment, the interface guarantees full exception safety (exception safe) through the consistent use of noexcept and error handling via result types [SWS_CRYPT_50197], [SWS_CRYPT_50198], [SWS_CRYPT_50199]. All member functions are also specified as thread-safe (thread-safe) [SWS_CRYPT_50197], [SWS_CRYPT_50198], [SWS_CRYPT_50199]. This allows concurrent read and transforming access of multiple threads to a shared formatter instance, as long as no competing reconfigurations take place.

Usage Path

Regular usage of ara::crypto::Formatter follows a fixed sequence of parameterization, capacity check, and transformation:

  1. Format configuration: Via SetFormatConfiguration, the expected input format (inputFormat), the desired output format (outputFormat), and the algorithm identifier (algId) of the data to be processed are bindingly specified [SWS_CRYPT_50197].
  2. Size determination: Prior to the actual conversion, the application calls GetExportSize to determine the exact memory size in bytes required by the serialized object under the current configuration [SWS_CRYPT_50199]. This enables the tailored allocation of the target memory.
  3. Data conversion: Finally, Convert transforms the source data from a ReadOnlyMemRegion into the destination buffer ReadWriteMemRegion in accordance with the established configuration [SWS_CRYPT_50198].
Typical data conversion with the FormatterApplicationFormatterSetFormatConfiguration(inputFormat, outputFormat, algId)Result<void>GetExportSize()Result<std::size_t> (buffer size)Convert(input, out)Result<void>

Sequence diagram: Typical conversion sequence from format selection and buffer size determination to the actual transformation. Sources: [SWS_CRYPT_50197], [SWS_CRYPT_50199], [SWS_CRYPT_50198]

Error Scenarios

Methods of ara::crypto::Formatter signal error states deterministically via return values of type ara::core::Result. In this context, clear rollback semantics are defined for failing operations:

  • Unsupported formats: If the underlying implementation does not support the specified conversion pair or algorithm identifier, SetFormatConfiguration returns the error code ara::crypto::CryptoErrc::kUnsupportedFormat [SWS_CRYPT_50197].
  • Invalid input data: If the raw data passed in the buffer does not match the configured format or is syntactically invalid, Convert fails with ara::crypto::CryptoErrc::kInvalidArgument [SWS_CRYPT_50198].
  • Insufficient destination buffer: If the provided ReadWriteMemRegion is too small for the serialized result, Convert aborts with ara::crypto::CryptoErrc::kInsufficientCapacity [SWS_CRYPT_50198]. This issue can be specifically prevented by prior querying via GetExportSize [SWS_CRYPT_50199].
  • Missing pre-configuration: While no standardized error codes are listed for GetExportSize [SWS_CRYPT_50199], a valid configuration must presumably be established in advance via SetFormatConfiguration so that consistent size determination or conversion can take place. Question Q-e7cf4306bc7cfb49 (open)

This guide is based on the AUTOSAR Adaptive Platform R25-11 specification (crypto module) and was generated automatically.

Member map

Class diagram

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

G nara__crypto__Formatter631 Formatter + Convert() + GetExportSize() + SetFormatConfiguration()

Detail view

Select an entry in the outline.

Methods

Convert function

Converts the data according to the previous configuration of the Formatter.

virtual ara::core::Result< void > Convert (ReadOnlyMemRegion input, ReadWriteMemRegion out) const noexcept=0;
GetExportSize function

Get the size in bytes of the object when serialized using the current configuration of the Formatter.

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

Configure the formatter with the expected input format, output format, and the AlgId of the data to be formatted. The input and output format may be kFormatRawValueOnly, kFormatDer Encoded, or kFormatPemEncoded.

virtual ara::core::Result< void > SetFormatConfiguration (FormatId inputFormat, FormatId outputFormat, AlgId algId) noexcept=0;

Type aliases

Sptr type alias

Smart pointer of the interface.

using Sptr = std::shared_ptr<Formatter>;

Method documentation

function Convert [SWS_CRYPT_50198] Upstream: RS_CRYPTO_02112

virtual ara::core::Result< void > Convert (ReadOnlyMemRegion input, ReadWriteMemRegion out) const noexcept=0;

Converts the data according to the previous configuration of the Formatter.

AI-GENERATED unreviewed Model: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 96118f35b505 Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original

The pure virtual member function Convert of interface ara::crypto::Formatter performs a synchronous conversion of data according to the previously defined configuration of the formatter object [SWS_CRYPT_50198]. The declaration is available via header #include "ara/crypto/common/formatter.h" [SWS_CRYPT_50198]. For the call, the caller passes the input data in the original format via buffer input of type ReadOnlyMemRegion, as well as a writable buffer out of type ReadWriteMemRegion into which the converted data in the target format is written [SWS_CRYPT_50198].

The return value is defined as ara::core::Result<void> and signals success or an error that occurred [SWS_CRYPT_50198]. If a problem occurs during conversion, rollback semantics take effect with the following specific error codes [SWS_CRYPT_50198]:

  • ara::crypto::CryptoErrc::kInvalidArgument: Returned if the serialized input data does not conform to the specified format [SWS_CRYPT_50198].
  • ara::crypto::CryptoErrc::kInsufficientCapacity: Occurs when the capacity of the passed output buffer out is too small to receive the result data [SWS_CRYPT_50198].

With respect to concurrency and fault tolerance, the method is specified as thread-safe (thread-safe) and exception-safe (exception safe) [SWS_CRYPT_50198]. Since the signature is provided with the specifiers const and noexcept, the operation throws no C++ exceptions and does not modify the state of the formatter instance [SWS_CRYPT_50198].

This usage note was generated automatically by an AI based on the specification.

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

Parameter (in)

ParameterBeschreibung
inputan input buffer containing the data in the input format

Parameter (out)

ParameterBeschreibung
outan output buffer that the data will be written to in the output format

Rückgabewert

TypBeschreibung
ara::core::Result< void >An empty result or an error.

Fehler

FehlercodeBeschreibung
ara::crypto::CryptoErrc::kInvalidArgumentrollback_semantics if serialized does not conform to the specified format
ara::crypto::CryptoErrc::kInsufficientCapacityrollback_semantics if the output buffer is too small

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

Record
AUTOSAR/AP/record/SWS_CRYPT_50198
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_50198@rel:R25-11#19644f36
Content hash
19644f36
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_50198
Status: valid/unmigrated Version: rel:R25-11#19644f36 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_50198@rel:R25-11#19644f36
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

function GetExportSize [SWS_CRYPT_50199] Upstream: RS_CRYPTO_02112

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

Get the size in bytes of the object when serialized using the current configuration of the Formatter.

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

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
This function does not specify any standardized errors.

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

Record
AUTOSAR/AP/record/SWS_CRYPT_50199
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_50199@rel:R25-11#b96bc7d6
Content hash
b96bc7d6
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_50199
Status: valid/unmigrated Version: rel:R25-11#b96bc7d6 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_50199@rel:R25-11#b96bc7d6
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

function SetFormatConfiguration [SWS_CRYPT_50197] Upstream: RS_CRYPTO_02112

virtual ara::core::Result< void > SetFormatConfiguration (FormatId inputFormat, FormatId outputFormat, AlgId algId) noexcept=0;

Configure the formatter with the expected input format, output format, and the AlgId of the data to be formatted. The input and output format may be kFormatRawValueOnly, kFormatDer Encoded, or kFormatPemEncoded.

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

Parameter (in)

ParameterBeschreibung
inputFormatthe input format
outputFormatthe output format
algIdthe AlgId of the data to be formatted

Rückgabewert

TypBeschreibung
ara::core::Result< void >An empty result or an error.

Fehler

FehlercodeBeschreibung
ara::crypto::CryptoErrc::kUnsupportedFormatrollback_semantics if the specified conversion is not supported

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

Record
AUTOSAR/AP/record/SWS_CRYPT_50197
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_50197@rel:R25-11#25ee4601
Content hash
25ee4601
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_50197
Status: valid/unmigrated Version: rel:R25-11#25ee4601 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_50197@rel:R25-11#25ee4601
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

Type alias documentation

type alias Sptr [SWS_CRYPT_50191] Upstream: RS_CRYPTO_02306

using Sptr = std::shared_ptr<Formatter>;

Smart pointer of the interface.

Header-Datei#include "ara/crypto/common/formatter.h"
Scopeclass ara::crypto::Formatter
SymbolSptr

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

Record
AUTOSAR/AP/record/SWS_CRYPT_50191
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_50191@rel:R25-11#869e375a
Content hash
869e375a
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_50191
Status: valid/unmigrated Version: rel:R25-11#869e375a 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_50191@rel:R25-11#869e375a
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