module
JOSE::JWA::AES_GCM
Overview
AES-GCM authenticated encryption (128 / 192 / 256-bit keys). Uses raw LibCrypto/LibCryptoJose bindings because Crystal's OpenSSL::Cipher does not expose auth_data= or auth_tag for GCM mode.
Defined in:
jose/jwa/aes_gcm.crClass Method Summary
-
.decrypt(key : Bytes, iv : Bytes, ciphertext : Bytes, tag : Bytes, aad : Bytes) : Bytes
Decrypts ciphertext with key, iv, and aad, verifying tag.
-
.encrypt(key : Bytes, iv : Bytes, plaintext : Bytes, aad : Bytes) : Tuple(Bytes, Bytes)
Encrypts plaintext with key and iv, authenticating aad.
Class Method Detail
def self.decrypt(key : Bytes, iv : Bytes, ciphertext : Bytes, tag : Bytes, aad : Bytes) : Bytes
#
Decrypts ciphertext with key, iv, and aad, verifying tag. Raises if authentication fails.
def self.encrypt(key : Bytes, iv : Bytes, plaintext : Bytes, aad : Bytes) : Tuple(Bytes, Bytes)
#
Encrypts plaintext with key and iv, authenticating aad.
key must be 16, 24, or 32 bytes (selects AES-128/192/256-GCM). iv should be 12 bytes (96 bits) for GCM. aad is the additional authenticated data (e.g. the base64url-encoded protected header in JWE).
Returns {ciphertext, tag} where tag is a 16-byte authentication tag.