diff --git a/pdf/core/security/crypt/filter_aesv2.go b/pdf/core/security/crypt/filter_aesv2.go index 301c202a..06cb566a 100644 --- a/pdf/core/security/crypt/filter_aesv2.go +++ b/pdf/core/security/crypt/filter_aesv2.go @@ -5,7 +5,11 @@ package crypt -import "fmt" +import ( + "fmt" + + "github.com/unidoc/unidoc/common" +) func init() { registerFilter("AESV2", newFilterAESV2) @@ -21,6 +25,10 @@ func NewFilterAESV2() Filter { } func newFilterAESV2(d FilterDict) (Filter, error) { + if d.Length == 128 { + common.Log.Debug("AESV2 crypt filter length appears to be in bits rather than bytes - assuming bits (%d)", d.Length) + d.Length /= 8 + } if d.Length != 0 && d.Length != 16 { return nil, fmt.Errorf("invalid AESV2 crypt filter length (%d)", d.Length) } diff --git a/pdf/core/security/crypt/filter_aesv3.go b/pdf/core/security/crypt/filter_aesv3.go index ee399596..e35e0e28 100644 --- a/pdf/core/security/crypt/filter_aesv3.go +++ b/pdf/core/security/crypt/filter_aesv3.go @@ -29,6 +29,10 @@ func NewFilterAESV3() Filter { } func newFilterAESV3(d FilterDict) (Filter, error) { + if d.Length == 256 { + common.Log.Debug("AESV3 crypt filter length appears to be in bits rather than bytes - assuming bits (%d)", d.Length) + d.Length /= 8 + } if d.Length != 0 && d.Length != 32 { return nil, fmt.Errorf("invalid AESV3 crypt filter length (%d)", d.Length) }