Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::Cryptography::Aead Struct Reference

Public Types

using InternalOpaque = OpaqueObject<InternalDefinition>
 

Public Member Functions

 Aead ()
 Construct a session using the default native backend.
 
 Aead (Backend backend)
 Construct a session using an explicitly selected backend.
 
 Aead (const Aead &)=delete
 
 Aead (Aead &&)=delete
 
Aeadoperator= (const Aead &)=delete
 
Aeadoperator= (Aead &&)=delete
 
Result init (AeadType type, Span< const uint8_t > key)
 Initialize an AEAD context with a single key.
 
Result seal (Span< const uint8_t > nonce, Span< const uint8_t > aad, Span< const uint8_t > plaintext, Span< uint8_t > ciphertext, Span< uint8_t > tag, size_t &bytesWritten)
 Encrypt a single message using AEAD.
 
Result open (Span< const uint8_t > nonce, Span< const uint8_t > aad, Span< const uint8_t > ciphertext, Span< const uint8_t > tag, Span< uint8_t > plaintext, size_t &bytesWritten)
 Decrypt a single message using AEAD.
 

Constructor & Destructor Documentation

◆ Aead() [1/2]

SC::Cryptography::Aead::Aead ( )

Construct a session using the default native backend.

◆ Aead() [2/2]

SC::Cryptography::Aead::Aead ( Backend backend)
explicit

Construct a session using an explicitly selected backend.

Member Function Documentation

◆ init()

Result SC::Cryptography::Aead::init ( AeadType type,
Span< const uint8_t > key )

Initialize an AEAD context with a single key.

Note
Every initialization attempt discards the previous key, including when initialization fails.

◆ open()

Result SC::Cryptography::Aead::open ( Span< const uint8_t > nonce,
Span< const uint8_t > aad,
Span< const uint8_t > ciphertext,
Span< const uint8_t > tag,
Span< uint8_t > plaintext,
size_t & bytesWritten )

Decrypt a single message using AEAD.

Parameters
nonceNonce/IV for the message. Must be 12 bytes for AES-GCM.
aadAdditional authenticated data. Must not overlap plaintext. The Linux AF_ALG backend accepts at most 4096 bytes.
ciphertextInput ciphertext.
tagInput authentication tag. Must be 16 bytes and must not overlap plaintext.
plaintextOutput plaintext span. Must be at least ciphertext size. Exact overlap is allowed; partial overlap is rejected. Nonce and AAD must not overlap plaintext. Authentication or backend failure clears the complete output span; validation failure leaves it unchanged.
[out]bytesWrittenNumber of plaintext bytes written. Always zero on failure.

◆ seal()

Result SC::Cryptography::Aead::seal ( Span< const uint8_t > nonce,
Span< const uint8_t > aad,
Span< const uint8_t > plaintext,
Span< uint8_t > ciphertext,
Span< uint8_t > tag,
size_t & bytesWritten )

Encrypt a single message using AEAD.

Parameters
nonceNonce/IV for the message. Must be 12 bytes for AES-GCM and unique for every message under a key.
aadAdditional authenticated data. Must not overlap ciphertext or tag. The Linux AF_ALG backend accepts at most 4096 bytes.
plaintextInput plaintext.
ciphertextOutput ciphertext span. Must be at least plaintext size. Exact overlap is allowed; partial overlap is rejected.
tagOutput authentication tag. Must be 16 bytes and must not overlap another argument.
[out]bytesWrittenNumber of ciphertext bytes written. Always zero on failure. Validation failures leave outputs unchanged; after a backend failure ciphertext and tag must be treated as unusable.

The documentation for this struct was generated from the following file: