security

package
v0.0.0-...-a2e00f7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventDocOpen is an event triggered when opening the document.
	EventDocOpen = AuthEvent("DocOpen")
	// EventEFOpen is an event triggered when accessing an embedded file.
	EventEFOpen = AuthEvent("EFOpen")
)
View Source
const (
	// PermOwner grants all permissions.
	PermOwner = Permissions(math.MaxUint32)

	// PermPrinting allows printing the document with a low quality.
	PermPrinting = Permissions(1 << 2)
	// PermModify allows to modify the document.
	PermModify = Permissions(1 << 3)
	// PermExtractGraphics allows to extract graphics from the document.
	PermExtractGraphics = Permissions(1 << 4)
	// PermAnnotate allows annotating the document.
	PermAnnotate = Permissions(1 << 5)
	// PermFillForms allow form filling, if annotation is disabled?  If annotation enabled, is not looked at.
	PermFillForms = Permissions(1 << 8)
	// PermDisabilityExtract allows to extract graphics in accessibility mode.
	PermDisabilityExtract = Permissions(1 << 9)
	// PermRotateInsert allows rotating, editing page order.
	PermRotateInsert = Permissions(1 << 10)
	// PermFullPrintQuality limits print quality (lowres), assuming Printing bit is set.
	PermFullPrintQuality = Permissions(1 << 11)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthEvent

type AuthEvent string

AuthEvent is an event type that triggers authentication.

type Permissions

type Permissions uint32

Permissions is a bitmask of access permissions for a PDF file.

func (Permissions) Allowed

func (p Permissions) Allowed(p2 Permissions) bool

Allowed checks if a set of permissions can be granted.

type StdEncryptDict

type StdEncryptDict struct {
	R int // (Required) A number specifying which revision of the standard security handler shall be used.

	P               Permissions
	EncryptMetadata bool // Indicates whether the document-level metadata stream shall be encrypted.

	O, U   []byte
	OE, UE []byte // R=6
	Perms  []byte // An encrypted copy of P (16 bytes). Used to verify permissions. R=6
}

StdEncryptDict is a set of additional fields used in standard encryption dictionary.

type StdHandler

type StdHandler interface {
	// GenerateParams uses owner and user passwords to set encryption parameters and generate an encryption key.
	// It assumes that R, P and EncryptMetadata are already set.
	GenerateParams(d *StdEncryptDict, ownerPass, userPass []byte) ([]byte, error)

	// Authenticate uses encryption dictionary parameters and the password to calculate
	// the document encryption key. It also returns permissions that should be granted to a user.
	// In case of failed authentication, it returns empty key and zero permissions with no error.
	Authenticate(d *StdEncryptDict, pass []byte) ([]byte, Permissions, error)
}

StdHandler is an interface for standard security handlers.

func NewHandlerR4

func NewHandlerR4(id0 string, length int) StdHandler

NewHandlerR4 creates a new standard security handler for R<=4.

func NewHandlerR6

func NewHandlerR6() StdHandler

NewHandlerR6 creates a new standard security handler for R=5 and R=6.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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