Documentation
¶
Index ¶
- func BuildAES256Encryption(userPwd, ownerPwd string, permissions raw.Permissions, fileID []byte, ...) (*raw.DictObj, []byte, error)
- func BuildStandardEncryption(userPwd, ownerPwd string, permissions raw.Permissions, fileID []byte, ...) (*raw.DictObj, []byte, error)
- func PermissionsValue(p raw.Permissions) int32
- type DataClass
- type Handler
- type HandlerBuilder
- type LTVData
- type Limits
- type MockSigner
- type Permissions
- type RSASigner
- type Signer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAES256Encryption ¶
func BuildAES256Encryption(userPwd, ownerPwd string, permissions raw.Permissions, fileID []byte, encryptMetadata bool) (*raw.DictObj, []byte, error)
BuildAES256Encryption constructs an Encrypt dictionary and keys for AES-256 (PDF 2.0) security.
func BuildStandardEncryption ¶
func BuildStandardEncryption(userPwd, ownerPwd string, permissions raw.Permissions, fileID []byte, encryptMetadata bool) (*raw.DictObj, []byte, error)
BuildStandardEncryption constructs an Encrypt dictionary and primary key for the Standard security handler.
func PermissionsValue ¶
func PermissionsValue(p raw.Permissions) int32
PermissionsValue builds the Standard security permissions flags for a document.
Types ¶
type DataClass ¶
type DataClass int
DataClass identifies the kind of payload being encrypted or decrypted.
type Handler ¶
type Handler interface {
IsEncrypted() bool
Authenticate(password string) error
DecryptWithFilter(objNum, gen int, data []byte, class DataClass, cryptFilter string) ([]byte, error)
Decrypt(objNum, gen int, data []byte, class DataClass) ([]byte, error)
EncryptWithFilter(objNum, gen int, data []byte, class DataClass, cryptFilter string) ([]byte, error)
Encrypt(objNum, gen int, data []byte, class DataClass) ([]byte, error)
Permissions() Permissions
EncryptMetadata() bool
}
func NoopHandler ¶
func NoopHandler() Handler
NoopHandler returns a reusable pass-through encryption handler.
type HandlerBuilder ¶
type HandlerBuilder struct {
// contains filtered or unexported fields
}
func (*HandlerBuilder) Build ¶
func (b *HandlerBuilder) Build() (Handler, error)
func (*HandlerBuilder) WithEncryptDict ¶
func (b *HandlerBuilder) WithEncryptDict(d raw.Dictionary) *HandlerBuilder
func (*HandlerBuilder) WithFileID ¶
func (b *HandlerBuilder) WithFileID(id []byte) *HandlerBuilder
func (*HandlerBuilder) WithTrailer ¶
func (b *HandlerBuilder) WithTrailer(d raw.Dictionary) *HandlerBuilder
type LTVData ¶
type LTVData struct {
Certs [][]byte // DER encoded certificates
OCSPs [][]byte // DER encoded OCSP responses
CRLs [][]byte // DER encoded CRLs
}
LTVData contains validation data for Long Term Validation (LTV).
type Limits ¶
type Limits struct {
// Maximum decompressed stream size (prevent zip bombs). Default: 100 MB.
MaxDecompressedSize int64
// Maximum indirect reference depth (prevent stack overflow). Default: 100.
MaxIndirectDepth int
// Maximum XRef chain depth (Prev entries). Default: 50.
MaxXRefDepth int
// Maximum XObject nesting depth. Default: 20.
MaxXObjectDepth int
// Maximum array size (number of elements). Default: 100,000.
MaxArraySize int
// Maximum dictionary size (number of entries). Default: 10,000.
MaxDictSize int
// Maximum string length (bytes). Default: 10 MB.
MaxStringLength int64
// Maximum raw stream length (bytes). Default: 50 MB.
MaxStreamLength int64
// Maximum decode time per stream. Default: 30s.
MaxDecodeTime time.Duration
// Maximum total parse time. Default: 5m.
MaxParseTime time.Duration
}
Limits defines security boundaries for parsing and processing PDFs. These limits help prevent resource exhaustion attacks (e.g., zip bombs, stack overflows).
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns a Limits struct with safe default values.
type MockSigner ¶
type MockSigner struct{}
MockSigner for testing without keys
func (*MockSigner) Certificate ¶
func (m *MockSigner) Certificate() []*x509.Certificate
type Permissions ¶
type Permissions struct{ Print, Modify, Copy, ModifyAnnotations, FillForms, ExtractAccessible, Assemble, PrintHighQuality bool }
type RSASigner ¶
type RSASigner struct {
// contains filtered or unexported fields
}
RSASigner implements Signer using an RSA private key.
func NewRSASigner ¶
func NewRSASigner(priv *rsa.PrivateKey, chain []*x509.Certificate) *RSASigner
NewRSASigner creates a new RSA signer.
func (*RSASigner) Certificate ¶
func (s *RSASigner) Certificate() []*x509.Certificate