Documentation
¶
Overview ¶
Package crypt implements the PDF standard security handler (ISO 32000-1 §7.6.3 and ISO 32000-2 §7.6.4): RC4 and AES stream/string decryption with the file key derived from a supplied user or owner password.
The package is value-agnostic: callers extract the /Encrypt dictionary and the /ID into a Config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPasswordRequired = errors.New("pdf: encrypted document requires a password")
ErrPasswordRequired means the supplied password matched neither the user nor the owner password.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Filter string // /Filter, must be "Standard"
V, R int // /V algorithm, /R revision
Length int // /Length in bits (default 40)
O, U []byte // /O, /U password strings
OE, UE []byte // /OE, /UE (R6)
P int32 // /P permissions
EncryptMeta bool // /EncryptMetadata (default true)
StmF, StrF string // /StmF, /StrF crypt filter names (V≥4)
CF map[string]Filter
ID []byte // first element of the trailer /ID array
}
Config carries the /Encrypt dictionary fields the handler needs, already extracted from PDF objects by the caller.
type Decryptor ¶
type Decryptor struct {
// contains filtered or unexported fields
}
A Decryptor holds the derived file key and per-string/stream methods.
func NewWithPassword ¶ added in v0.3.0
NewWithPassword authenticates password as either the user or owner password and derives the file key.
func (*Decryptor) DecryptStream ¶
DecryptStream wraps r so the stream body decrypts as it is read.
func (*Decryptor) DecryptStreamData ¶
DecryptStreamData decrypts a fully-read stream body.