|
Determines PDF file encryption method.
type
THPDFKeyType = ( k40, k128, aes128, aes256, aesgcm );
Delphi syntax:
property CryptKeyLength: THPDFKeyType;
C++ syntax:
__property THPDFKeyType CryptKeyLength;
説明
ActivateProtection が有効なときに使用する standard security handler の revision と cipher を選択するには CryptKeyLength を使用します
AES パスワード暗号化では、BeginDoc の前に EncryptMetadata を false に設定すると /EncryptMetadata false が書き込まれ、XMP の /Metadata ストリームがクリアテキストのままになり、対応する AES-128 の鍵導出または AES-256 の /Perms メタデータフラグが使われます。互換性のため、デフォルトは true です
Value Meaning
k40 Standard security handler V=1, R=2, RC4 with a 40-bit key (PDF 1.1+).
k128 Standard security handler V=2, R=3, RC4 with a 128-bit key (PDF 1.4+).
aes128 Standard security handler V=4, R=4 with crypt filter StdCF (CFM=AESV2). AES-128 in CBC mode with PKCS#7 padding and a 16-byte random initialization vector per ISO 32000-1 7.6.2 / 7.4.4.2 (PDF 1.6+). Since HotPDF v2.4.0 this option encrypts strings and streams with a real AES implementation; earlier builds emitted the AES dictionary but did not actually encrypt content.
aes256 標準セキュリティハンドラ V=5、暗号フィルタ StdCF(CFM=AESV3)。Adobe Extension Level 3 / ISO 32000-2 7.6.4 に従う、PKCS#7 パディング付きの AES-256 CBC モードと 16 バイトのランダム初期化ベクトル(PDF 1.7+。Acrobat 9 以降、Foxit、Chrome、Apple/macOS の各ビューアが受け付けます)。HotPDF v2.17.0 以降で利用可能。それより低い出力バージョンで aes256 を選ぶと、StrictVersionLock が設定されていない限り出力は PDF 1.7 に引き上げられます。設定されている場合は、低いバージョンのままで AES-128 にフォールバックします(v2.760.0 より前は、デフォルトの PDF 1.6 出力が黙って AES-128 にフォールバックしていました)。デフォルトのリビジョンは SHA-256 パスワードハッシュの R=5 です。UseAES256R6 を true にすると、ISO 32000-2 のアルゴリズム 2.B の "hash dance"(SHA-256 / SHA-384 / SHA-512 + AES-128 ミキサー)を使う R=6 に切り替わります。R=6 は Acrobat DC と PDF/A-4 バリデーターが要求します。HotPDF v2.22.0 以降で利用可能
aesgcm 標準セキュリティハンドラ V=6、R=7、暗号フィルタ StdCF(CFM=AESV4)。AES-256-GCM は、ISO/TS 32003:2023 の定義どおり、空の追加認証データ付きで、暗号化する文字列とストリームごとに一意な 12 バイト初期化ベクトルと 16 バイト認証タグを使います。このオプションは PDF 2.0 が必要で、拡張レベル 32003 の ISO デベロッパー拡張を出力します。HotPDF v2.475.0 以降で利用可能
Public-Key Security Handler (PDF 1.7 7.6.5)
証明書ベースの暗号化(1 つのドキュメント、複数の受信者)では、UserPassword / OwnerPassword を設定する代わりに EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) を呼び出します。公開鍵暗号化は k40、k128、aes128、aes256 に対応します(aes256 は出力を PDF 2.0 に引き上げます。証明書または鍵合意の受信者では aes256 が必須です)。aesgcm はパスワードベースの標準セキュリティハンドラに限られます。呼び出し元は受信者ごとに PKCS#7 envelopedData blob を 1 つ作成し(Windows CryptoAPI、OpenSSL、pycryptodome)、各 blob を AddPubKeyRecipient で追加する必要があります。file encryption key は ISO 32000-1 7.6.4.3 の記述どおりに導出されます(seed と envelope binaries の連結に対する SHA-1)。HotPDF v2.33.0 以降で利用できます
Code Example
HPDF.OwnerPassword := 'password'; // Set owner password (required to change security settings)
HPDF.UserPassword := 'user'; // Set user password (required to open the document)
HPDF.ProtectOptions := [prPrint, prInformationCopy]; // Allow printing and copying only
HPDF.ActivateProtection := true; // Enable PDF security
関連項目: ActivateProtection, OwnerPassword, ProtectOptions, UserPassword
|