PDFium Delphi Component Docs

FPdfAesGcm unit

Unit: FPdfAesGcm
Pure-Pascal AES-GCM authenticated encryption for AES-128 and AES-256 keys, providing ciphertext plus a 16-byte authentication tag

Syntax

TAesGcmTag = array[0..15] of Byte;
TGHashBlock = TAesBlock;

procedure Aes256GcmEncrypt(const Key: TAes256Key; const IV, Plain, AAD: TBytes;
  out Cipher: TBytes; out Tag: TAesGcmTag);
function Aes256GcmDecrypt(const Key: TAes256Key; const IV, Cipher, AAD: TBytes;
  const Tag: TAesGcmTag; out Plain: TBytes): Boolean;
procedure Aes128GcmEncrypt(const Key: TAes128Key; const IV, Plain, AAD: TBytes;
  out Cipher: TBytes; out Tag: TAesGcmTag);
function Aes128GcmDecrypt(const Key: TAes128Key; const IV, Cipher, AAD: TBytes;
  const Tag: TAesGcmTag; out Plain: TBytes): Boolean;

Description

FPdfAesGcm implements AES in Galois/Counter Mode over the block primitives in FPdfAes. It produces ciphertext and a 16-byte authentication tag, and accepts additional authenticated data (AAD) that is covered by the tag but not encrypted

The decrypt functions return False when the tag does not verify, so callers can reject tampered ciphertext without raising. This mode is used by structures that require authenticated encryption beyond the PDF AES-256-CBC security handler

Functions

FunctionDescription
Aes256GcmEncryptEncrypts Plain with a 256-bit key, IV and AAD, returning ciphertext and a 16-byte tag
Aes256GcmDecryptDecrypts Cipher with a 256-bit key, IV and AAD, verifying the tag; returns False on tag mismatch
Aes128GcmEncryptEncrypts Plain with a 128-bit key, IV and AAD, returning ciphertext and a 16-byte tag
Aes128GcmDecryptDecrypts Cipher with a 128-bit key, IV and AAD, verifying the tag; returns False on tag mismatch

Types

TypeDescription
TAesGcmTag16-byte authentication tag produced and verified by GCM
TGHashBlockAlias for TAesBlock used by the GHASH building block

Remarks

See Also

FPdfAes