TAesBlock = array[0..15] of Byte;
TAes128Key = array[0..15] of Byte;
TAes128ExpandedKey = array[0..175] of Byte;
TAes256Key = array[0..31] of Byte;
TAes256ExpandedKey = array[0..239] of Byte;
procedure Aes128KeyExpansion(const Key: TAes128Key; var Expanded: TAes128ExpandedKey);
procedure Aes128EncryptBlock(const Expanded: TAes128ExpandedKey;
const Input: TAesBlock; var Output: TAesBlock);
procedure Aes256KeyExpansion(const Key: TAes256Key; var Expanded: TAes256ExpandedKey);
procedure Aes256EncryptBlock(const Expanded: TAes256ExpandedKey;
const Input: TAesBlock; var Output: TAesBlock);
procedure Aes256DecryptBlock(const Expanded: TAes256ExpandedKey;
const Input: TAesBlock; var Output: TAesBlock);
function Aes256CbcEncryptPKCS7(const Key: TAes256Key; const IV: TAesBlock;
const Plain: TBytes): TBytes;
function Aes256CbcEncryptNoPad(const Key: TAes256Key; const IV: TAesBlock;
const Plain: TBytes): TBytes;
function Aes256CbcDecryptPKCS7(const Key: TAes256Key; const IV: TAesBlock;
const Cipher: TBytes): TBytes;
function Aes256CbcDecryptNoPad(const Key: TAes256Key; const IV: TAesBlock;
const Cipher: TBytes): TBytes;
function Aes256KeyWrap(const KeyEncryptionKey: TAes256Key;
const PlainKeyData: TBytes): TBytes;
function Aes256KeyUnwrap(const KeyEncryptionKey: TAes256Key; const WrappedKeyData: TBytes;
out PlainKeyData: TBytes): Boolean;
procedure AesGenerateRandomBytes(Buffer: Pointer; Count: Integer);
FPdfAes is a dependency-free AES implementation provided so PDFium Delphi Component can encrypt and decrypt PDF streams on Delphi, C++Builder, and Free Pascal without relying on an external crypto library. It is consumed by the PDF AES-256 security handler in FPdfEncrypt and by the GCM mode in FPdfAesGcm
The block primitives operate on fixed 16-byte blocks via expanded round keys. The CBC wrappers handle PKCS#7 padding or no padding over variable-length byte arrays, matching the two stream-encryption modes the PDF specification requires
AesGenerateRandomBytes fills a buffer with cryptographically random bytes used for IVs, salts, and keys
| Function | Description |
|---|---|
Aes128KeyExpansion | Expands a 128-bit key into the 176-byte round-key schedule |
Aes128EncryptBlock | Encrypts one 16-byte block with an expanded AES-128 key |
Aes256KeyExpansion | Expands a 256-bit key into the 240-byte round-key schedule |
Aes256EncryptBlock | Encrypts one 16-byte block with an expanded AES-256 key |
Aes256DecryptBlock | Decrypts one 16-byte block with an expanded AES-256 key |
Aes256CbcEncryptPKCS7 | Encrypts a byte array in CBC mode with PKCS#7 padding |
Aes256CbcEncryptNoPad | Encrypts a byte array in CBC mode without padding (input length must be a block multiple) |
Aes256CbcDecryptPKCS7 | Decrypts a CBC ciphertext and strips PKCS#7 padding |
Aes256CbcDecryptNoPad | Decrypts a CBC ciphertext without removing padding |
Aes256KeyWrap | Wraps key data with AES-256 using RFC 3394 integrity protection |
Aes256KeyUnwrap | Authenticates and unwraps RFC 3394 key data, returning no plaintext on integrity failure |
AesGenerateRandomBytes | Fills a buffer with cryptographically random bytes |
| Type | Description |
|---|---|
TAesBlock | One 16-byte AES data block, the unit of the single-block primitives and the CBC chaining step, and also the IV type of the CBC wrappers |
TAes128Key | 16-byte AES-128 key accepted by Aes128KeyExpansion |
TAes128ExpandedKey | 176-byte AES-128 round-key schedule produced by Aes128KeyExpansion and consumed by Aes128EncryptBlock |
TAes256Key | 32-byte AES-256 key accepted by Aes256KeyExpansion, the CBC wrappers, and the RFC 3394 key-wrap functions |
TAes256ExpandedKey | 240-byte AES-256 round-key schedule covering all 14 rounds, produced by Aes256KeyExpansion and consumed by the block encrypt/decrypt and CBC routines |
| Constant | Value | Description |
|---|---|---|
AES_BLOCK_SIZE | 16 | AES block size in bytes |
AES128_KEY_SIZE | 16 | AES-128 key size in bytes |
AES128_ROUND_KEY_SIZE | 176 | Expanded AES-128 round-key size in bytes |
AES256_KEY_SIZE | 32 | AES-256 key size in bytes |
AES256_ROUND_KEY_SIZE | 240 | Expanded AES-256 round-key size in bytes |