![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
AES-256 in Galois/Counter Mode (GCM) as specified in NIST SP 800-38D. More...
#include <aes_gcm.hpp>
Public Member Functions | |
| AesGcm (const uint8_t key[KEY_SIZE]) | |
| Initialize with a 32-byte key. | |
| void | set_iv_size (size_t size) |
| Set the expected IV size. | |
| size_t | iv_size () const |
| Get the current IV size (12 or 16 bytes). | |
| expected< std::vector< uint8_t > > | encrypt (const uint8_t *plaintext, size_t plaintext_size, const uint8_t iv[IV_SIZE], const uint8_t *aad=nullptr, size_t aad_size=0) const |
| Authenticated encryption with additional data (AEAD). | |
| expected< std::vector< uint8_t > > | decrypt (const uint8_t *ciphertext_with_tag, size_t total_size, const uint8_t iv[IV_SIZE], const uint8_t *aad=nullptr, size_t aad_size=0) const |
| Authenticated decryption and verification (NIST SP 800-38D Section 7.2). | |
Static Public Attributes | |
| static constexpr size_t | KEY_SIZE = 32 |
| AES-256 key size in bytes. | |
| static constexpr size_t | IV_SIZE = 12 |
| Standard GCM nonce size in bytes (96 bits). | |
| static constexpr size_t | TAG_SIZE = 16 |
| Authentication tag size in bytes (128 bits). | |
| static constexpr uint64_t | MAX_GCM_PLAINTEXT |
| Maximum plaintext size for a single GCM invocation (NIST SP 800-38D §5.2.1.1). | |
| static constexpr uint64_t | MAX_AAD_BYTES = (UINT64_MAX / 8) |
| NIST SP 800-38D §5.2.1.1: AAD length limit is 2^64-1 bits. | |
AES-256 in Galois/Counter Mode (GCM) as specified in NIST SP 800-38D.
Provides both confidentiality (encryption) and authenticity (128-bit authentication tag). This is the mode used for Parquet footer encryption where tamper detection is critical.
Definition at line 406 of file aes_gcm.hpp.
|
inlineexplicit |
Initialize with a 32-byte key.
Computes the hash subkey H = AES_K(0^128) and precomputes the 4-bit GHASH multiplication table for constant-time operation (NIST SP 800-38D §6.3, CWE-208).
Definition at line 415 of file aes_gcm.hpp.
|
inline |
Authenticated decryption and verification (NIST SP 800-38D Section 7.2).
| ciphertext_with_tag | Pointer to ciphertext + 16-byte appended tag. |
| total_size | Total input size (ciphertext + TAG_SIZE); must be >= TAG_SIZE. |
| iv | 12-byte nonce (same as used for encryption). |
| aad | Additional authenticated data (same as encryption). |
| aad_size | Length of AAD in bytes. |
Definition at line 592 of file aes_gcm.hpp.
|
inline |
Authenticated encryption with additional data (AEAD).
| plaintext | Pointer to data to encrypt. |
| plaintext_size | Number of bytes to encrypt. |
| iv | 12-byte nonce (MUST be unique per message under the same key). |
| aad | Additional authenticated data (authenticated but not encrypted; may be nullptr if aad_size == 0). |
| aad_size | Length of AAD in bytes. |
Definition at line 487 of file aes_gcm.hpp.
|
inline |
Get the current IV size (12 or 16 bytes).
Definition at line 457 of file aes_gcm.hpp.
|
inline |
Set the expected IV size.
Default is 12 bytes (96 bits, standard). Optionally supports 16 bytes; 16-byte IVs use GHASH-based J0 derivation per NIST SP 800-38D §5.2.1.2.
| size | Must be 12 or 16. |
| std::invalid_argument | if size is neither 12 nor 16. |
Definition at line 449 of file aes_gcm.hpp.
|
staticconstexpr |
Standard GCM nonce size in bytes (96 bits).
Definition at line 409 of file aes_gcm.hpp.
|
staticconstexpr |
AES-256 key size in bytes.
Definition at line 408 of file aes_gcm.hpp.
|
staticconstexpr |
NIST SP 800-38D §5.2.1.1: AAD length limit is 2^64-1 bits.
Practical limit: 2^61-1 bytes (to avoid overflow when converting to bits).
Definition at line 467 of file aes_gcm.hpp.
|
staticconstexpr |
Maximum plaintext size for a single GCM invocation (NIST SP 800-38D §5.2.1.1).
32-bit counter can address at most (2^32 - 2) blocks of 16 bytes each (counter value 1 is reserved for J0).
Definition at line 462 of file aes_gcm.hpp.
|
staticconstexpr |
Authentication tag size in bytes (128 bits).
Definition at line 410 of file aes_gcm.hpp.