AES-GCM cipher helper that encrypts and authenticates payloads.
More...
#include <src/crypto.h>
|
| int | decrypt (const std::string_view &cipher, std::vector< std::uint8_t > &plaintext, aes_t *iv) |
| | Decrypt ciphertext into the supplied plaintext buffer.
|
| int | encrypt (const std::string_view &plaintext, std::uint8_t *tag, std::uint8_t *ciphertext, aes_t *iv) |
| | Encrypts the plaintext using AES GCM mode.
|
| int | encrypt (const std::string_view &plaintext, std::uint8_t *tagged_cipher, aes_t *iv) |
| | Encrypts the plaintext using AES GCM mode. length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size.
|
| | gcm_t (const crypto::aes_t &key_material, bool use_padding=true) |
| | Explicitly construct an AES-GCM cipher helper with key material and IV state.
|
|
| gcm_t (gcm_t &&) noexcept=default |
| | Construct an AES-GCM cipher helper with key material and IV state.
|
| gcm_t & | operator= (gcm_t &&) noexcept=default |
| | Assign state from another instance while preserving ownership semantics.
|
|
|
cipher_ctx_t | decrypt_ctx |
| | Decrypt ctx.
|
|
cipher_ctx_t | encrypt_ctx |
| | Encrypt ctx.
|
|
aes_t | key |
| | AES key used by the cipher context.
|
|
bool | padding |
| | Enables block padding for the cipher.
|
AES-GCM cipher helper that encrypts and authenticates payloads.
◆ gcm_t()
| crypto::cipher::gcm_t::gcm_t |
( |
const crypto::aes_t & | key_material, |
|
|
bool | use_padding = true ) |
|
explicit |
Explicitly construct an AES-GCM cipher helper with key material and IV state.
- Parameters
-
| key_material | AES key material used to initialize the cipher. |
| use_padding | Whether the cipher should use block padding. |
◆ decrypt()
| int crypto::cipher::gcm_t::decrypt |
( |
const std::string_view & | cipher, |
|
|
std::vector< std::uint8_t > & | plaintext, |
|
|
aes_t * | iv ) |
Decrypt ciphertext into the supplied plaintext buffer.
- Parameters
-
| cipher | Ciphertext bytes to decrypt or output buffer for encryption. |
| plaintext | Plaintext bytes to encrypt. |
| iv | Initialization vector for the cipher operation. |
- Returns
- Number of bytes written, signature bytes, or an error status depending on the overload.
◆ encrypt() [1/2]
| int crypto::cipher::gcm_t::encrypt |
( |
const std::string_view & | plaintext, |
|
|
std::uint8_t * | tag, |
|
|
std::uint8_t * | ciphertext, |
|
|
aes_t * | iv ) |
Encrypts the plaintext using AES GCM mode.
- Parameters
-
| plaintext | The plaintext data to be encrypted. |
| tag | The buffer where the GCM tag will be written. |
| ciphertext | The buffer where the resulting ciphertext will be written. |
| iv | The initialization vector to be used for the encryption. |
- Returns
- The total length of the ciphertext and GCM tag. Returns -1 in case of an error.
This function encrypts the given plaintext using the AES key in GCM mode. The initialization vector (IV) is also provided. The function handles the creation and initialization of the encryption context, and manages the encryption process. The resulting ciphertext and the GCM tag are written into the tagged_cipher buffer.
◆ encrypt() [2/2]
| int crypto::cipher::gcm_t::encrypt |
( |
const std::string_view & | plaintext, |
|
|
std::uint8_t * | tagged_cipher, |
|
|
aes_t * | iv ) |
Encrypts the plaintext using AES GCM mode. length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size.
- Parameters
-
| plaintext | The plaintext data to be encrypted. |
| tagged_cipher | The buffer where the resulting ciphertext and GCM tag will be written. |
| iv | The initialization vector to be used for the encryption. |
- Returns
- The total length of the ciphertext and GCM tag written into tagged_cipher. Returns -1 in case of an error.
◆ operator=()
| gcm_t & crypto::cipher::gcm_t::operator= |
( |
gcm_t && | | ) |
|
|
defaultnoexcept |
Assign state from another instance while preserving ownership semantics.
- Returns
- Reference or value produced by the operator.
The documentation for this class was generated from the following files: