1#ifndef SOURCEMETA_CORE_CRYPTO_AES_GCM_H_
2#define SOURCEMETA_CORE_CRYPTO_AES_GCM_H_
4#ifndef SOURCEMETA_CORE_CRYPTO_EXPORT
5#include <sourcemeta/core/crypto_export.h>
13namespace sourcemeta::core {
23 [[nodiscard]]
auto ciphertext() const -> std::string_view {
24 assert(this->data.size() >= 16);
25 return std::string_view{this->data}.substr(0, this->data.size() - 16);
29 [[nodiscard]]
auto tag() const -> std::string_view {
30 assert(this->data.size() >= 16);
31 return std::string_view{this->data}.substr(this->data.size() - 16);
50 const std::string_view key,
const std::string_view iv,
51 const std::string_view associated_data,
const std::string_view plaintext)
52 -> std::optional<AESGCMCiphertext>;
71 const std::string_view key,
const std::string_view iv,
72 const std::string_view associated_data,
const std::string_view ciphertext,
73 const std::string_view tag) -> std::optional<std::string>;
92auto SOURCEMETA_CORE_CRYPTO_EXPORT
94 -> std::optional<std::string>;
110auto SOURCEMETA_CORE_CRYPTO_EXPORT
112 -> std::optional<std::string>;
auto ciphertext() const -> std::string_view
The ciphertext, the same length as the plaintext.
Definition crypto_aes_gcm.h:23
std::string data
The ciphertext followed by its 16-byte authentication tag.
Definition crypto_aes_gcm.h:20
auto tag() const -> std::string_view
The 16-byte authentication tag.
Definition crypto_aes_gcm.h:29
auto SOURCEMETA_CORE_CRYPTO_EXPORT aes_256_gcm_unseal(const std::string_view key, const std::string_view sealed) -> std::optional< std::string >
auto SOURCEMETA_CORE_CRYPTO_EXPORT aes_gcm_encrypt(const std::string_view key, const std::string_view iv, const std::string_view associated_data, const std::string_view plaintext) -> std::optional< AESGCMCiphertext >
auto SOURCEMETA_CORE_CRYPTO_EXPORT aes_gcm_decrypt(const std::string_view key, const std::string_view iv, const std::string_view associated_data, const std::string_view ciphertext, const std::string_view tag) -> std::optional< std::string >
auto SOURCEMETA_CORE_CRYPTO_EXPORT aes_256_gcm_seal(const std::string_view key, const std::string_view plaintext) -> std::optional< std::string >
Definition crypto_aes_gcm.h:18