Encrypts data asymmetrically in a single step or via a multi-part streaming operation.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 9ba841f18186ProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Encrypts data asymmetrically in a single step or via a multi-part streaming operation.
The interface serves for asymmetric encryption of plaintext data on the AUTOSAR Adaptive Platform and is managed via the provided smart pointer [SWS_CRYPT_50174]. After assigning a suitable public key, messages can be transformed either compactly in a single pass or continuously via a multi-part streaming session [SWS_CRYPT_50090]. For proper execution, buffer sizes must be calculated in advance, with all context operations specified as exception-safe and thread-safe.
Context
The C++ class ara::crypto::cryp::EncryptorPublicCtx provides the standardized interface for asymmetric data encryption in the AUTOSAR Adaptive Platform. It serves client applications for encrypting plaintext data using an asymmetric public key. Configuration of the cryptographic key can take place either directly via a key object ([SWS_CRYPT_50175]) or via a reference to a key slot (KeySlot, [SWS_CRYPT_50086]). Data transfer occurs via memory-efficient buffer regions (ReadOnlyMemRegion for plaintext data and ReadWriteMemRegion for the ciphertext output).
Lifecycle
Instances of the context are managed via the shared pointer std::shared_ptr<EncryptorPublicCtx> defined in the type alias Sptr ([SWS_CRYPT_50174]). The creation itself is not part of this interface definition; instantiation is presumably performed via a higher-level factory component of the crypto architecture. Question Q-5b7490ba113bb861 (open) The object passes through clearly defined states during its lifetime:
Uninitialized: After instantiation, the context does not yet possess a key. Data processing operations are not permitted in this state.
Configured (Ready): Calling SetKey() with an PublicKey ([SWS_CRYPT_50175]) or a KeySlot ([SWS_CRYPT_50086]) makes the context ready for use. From this state, either single-step encryption can be executed or a streaming session can be started.
Streaming active: The call to Start() ([SWS_CRYPT_50087]) places the context into the streaming state. Consecutive data blocks are processed via Update() ([SWS_CRYPT_50176]). The session is either completed with Finish() ([SWS_CRYPT_50088]) or aborted with Cancel() ([SWS_CRYPT_50089]), returning the context to the Configured state.
All methods of the class are specified as exception-safe (exception safe) and thread-safe (thread-safe). If the context is destroyed while a streaming operation has not yet finished, the underlying implementation is expected to clean up allocated buffers and implicitly discard the session. Question Q-3eadc946a0bdbdfd (open)
The class supports two processing modes: single-step processing for complete datasets and multi-step streaming for segmented data streams. Before performing encryptions, applications must account for buffer limits:
Via GetMinimumChunkSize()` (<a class="spec-record-ref" data-req="SWS_CRYPT_50178">[SWS_CRYPT_50178]</a>) und <code>GetMaximumChunkSize() ([SWS_CRYPT_50091]), the minimum and maximum supported input sizes for individual calls can be determined.
The necessary capacity of the output buffer must be queried in advance with GetRequiredOutputBufferSize() ([SWS_CRYPT_50177]). The parameter isFinal controls whether the calculation is performed for intermediate steps (false) or final calls and single steps (true).
The typical sequence of a streaming encryption is divided into the following steps:
Key assignment via SetKey() with a valid PublicKey ([SWS_CRYPT_50175]).
Initialization of the streaming session by calling Start() ([SWS_CRYPT_50087]).
Calculation of the required output buffer size for intermediate blocks with GetRequiredOutputBufferSize(inputSize, false) ([SWS_CRYPT_50177]).
Repeated transformation of data blocks via Update() ([SWS_CRYPT_50176]).
Determination of the buffer size for the last block (isFinal = true) and finalization of the operation via Finish() ([SWS_CRYPT_50088]).
For compact data that can be processed in a single pass, Encrypt() ([SWS_CRYPT_50090]) provides a direct single-step call without division into start, update, and finish phases.
All methods use ara::core::Result for error signaling and guarantee rollback semantics in the event of an error:
State errors: A call to Start(), Encrypt(), or GetRequiredOutputBufferSize() on an uninitialized context results in ara::crypto::CryptoErrc::kUninitializedContext ([SWS_CRYPT_50087], [SWS_CRYPT_50090], [SWS_CRYPT_50177]). If Update(), Finish(), or Cancel() are called without Start() having been executed beforehand, the operation fails with ara::crypto::CryptoErrc::kProcessingNotStarted ([SWS_CRYPT_50176], [SWS_CRYPT_50088], [SWS_CRYPT_50089]).
Buffer and data errors: If the provided output buffer is too small, Encrypt(), Update(), and Finish() respond with ara::crypto::CryptoErrc::kInsufficientCapacity ([SWS_CRYPT_50090], [SWS_CRYPT_50176], [SWS_CRYPT_50088]). Deviations from the permitted chunk sizes result in ara::crypto::CryptoErrc::kInvalidInputSize, and invalid input data in ara::crypto::CryptoErrc::kInvalidArgument.
This guide is based on the requirements of AUTOSAR Adaptive Platform Release R25-11 and summarizes the specification of the class ara::crypto::cryp::EncryptorPublicCtx.
Cancel the ongoing streaming operation that has been initiated by Start() and has not yet been finished.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: c2111af75063ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The method Cancel() aborts an active streaming operation in context ara::crypto::cryp::EncryptorPublicCtx that was previously initiated via Start() and has not yet finished [SWS_CRYPT_50089]. It takes no input parameters and returns a ara::core::Result<void>, which is empty on success [SWS_CRYPT_50089]. Since the signature returns a Result directly and not a Future, the abort is likely executed synchronously. Question Q-cd18e56d693fe1a4 (open)
Error Handling and Concurrency
If data processing was not started in advance by Start(), the operation fails with the error code ara::crypto::CryptoErrc::kProcessingNotStarted complying with rollback semantics [SWS_CRYPT_50089]. According to the specification, the interface is declared with noexcept, exception safe, and classified as thread-safe for concurrent access [SWS_CRYPT_50089].
Interaction in the Crypto Stack
The abort behavior implemented by Cancel() follows a unified design pattern for stateful streaming operations in the crypto module. Analogous interfaces with identical error semantics exist for:
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 523fe4336ba2Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The synchronous method Encrypt serves to encrypt plaintext data in a single call ([SWS_CRYPT_50090]). It accepts the input data from buffer in (ReadOnlyMemRegion) and writes the ciphertext into the output buffer out (ReadWriteMemRegion) ([SWS_CRYPT_50090]). In the success case, the return value ara::core::Result<std::size_t> returns the size of the output data actually written, which may be smaller than the total capacity of out ([SWS_CRYPT_50090]).
With respect to concurrency, the function is specified as thread-safe (thread-safe) as well as exception-safe (exception safe) ([SWS_CRYPT_50090]).
In interaction with context EncryptorPublicCtx, the following buffer limits must be observed prior to the call:
The input size must be within the limits specified by [SWS_CRYPT_50178] (GetMinimumChunkSize) and [SWS_CRYPT_50091] (GetMaximumChunkSize).
The maximum required capacity of the output buffer out can be calculated in advance via GetRequiredOutputBufferSize with the parameter isFinal = true ([SWS_CRYPT_50177]).
All error cases have rollback semantics ([SWS_CRYPT_50090]). The defined errors from ara::crypto::CryptoErrc include:
kUninitializedContext: The context was not initialized by providing a key ([SWS_CRYPT_50090]).
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: ef643cd9b744Provenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The method Finish completes the asymmetric encryption operation in the context of ara::crypto::cryp::EncryptorPublicCtx[SWS_CRYPT_50088]. The call is synchronous and is specified as noexcept, exception-safe, and thread-safe. As parameters, the function accepts the final plaintext fragment via in (ReadOnlyMemRegion) and writes the resulting ciphertext data to the output buffer out (ReadWriteMemRegion). The required buffer size for out can be determined in advance via GetRequiredOutputBufferSize(). The return value ara::core::Result<std::size_t> returns the number of bytes actually written in the success case, which may be smaller than the total capacity of the output buffer [SWS_CRYPT_50088].
Error Handling and Concurrency
All error cases have rollback semantics, so that the context state remains consistent upon failure [SWS_CRYPT_50088]. The method reports the following specific error codes from ara::crypto::CryptoErrc:
kProcessingNotStarted: Data processing was not previously initiated by calling Start().
kInsufficientCapacity: The provided output buffer out is dimensioned too small.
kInvalidInputSize: The buffer size of in cannot be processed by the context.
kInvalidArgument: The passed input data contains invalid values.
kUnsupported: Stream processing is not supported by the concrete context.
Interaction
Finalization concludes the cryptographic processing sequence [SWS_CRYPT_50088]. DecryptorPrivateCtx::Finish[SWS_CRYPT_50068] acts as the complementary counterpart for decryption, while in the area of symmetric ciphers SymmetricCipherCtx::Finish[SWS_CRYPT_50045] provides a comparable sequence pattern.
This text was generated by an AI process based on the specification.
Configure the context to use the key stored in the provided KeySlot at the time the encryption is started.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: e68fdee554baProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Usage and Call Context
The pure virtual method SetKey of interface ara::crypto::cryp::EncryptorPublicCtx (header file ara/crypto/cryp/encryptor_public_ctx.h) serves to assign a key for asymmetric cipher operations [SWS_CRYPT_50086]. A smart pointer keySlot of type KeySlot::Sptr, which must contain a PublicKey, is passed as a parameter [SWS_CRYPT_50086]. The call is synchronous and signals success via an empty ara::core::Result<void>. Essential for the semantics is that the key stored in the slot is used only at the point in time when the encryption is started [SWS_CRYPT_50086]. (Interpretation: Since key resolution takes place only with the actual encryption start, updates to the slot content before this start time should still take effect.) Question Q-25c5d462aafde8a1 (open)
Error handling
If configuration fails, an error code with rollback semantics is returned in the result object [SWS_CRYPT_50086]:
ara::crypto::CryptoErrc::kIncompatibleObject: Reported if the provided keySlot is incompatible with this context [SWS_CRYPT_50086].
ara::crypto::CryptoErrc::kUnsupported: Occurs if the concrete context implementation exclusively supports direct setting of a PublicKey and does not permit key binding via a KeySlot[SWS_CRYPT_50086].
Concurrency and Interaction
The operation is declared as noexcept, exception-safe (exception safe), and specified as thread-safe (thread-safe) for concurrent use [SWS_CRYPT_50086].
The concept of indirect key referencing via KeySlot is also found in a comparable manner in other asymmetric contexts, such as VerifierPublicCtx::SetKey[SWS_CRYPT_50018] and KeyEncapsulatorPublicCtx::SetKey[SWS_CRYPT_50012]. It differs from methods that accept key objects directly, such as in [SWS_CRYPT_24115] or [SWS_CRYPT_21815].
This usage note was generated by an AI based on the AUTOSAR specification.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 09de2ed1c4fcProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The virtual method SetKey of class ara::crypto::cryp::EncryptorPublicCtx configures the context to use a provided public key [SWS_CRYPT_50175].
The key object to be used for encryption is passed via parameter key (of type PublicKey::Sptr) [SWS_CRYPT_50175].
Execution is synchronous and returns a ara::core::Result<void>, which contains no value on success [SWS_CRYPT_50175].
Error handling
If an error occurs during configuration, a corresponding error code with defined rollback semantics is reported [SWS_CRYPT_50175]:
ara::crypto::CryptoErrc::kUsageViolation: The allowed key usage does not permit data encryption (kAllowDataEncryption) [SWS_CRYPT_50175].
ara::crypto::CryptoErrc::kIncompatibleObject: The passed key object is incompatible with this encryption context [SWS_CRYPT_50175].
ara::crypto::CryptoErrc::kUnsupported: The concrete context implementation exclusively supports binding via a KeySlot[SWS_CRYPT_50175].
Concurrency and Limitations
The interface is defined as noexcept and specifies a behavior that is both thread-safe and exception safe[SWS_CRYPT_50175].
Thanks to the rollback semantics, the context remains in its previous state in the event of an error.
Interpretation: A successful call is likely a mandatory prerequisite for subsequent encryption operations, as the context cannot perform any operations without an assigned key. Question Q-ab4779cac18793fa (open)
Interaction
This approach follows the module-wide pattern of asymmetric contexts, as also used in VerifierPublicCtx::SetKey[SWS_CRYPT_24115] and KeyEncapsulatorPublicCtx::SetKey[SWS_CRYPT_21815] for key binding.
Alternatively, related interfaces also provide KeySlot variants for configuration, such as in VerifierPublicCtx[SWS_CRYPT_50018] or KeyEncapsulatorPublicCtx[SWS_CRYPT_50012].
This text was generated by an AI system based on the AUTOSAR R25-11 specification.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 50b972147b28ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Usage and Semantics
The pure virtual method Start of class ara::crypto::cryp::EncryptorPublicCtx serves to initialize the context for a new encryption [SWS_CRYPT_50087]. It takes no input parameters and is executed synchronously. As a return value, the function returns an ara::core::Result<void> that either confirms successful initialization or conveys an occurred error code [SWS_CRYPT_50087].
Error handling and rollback behavior
If the required preconditions for the encryption operation are not met, the call fails. The specification guarantees rollback semantics for error cases and defines the following error causes [SWS_CRYPT_50087]:
UninitializedContext: No key was assigned to the context in advance.
ara::crypto::CryptoErrc::kEmptyKeySlot: A configured KeySlot is currently unoccupied.
ara::crypto::CryptoErrc::kUsageViolation: The permissions of the key do not contain the usage flag kAllowDataEncryption.
ara::crypto::CryptoErrc::kIncompatibleObject: The assigned key type is incompatible with the required transformation.
ara::crypto::CryptoErrc::kBusyResource: A resource required for initialization is occupied.
ara::crypto::CryptoErrc::kUnsupported: Stream processing is not supported by the concrete context.
Concurrency and Interaction
The method is specified as thread-safe and exception safe[SWS_CRYPT_50087]. Providing a suitable key in the context is a mandatory precondition for success. Conceptually, the function fits into standardized lifecycles of cryptographic contexts in which operations are prepared via parameterless calls – comparable to signature verifications [SWS_CRYPT_50019], signature generations [SWS_CRYPT_50037], or MAC calculations [SWS_CRYPT_22111]. The call should represent the mandatory starting point before the actual execution of a stream encryption. Question Q-db262c3914e6b4cf (open)
This usage note was generated automatically based on the AUTOSAR specification R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 01cf25c1d489ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
use
The synchronous method Update of class ara::crypto::cryp::EncryptorPublicCtx serves to encrypt plaintext data blocks step by step [SWS_CRYPT_50176]. A portion of the plaintext is passed via parameter in (ReadOnlyMemRegion), while the encrypted data is written to the output buffer out (ReadWriteMemRegion) [SWS_CRYPT_50176]. As a return value, the function provides via ara::core::Result<std::size_t> the actual number of bytes written, which can be smaller than the provided capacity of out[SWS_CRYPT_50176].
Sequence and Interaction
Prior to the first call to Update, data processing must mandatory have been initiated by Start()[SWS_CRYPT_50176]. The maximum permitted input size for individual calls can be queried via method GetMaximumChunkSize()[SWS_CRYPT_50091]. In addition, the minimum size required for out can be calculated via GetRequiredOutputBufferSize()[SWS_CRYPT_50176].
Error Handling and Concurrency
If an error occurs during execution, it is reported with rollback semantics [SWS_CRYPT_50176]:
ara::crypto::CryptoErrc::kProcessingNotStarted: Data processing was not previously started with Start()[SWS_CRYPT_50176].
ara::crypto::CryptoErrc::kInsufficientCapacity: The capacity of buffer out is insufficient for the result [SWS_CRYPT_50176].
ara::crypto::CryptoErrc::kInvalidInputSize: The buffer size of in is invalid [SWS_CRYPT_50176].
ara::crypto::CryptoErrc::kUnsupported: Stream processing is not supported by the current context [SWS_CRYPT_50176].
The method is declared as exception-safe and thread-safe [SWS_CRYPT_50176]. Nevertheless, parallel calls of multiple operations on the same context object are presumably likely to require external synchronization in order to guarantee a deterministic order of the encrypted data fragments. Question Q-b22ffe505b583b25 (open)
This text was created by an AI and serves as guidance. The specification is binding.
an input data buffer containing a part of the plaintext
Parameter (out)
Parameter
Beschreibung
out
an output data buffer that the encrypted data will be written into. The required size of this buffer can be queried using GetRequired OutputBufferSize()
gemini-3.8-flash-low· 2026-10-13 · German original