finish support for revision 5 encryption using aes 256 #34

This commit is contained in:
Eliot Jones
2019-06-13 19:46:08 +01:00
parent d0a3cd398f
commit 4c716fcbd6
6 changed files with 52 additions and 35 deletions

View File

@@ -55,7 +55,8 @@
useAes = false;
if (encryptionDictionary.EncryptionAlgorithmCode == EncryptionAlgorithmCode.SecurityHandlerInDocument)
if (encryptionDictionary.EncryptionAlgorithmCode == EncryptionAlgorithmCode.SecurityHandlerInDocument
|| encryptionDictionary.EncryptionAlgorithmCode == EncryptionAlgorithmCode.SecurityHandlerInDocument256)
{
if (!encryptionDictionary.TryGetCryptHandler(out var cryptHandlerLocal))
{
@@ -64,7 +65,8 @@
cryptHandler = cryptHandlerLocal;
useAes = cryptHandlerLocal?.StreamDictionary?.Name == CryptDictionary.Method.AesV2;
useAes = cryptHandlerLocal?.StreamDictionary?.Name == CryptDictionary.Method.AesV2
|| cryptHandlerLocal?.StreamDictionary?.Name == CryptDictionary.Method.AesV3;
}
var charset = OtherEncodings.Iso88591;
@@ -407,7 +409,7 @@
{
if (useAes && encryptionKey.Length == 32)
{
throw new PdfDocumentEncryptedException("Decryption for AES-256 not currently supported.", encryptionDictionary);
return AesEncryptionHelper.Decrypt(data, encryptionKey);
}
var finalKey = GetObjectKey(reference);