sighandler

package
v3.0.0-...-55e877b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: GPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package sighandler implements digital signature handlers for PDF signature validation and signing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdobePKCS7Detached

func NewAdobePKCS7Detached(privateKey *_ag.PrivateKey, certificate *_e.Certificate) (_dd.SignatureHandler, error)

NewAdobePKCS7Detached creates a new Adobe.PPKMS/Adobe.PPKLite adbe.pkcs7.detached signature handler. Both parameters may be nil for the signature validation.

func NewAdobeX509RSASHA1

func NewAdobeX509RSASHA1(privateKey *_ag.PrivateKey, certificate *_e.Certificate) (_dd.SignatureHandler, error)

NewAdobeX509RSASHA1 creates a new Adobe.PPKMS/Adobe.PPKLite adbe.x509.rsa_sha1 signature handler. Both the private key and the certificate can be nil for the signature validation.

func NewAdobeX509RSASHA1Custom

func NewAdobeX509RSASHA1Custom(certificate *_e.Certificate, signFunc SignFunc) (_dd.SignatureHandler, error)

NewAdobeX509RSASHA1Custom creates a new Adobe.PPKMS/Adobe.PPKLite adbe.x509.rsa_sha1 signature handler with a custom signing function. Both the certificate and the sign function can be nil for the signature validation. NOTE: the handler will do a mock Sign when initializing the signature in order to estimate the signature size. Use NewAdobeX509RSASHA1CustomWithOpts for configuring the handler to estimate the signature size.

func NewAdobeX509RSASHA1CustomWithOpts

func NewAdobeX509RSASHA1CustomWithOpts(certificate *_e.Certificate, signFunc SignFunc, opts *AdobeX509RSASHA1Opts) (_dd.SignatureHandler, error)

NewAdobeX509RSASHA1CustomWithOpts creates a new Adobe.PPKMS/Adobe.PPKLite adbe.x509.rsa_sha1 signature handler with a custom signing function. The handler is configured based on the provided options. If no options are provided, default options will be used. Both the certificate and the sign function can be nil for the signature validation.

func NewDocMDPHandler

func NewDocMDPHandler(handler _dd.SignatureHandler, permission _eb.DocMDPPermission) (_dd.SignatureHandler, error)

NewDocMDPHandler returns the new DocMDP handler with the specific DocMDP restriction level.

func NewDocTimeStamp

func NewDocTimeStamp(timestampServerURL string, hashAlgorithm _f.Hash) (_dd.SignatureHandler, error)

NewDocTimeStamp creates a new DocTimeStamp signature handler. Both the timestamp server URL and the hash algorithm can be empty for the signature validation. The following hash algorithms are supported: crypto.SHA1, crypto.SHA256, crypto.SHA384, crypto.SHA512. NOTE: the handler will do a mock Sign when initializing the signature in order to estimate the signature size. Use NewDocTimeStampWithOpts for providing the signature size.

func NewDocTimeStampWithOpts

func NewDocTimeStampWithOpts(timestampServerURL string, hashAlgorithm _f.Hash, opts *DocTimeStampOpts) (_dd.SignatureHandler, error)

NewDocTimeStampWithOpts returns a new DocTimeStamp configured using the specified options. If no options are provided, default options will be used. Both the timestamp server URL and the hash algorithm can be empty for the signature validation. The following hash algorithms are supported: crypto.SHA1, crypto.SHA256, crypto.SHA384, crypto.SHA512.

func NewEmptyAdobePKCS7Detached

func NewEmptyAdobePKCS7Detached(signatureLen int) (_dd.SignatureHandler, error)

NewEmptyAdobePKCS7Detached creates a new Adobe.PPKMS/Adobe.PPKLite adbe.pkcs7.detached signature handler. The generated signature is empty and of size signatureLen. The signatureLen parameter can be 0 for the signature validation.

Types

type AdobeX509RSASHA1Opts

type AdobeX509RSASHA1Opts struct {

	// EstimateSize specifies whether the size of the signature contents
	// should be estimated based on the modulus size of the public key
	// extracted from the signing certificate. If set to false, a mock Sign
	// call is made in order to estimate the size of the signature contents.
	EstimateSize bool

	// Algorithm specifies the algorithm used for performing signing.
	// If not specified, defaults to SHA1.
	Algorithm _f.Hash
}

AdobeX509RSASHA1Opts defines options for configuring the adbe.x509.rsa_sha1 signature handler.

type DocMDPHandler

type DocMDPHandler struct {
	Permission _eb.DocMDPPermission
	// contains filtered or unexported fields
}

DocMDPHandler describes handler for the DocMDP realization.

func (*DocMDPHandler) InitSignature

func (_efg *DocMDPHandler) InitSignature(sig *_dd.PdfSignature) error

InitSignature initialization of the DocMDP signature.

func (*DocMDPHandler) IsApplicable

func (_age *DocMDPHandler) IsApplicable(sig *_dd.PdfSignature) bool

IsApplicable returns true if the signature handler is applicable for the PdfSignature.

func (*DocMDPHandler) NewDigest

func (_fa *DocMDPHandler) NewDigest(sig *_dd.PdfSignature) (_dd.Hasher, error)

NewDigest creates a new digest.

func (*DocMDPHandler) Sign

func (_ecc *DocMDPHandler) Sign(sig *_dd.PdfSignature, digest _dd.Hasher) error

Sign adds a new reference to signature's references array.

func (*DocMDPHandler) Validate

func (_ebd *DocMDPHandler) Validate(sig *_dd.PdfSignature, digest _dd.Hasher) (_dd.SignatureValidationResult, error)

Validate implementation of the SignatureHandler interface This check is impossible without checking the document's content. Please, use ValidateWithOpts with the PdfParser.

func (*DocMDPHandler) ValidateWithOpts

ValidateWithOpts validates a PDF signature by checking PdfReader or PdfParser by the DiffPolicy params describes parameters for the DocMDP checks.

type DocTimeStampOpts

type DocTimeStampOpts struct {

	// SignatureSize is the estimated size of the signature contents in bytes.
	// If not provided, a default signature size of 4192 is used.
	// The signing process will report the model.ErrSignNotEnoughSpace error
	// if the estimated signature size is smaller than the actual size of the
	// signature.
	SignatureSize int

	// Client is the timestamp client used to make the signature request.
	// If no client is provided, a default one is used.
	Client *_deg.TimestampClient
}

DocTimeStampOpts defines options for configuring the timestamp handler.

type SignFunc

type SignFunc func(_bbb *_dd.PdfSignature, _bbd _dd.Hasher) ([]byte, error)

SignFunc represents a custom signing function. The function should return the computed signature.

Jump to

Keyboard shortcuts

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