Asylo
Public Member Functions | Static Public Member Functions | List of all members
asylo::experimental::AeadCryptor Class Reference

An AEAD cryptor that provides Seal() and Open() functionality. More...

#include <aead_cryptor.h>

Public Member Functions

size_t MaxMessageSize () const
 Gets the maximum size of a message that may be sealed successfully. More...
 
uint64_t MaxSealedMessages () const
 Gets the maximum number of messages that may be sealed successfully. More...
 
size_t MaxSealOverhead () const
 Gets the max overhead of Seal(). More...
 
size_t NonceSize () const
 Gets the nonce size. More...
 
Status Seal (ByteContainerView plaintext, ByteContainerView associated_data, absl::Span< uint8_t > nonce, absl::Span< uint8_t > ciphertext, size_t *ciphertext_size)
 Implements the AEAD Seal operation. More...
 
Status Open (ByteContainerView ciphertext, ByteContainerView associated_data, ByteContainerView nonce, absl::Span< uint8_t > plaintext, size_t *plaintext_size)
 Implements the AEAD Open operation. More...
 

Static Public Member Functions

static StatusOr< std::unique_ptr< AeadCryptor > > CreateAesGcmCryptor (ByteContainerView key)
 Creates a cryptor that uses AES-GCM for Seal() and Open(), and generates random 96-bit nonces for use in Seal(). More...
 
static StatusOr< std::unique_ptr< AeadCryptor > > CreateAesGcmSivCryptor (ByteContainerView key)
 Creates a cryptor that uses AES-GCM-SIV for Seal() and Open(), and generates random 96-bit nonces for use in Seal(). More...
 
static StatusOr< size_t > MaxMessageSize (AeadScheme scheme)
 Gets the maximum size of a message that may be sealed successfully with a cryptor that uses scheme. More...
 
static StatusOr< uint64_t > MaxSealedMessages (AeadScheme scheme)
 Gets the maximum number of messages that may be sealed safely with a cryptor that uses scheme. More...
 

Detailed Description

An AEAD cryptor that provides Seal() and Open() functionality.

Currently supported configurations:

Member Function Documentation

◆ CreateAesGcmCryptor()

static StatusOr<std::unique_ptr<AeadCryptor> > asylo::experimental::AeadCryptor::CreateAesGcmCryptor ( ByteContainerView  key)
static

Creates a cryptor that uses AES-GCM for Seal() and Open(), and generates random 96-bit nonces for use in Seal().

Parameters
keyThe underlying key used for encryption and decryption.
Returns
A pointer to the created cryptor, or a non-OK Status if creation failed.

◆ CreateAesGcmSivCryptor()

static StatusOr<std::unique_ptr<AeadCryptor> > asylo::experimental::AeadCryptor::CreateAesGcmSivCryptor ( ByteContainerView  key)
static

Creates a cryptor that uses AES-GCM-SIV for Seal() and Open(), and generates random 96-bit nonces for use in Seal().

Parameters
keyThe underlying key used for encryption and decryption.
Returns
A pointer to the created cryptor, or a non-OK Status if creation failed.

◆ MaxMessageSize() [1/2]

static StatusOr<size_t> asylo::experimental::AeadCryptor::MaxMessageSize ( AeadScheme  scheme)
static

Gets the maximum size of a message that may be sealed successfully with a cryptor that uses scheme.

Parameters
schemeThe associated AeadScheme.
Returns
The maximum message size that may be sealed successfully, or a non-OK Status if scheme is unsupported.

◆ MaxMessageSize() [2/2]

size_t asylo::experimental::AeadCryptor::MaxMessageSize ( ) const

Gets the maximum size of a message that may be sealed successfully.

Returns
The maximum message size that this cryptor will seal successfully.

◆ MaxSealedMessages() [1/2]

static StatusOr<uint64_t> asylo::experimental::AeadCryptor::MaxSealedMessages ( AeadScheme  scheme)
static

Gets the maximum number of messages that may be sealed safely with a cryptor that uses scheme.

Parameters
schemeThe associated AeadScheme.
Returns
The maximum number of messages that may be sealed safely, or a non-OK Status if scheme is unsupported.

◆ MaxSealedMessages() [2/2]

uint64_t asylo::experimental::AeadCryptor::MaxSealedMessages ( ) const

Gets the maximum number of messages that may be sealed successfully.

Returns
The maximum number of messages that this cryptor will seal successfully.

◆ MaxSealOverhead()

size_t asylo::experimental::AeadCryptor::MaxSealOverhead ( ) const

Gets the max overhead of Seal().

Returns
The maximum space overhead of Seal().

◆ NonceSize()

size_t asylo::experimental::AeadCryptor::NonceSize ( ) const

Gets the nonce size.

Returns
The nonce size.

◆ Open()

Status asylo::experimental::AeadCryptor::Open ( ByteContainerView  ciphertext,
ByteContainerView  associated_data,
ByteContainerView  nonce,
absl::Span< uint8_t >  plaintext,
size_t *  plaintext_size 
)

Implements the AEAD Open operation.

nonce.size() must be greater than or equal to the value returned by NonceSize(). plaintext is not resized, but its final size is returned through plaintext_size. To ascertain that plaintext is not smaller than is necessary for Open(), plaintext.size() should be greater than or equal to ciphertext.size().

Parameters
ciphertextThe sealed ciphertext.
associated_dataThe authenticated data for the Open() operation.
nonceThe nonce used to seal the ciphertext.
[out]plaintextThe unsealed ciphertext.
[out]plaintext_sizeThe size of the plaintext.
Returns
The resulting status of the Open() operation.

◆ Seal()

Status asylo::experimental::AeadCryptor::Seal ( ByteContainerView  plaintext,
ByteContainerView  associated_data,
absl::Span< uint8_t >  nonce,
absl::Span< uint8_t >  ciphertext,
size_t *  ciphertext_size 
)

Implements the AEAD Seal operation.

The nonce used is returned through nonce and the authenticated ciphertext is written to ciphertext. plaintext.size() must be less than or equal to MaxMessageSize(). nonce.size() must be greater than or equal to the value returned by NonceSize(). ciphertext.size() must be greater than or equal to plaintext.size() + MaxSealOverhead(). ciphertext is not resized, but its final size is returned through ciphertext_size. Seal() will succeed at most MaxSealedMessages() times.

Parameters
plaintextThe secret that will be sealed.
associated_dataThe authenticated data for the Seal() operation.
[out]nonceThe generated nonce.
[out]ciphertextThe sealed ciphertext of plaintext.
[out]ciphertext_sizeThe size of ciphertext.
Returns
The resulting status of the Seal() operation.

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