Sunshine latest
Self-hosted game stream host for Moonlight.
crypto::cipher::gcm_t Class Reference
Inheritance diagram for crypto::cipher::gcm_t:
[legend]
Collaboration diagram for crypto::cipher::gcm_t:
[legend]

Public Member Functions

int decrypt (const std::string_view &cipher, std::vector< std::uint8_t > &plaintext, aes_t *iv)
 
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, bool padding=true)
 
 gcm_t (gcm_t &&) noexcept=default
 
gcm_toperator= (gcm_t &&) noexcept=default
 

Additional Inherited Members

- Public Attributes inherited from crypto::cipher::cipher_t
cipher_ctx_t decrypt_ctx
 
cipher_ctx_t encrypt_ctx
 
aes_t key
 
bool padding
 

Member Function Documentation

◆ 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
plaintextThe plaintext data to be encrypted.
tagThe buffer where the GCM tag will be written.
ciphertextThe buffer where the resulting ciphertext will be written.
ivThe 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
plaintextThe plaintext data to be encrypted.
tagged_cipherThe buffer where the resulting ciphertext and GCM tag will be written.
ivThe 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.

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