HomeUniDoc
HomeUniDoc
...

Package sighandler

Overview ▾

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

func NewAdobePKCS7Detached

func NewAdobePKCS7Detached(privateKey *rsa.PrivateKey, certificate *x509.Certificate) (model.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 *rsa.PrivateKey, certificate *x509.Certificate) (model.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 *x509.Certificate, signFunc SignFunc) (model.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 *x509.Certificate, signFunc SignFunc,
    opts *AdobeX509RSASHA1Opts) (model.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 NewDocTimeStamp

func NewDocTimeStamp(timestampServerURL string, hashAlgorithm crypto.Hash) (model.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 crypto.Hash, opts *DocTimeStampOpts) (model.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) (model.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.

type AdobeX509RSASHA1Opts

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

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
}

type DocTimeStampOpts

DocTimeStampOpts defines options for configuring the timestamp handler.

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
}

type SignFunc

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

type SignFunc func(sig *model.PdfSignature, digest model.Hasher) ([]byte, error)