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 は、外部の暗号ライブラリに依存せずに Delphi、C++Builder、Free Pascal で PDF ストリームの暗号化と復号を行えるよう用意された、依存関係のない AES 実装です。FPdfEncrypt の PDF AES-256 セキュリティハンドラと、FPdfAesGcm の GCM モードで使用されます
ブロックプリミティブは展開されたラウンドキーを用いて固定の 16 バイトブロックを処理します。CBC ラッパーは可変長バイト配列に対して PKCS#7 パディングまたはパディングなしを扱い、PDF 仕様が要求する 2 つのストリーム暗号化モードに対応します
AesGenerateRandomBytes は、IV、ソルト、キーとして使用される暗号論的にランダムなバイトでバッファを埋めます
| 関数 | 説明 |
|---|---|
Aes128KeyExpansion | 128 ビットキーを 176 バイトのラウンドキースケジュールに展開します |
Aes128EncryptBlock | 展開済み AES-128 キーで 1 つの 16 バイトブロックを暗号化します |
Aes256KeyExpansion | 256 ビットキーを 240 バイトのラウンドキースケジュールに展開します |
Aes256EncryptBlock | 展開済み AES-256 キーで 1 つの 16 バイトブロックを暗号化します |
Aes256DecryptBlock | 展開済み AES-256 キーで 1 つの 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 データブロック 1 個分。単一ブロックのプリミティブと CBC のチェーン処理の単位であり、CBC ラッパーの IV 型でもあります |
TAes128Key | Aes128KeyExpansion が受け付ける 16 バイトの AES-128 キー |
TAes128ExpandedKey | Aes128KeyExpansion が生成し Aes128EncryptBlock が受け取る 176 バイトの AES-128 ラウンドキースケジュール |
TAes256Key | Aes256KeyExpansion、CBC ラッパー、RFC 3394 の key-wrap 関数が受け付ける 32 バイトの AES-256 キー |
TAes256ExpandedKey | 14 ラウンド全体をカバーする 240 バイトの AES-256 ラウンドキースケジュール。Aes256KeyExpansion が生成し、ブロック暗号化 / 復号および CBC ルーチンが受け取ります |
| 定数 | 値 | 説明 |
|---|---|---|
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 ラウンドキーのサイズ (バイト単位) |