mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
Merge pull request #439 from adrg/aes-bit-crypt-filter-length
Account for crypt filter length specified in bits for AESV2 and AESV3
This commit is contained in:
commit
3b2c788c32
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user