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 是一个无依赖的 AES 实现,使 PDFium Delphi Component 可以在 Delphi、C++Builder 和 Free Pascal 上加解密 PDF 流,而无需依赖外部加密库。它被 FPdfEncrypt 中的 PDF AES-256 安全处理器以及 FPdfAesGcm 中的 GCM 模式所使用
分组原语通过扩展的轮密钥对固定 16 字节的分组进行运算。CBC 包装器在可变长度的字节数组上处理 PKCS#7 填充或无填充,对应 PDF 规范要求的两种流加密模式
AesGenerateRandomBytes 用加密随机的字节填充缓冲区,用于 IV、盐值和密钥
| Function | Description |
|---|---|
Aes128KeyExpansion | 将 128 位密钥扩展为 176 字节的轮密钥调度 |
Aes128EncryptBlock | 用扩展的 AES-128 密钥加密一个 16 字节的分组 |
Aes256KeyExpansion | 将 256 位密钥扩展为 240 字节的轮密钥调度 |
Aes256EncryptBlock | 用扩展的 AES-256 密钥加密一个 16 字节的分组 |
Aes256DecryptBlock | 用扩展的 AES-256 密钥解密一个 16 字节的分组 |
Aes256CbcEncryptPKCS7 | 在 CBC 模式下使用 PKCS#7 填充加密字节数组 |
Aes256CbcEncryptNoPad | 在 CBC 模式下不加填充地加密字节数组(输入长度必须是分组的整数倍) |
Aes256CbcDecryptPKCS7 | 解密 CBC 密文并去除 PKCS#7 填充 |
Aes256CbcDecryptNoPad | 解密 CBC 密文但不去除填充 |
Aes256KeyWrap | 使用 RFC 3394 完整性保护对密钥数据执行 AES-256 包装 |
Aes256KeyUnwrap | 验证并解包 RFC 3394 密钥数据,完整性校验失败时不返回任何明文 |
AesGenerateRandomBytes | 用加密随机的字节填充缓冲区 |
| 类型 | 说明 |
|---|---|
TAesBlock | 一个 16 字节的 AES 数据分组,既是单分组原语和 CBC 链接步骤的操作单元,也是 CBC 包装函数的 IV 类型 |
TAes128Key | 16 字节的 AES-128 密钥,供 Aes128KeyExpansion 接受 |
TAes128ExpandedKey | 176 字节的 AES-128 轮密钥调度,由 Aes128KeyExpansion 生成,供 Aes128EncryptBlock 消费 |
TAes256Key | 32 字节的 AES-256 密钥,供 Aes256KeyExpansion、CBC 包装函数和 RFC 3394 密钥包装函数接受 |
TAes256ExpandedKey | 240 字节的 AES-256 轮密钥调度,覆盖全部 14 轮,由 Aes256KeyExpansion 生成,供分组加解密例程和 CBC 例程消费 |
| Constant | Value | Description |
|---|---|---|
AES_BLOCK_SIZE | 16 | AES 分组大小(字节) |
AES128_KEY_SIZE | 16 | AES-128 密钥大小(字节) |
AES128_ROUND_KEY_SIZE | 176 | 扩展后的 AES-128 轮密钥大小(字节) |
AES256_KEY_SIZE | 32 | AES-256 密钥大小(字节) |
AES256_ROUND_KEY_SIZE | 240 | 扩展后的 AES-256 轮密钥大小(字节) |