Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
crypto::cipher::cbc_t Class Reference
Inheritance diagram for crypto::cipher::cbc_t:
[legend]
Collaboration diagram for crypto::cipher::cbc_t:
[legend]

Public Member Functions

 cbc_t (cbc_t &&) noexcept=default
cbc_t & operator= (cbc_t &&) noexcept=default
 cbc_t (const crypto::aes_t &key, bool padding=true)
int encrypt (const std::string_view &plaintext, std::uint8_t *cipher, aes_t *iv)
 Encrypts the plaintext using AES CBC mode. length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()).
int decrypt (const std::string_view &cipher, std::vector< std::uint8_t > &plaintext, aes_t *iv)
 Decrypts the ciphertext using AES CBC mode.

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

Detailed Description

Definition at line 212 of file crypto.h.

Constructor & Destructor Documentation

◆ cbc_t()

crypto::cipher::cbc_t::cbc_t ( const crypto::aes_t & key,
bool padding = true )

Definition at line 338 of file crypto.cpp.

Member Function Documentation

◆ decrypt()

int crypto::cipher::cbc_t::decrypt ( const std::string_view & cipher,
std::vector< std::uint8_t > & plaintext,
aes_t * iv )

Decrypts the ciphertext using AES CBC mode.

Returns
0 on success, -1 on error.

Definition at line 304 of file crypto.cpp.

◆ encrypt()

int crypto::cipher::cbc_t::encrypt ( const std::string_view & plaintext,
std::uint8_t * cipher,
aes_t * iv )

Encrypts the plaintext using AES CBC mode. length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()).

Parameters
plaintextThe plaintext data to be encrypted.
cipherThe buffer where the resulting ciphertext will be written.
ivThe initialization vector to be used for the encryption.
Returns
The total length of the ciphertext written into cipher. Returns -1 in case of an error.

This function encrypts the given plaintext using the AES key in CBC 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 is written into the cipher buffer.

Definition at line 279 of file crypto.cpp.


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