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、salt 與金鑰
| 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 | 以 AES-256 與 RFC 3394 完整性保護包裝金鑰資料 |
Aes256KeyUnwrap | 驗證並解開 RFC 3394 金鑰資料,完整性失敗時不傳回明文 |
AesGenerateRandomBytes | 以密碼學隨機位元組填滿緩衝區 |
| Type | Description |
|---|---|
TAesBlock | 一個 16 位元組的 AES 資料區塊,是單區塊基本操作與 CBC 鏈接步驟的處理單位,同時也是 CBC 包裝函式的 IV 型別 |
TAes128Key | Aes128KeyExpansion 接受的 16 位元組 AES-128 金鑰 |
TAes128ExpandedKey | 由 Aes128KeyExpansion 產生、並交給 Aes128EncryptBlock 使用的 176 位元組 AES-128 回合金鑰排程 |
TAes256Key | Aes256KeyExpansion、CBC 包裝函式與 RFC 3394 金鑰包裝函式接受的 32 位元組 AES-256 金鑰 |
TAes256ExpandedKey | 涵蓋全部 14 個回合的 240 位元組 AES-256 回合金鑰排程,由 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 回合金鑰大小(位元組) |