Documentation
¶
Overview ¶
Package crypt implements the PDF /Standard security handler for versions V2 (RC4), V4 (RC4 or AES-128) and V5 (AES-256, PDF 1.7 Extension 3 and PDF 2.0).
Only password-based access (the user password "empty string" path included) is supported. Public-key encryption (/Adobe.PubSec) is out of scope.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
V int // /V version
R int // /R revision
Length int // key length in bits (V2/V4)
FileKey []byte // file encryption key (computed from password)
StringAlg Algorithm // algorithm for strings
StreamAlg Algorithm // algorithm for streams
EmbedAlg Algorithm // algorithm for embedded files
CryptFilts map[string]filterDef
StmF string // default stream filter (V4)
StrF string // default string filter (V4)
EFF string // embedded-file filter (V4)
}
Handler holds the state needed to decrypt strings and streams in a PDF once a password has been validated.
func New ¶
New tries to instantiate a Handler given the encryption parameters and the user password (empty string is the most common case).
func (*Handler) DecryptStream ¶
func (h *Handler) DecryptStream(data []byte, objNum, objGen int, cryptFilterName string) ([]byte, error)
DecryptStream decrypts a stream. cryptFilterName, if non-empty, overrides the default stream algorithm (V4 streams can carry an inline /Filter chain containing /Crypt with parameters).
type Params ¶
type Params struct {
V int
R int
Length int
P int32
OwnerEntry []byte // /O
UserEntry []byte // /U
OE []byte // /OE (V5)
UE []byte // /UE (V5)
Perms []byte // /Perms (V5)
ID0 []byte // first element of /ID
EncryptMeta bool
StmF string
StrF string
EFF string
CryptFilters map[string]string // name → CFM
}
Params is the inputs needed to instantiate a Handler from the PDF /Encrypt dict.