19 #ifndef ASYLO_CRYPTO_AEAD_CRYPTOR_H_ 20 #define ASYLO_CRYPTO_AEAD_CRYPTOR_H_ 25 #include "absl/types/span.h" 26 #include "asylo/crypto/aead_key.h" 27 #include "asylo/crypto/algorithms.pb.h" 28 #include "asylo/crypto/nonce_generator_interface.h" 29 #include "asylo/crypto/util/byte_container_view.h" 30 #include "asylo/util/statusor.h" 135 AeadCryptor(std::unique_ptr<AeadKey> key, size_t max_message_size,
136 uint64_t max_sealed_messages,
137 std::unique_ptr<NonceGeneratorInterface> nonce_generator);
140 const std::unique_ptr<AeadKey> key_;
143 const size_t max_message_size_;
146 const uint64_t max_sealed_messages_;
149 const std::unique_ptr<NonceGeneratorInterface> nonce_generator_;
152 size_t number_of_sealed_messages_;
Status Open(ByteContainerView ciphertext, ByteContainerView associated_data, ByteContainerView nonce, absl::Span< uint8_t > plaintext, size_t *plaintext_size)
Implements the AEAD Open operation.
static StatusOr< uint64_t > MaxSealedMessages(AeadScheme scheme)
Gets the maximum number of messages that may be sealed safely with a cryptor that uses scheme...
An AEAD cryptor that provides Seal() and Open() functionality.
Definition: aead_cryptor.h:39
size_t NonceSize() const
Gets the nonce size.
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...
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
uint64_t MaxSealedMessages() const
Gets the maximum number of messages that may be sealed successfully.
size_t MaxMessageSize() const
Gets the maximum size of a message that may be sealed successfully.
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...
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.
Definition: aead_cryptor.h:155
size_t MaxSealOverhead() const
Gets the max overhead of Seal().
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...