crypt

package
v0.0.0-...-90a1d6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2020 License: AGPL-3.0, AGPL-3.0-only Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	// Name returns a name of the filter that should be used in CFM field of Encrypt dictionary.
	Name() string
	// KeyLength returns a length of the encryption key in bytes.
	KeyLength() int
	// PDFVersion reports the minimal version of PDF document that introduced this filter.
	PDFVersion() [2]int
	// HandlerVersion reports V and R parameters that should be used for this filter.
	HandlerVersion() (V, R int)
	// MakeKey generates a object encryption key based on file encryption key and object numbers.
	// Used only for legacy filters - AESV3 doesn't change the key for each object.
	MakeKey(objNum, genNum uint32, fkey []byte) ([]byte, error)
	// EncryptBytes encrypts a buffer using object encryption key, as returned by MakeKey.
	// Implementation may reuse a buffer and encrypt data in-place.
	EncryptBytes(p []byte, okey []byte) ([]byte, error)
	// DecryptBytes decrypts a buffer using object encryption key, as returned by MakeKey.
	// Implementation may reuse a buffer and decrypt data in-place.
	DecryptBytes(p []byte, okey []byte) ([]byte, error)
}

Filter is a common interface for crypt filter methods.

func NewFilter

func NewFilter(d FilterDict) (Filter, error)

NewFilter creates CryptFilter from a corresponding dictionary.

func NewFilterAESV2

func NewFilterAESV2() Filter

NewFilterAESV2 creates an AES-based filter with a 128 bit key (AESV2).

func NewFilterAESV3

func NewFilterAESV3() Filter

NewFilterAESV3 creates an AES-based filter with a 256 bit key (AESV3).

func NewFilterV2

func NewFilterV2(length int) Filter

NewFilterV2 creates a RC4-based filter with a specified key length (in bytes).

func NewIdentity

func NewIdentity() Filter

NewIdentity creates an identity filter that bypasses all data without changes.

type FilterDict

type FilterDict struct {
	CFM       string // The method used, if any, by the PDF reader to decrypt data.
	AuthEvent security.AuthEvent
	Length    int // in bytes
}

FilterDict represents information from a CryptFilter dictionary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL