49 const uint8_t* iv,
size_t ivLen,
50 const uint8_t* aad,
size_t aadLen,
51 const uint8_t* pt,
size_t ptLen,
52 uint8_t* ctOut, uint8_t tagOut[16]) {
54 int rc = mbedtls_gcm_setkey(gcm.
get(), MBEDTLS_CIPHER_ID_AES, key, 256);
56 rc = mbedtls_gcm_crypt_and_tag(
57 gcm.
get(), MBEDTLS_GCM_ENCRYPT, ptLen,
80 const uint8_t* iv,
size_t ivLen,
81 const uint8_t* aad,
size_t aadLen,
82 const uint8_t* ct,
size_t ctLen,
83 const uint8_t tag[16], uint8_t* ptOut) {
85 int rc = mbedtls_gcm_setkey(gcm.
get(), MBEDTLS_CIPHER_ID_AES, key, 256);
87 rc = mbedtls_gcm_auth_decrypt(
RAII wrapper around mbedtls_gcm_context. Non-copyable, non-movable.
GcmContext & operator=(const GcmContext &)=delete
GcmContext(const GcmContext &)=delete
mbedtls_gcm_context * get()
Returns the underlying mbedTLS context.
GcmContext(GcmContext &&)=delete
GcmContext & operator=(GcmContext &&)=delete
bool aesGcm256Seal(const uint8_t key[32], const uint8_t *iv, size_t ivLen, const uint8_t *aad, size_t aadLen, const uint8_t *pt, size_t ptLen, uint8_t *ctOut, uint8_t tagOut[16])
Encrypts pt with AES-256-GCM and produces a 16-byte tag.
bool aesGcm256Open(const uint8_t key[32], const uint8_t *iv, size_t ivLen, const uint8_t *aad, size_t aadLen, const uint8_t *ct, size_t ctLen, const uint8_t tag[16], uint8_t *ptOut)
Authenticates and decrypts ct with AES-256-GCM.