Documentation
¶
Overview ¶
Package xmlsig supports add XML Digital Signatures to Go structs marshalled to XML.
Index ¶
Constants ¶
const ( SignatureAlgorithmDsigRSASHA1 = "http://www.w3.org/2000/09/xmldsig#rsa-sha1" SignatureAlgorithmDsigRSASHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" )
const ( DigestAlgorithmDsigRSASHA1 = "http://www.w3.org/2000/09/xmldsig#rsa-sha1" DigestAlgorithmDsigSHA256 = "http://www.w3.org/2001/04/xmlenc#sha256" )
Variables ¶
var Canonicalize = canonicalize
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm struct {
Algorithm string `xml:",attr"`
}
Algorithm describes the digest or signature used when digest or signature.
type KeyInfo ¶
type KeyInfo struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# KeyInfo"`
X509Data *X509Data
Children []interface{}
}
KeyInfo is an optional element that enables the recipient(s) to obtain the key needed to validate the signature.
type Reference ¶
type Reference struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Reference"`
URI string `xml:",attr,omitempty"`
Transforms Transforms
DigestMethod Algorithm `xml:"http://www.w3.org/2000/09/xmldsig# DigestMethod"`
DigestValue string `xml:"http://www.w3.org/2000/09/xmldsig# DigestValue"`
}
Reference specifies a digest algorithm and digest value, and optionally an identifier of the object being signed, the type of the object, and/or a list of transforms to be applied prior to digesting.
type Signature ¶
type Signature struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`
SignedInfo SignedInfo
SignatureValue string `xml:"http://www.w3.org/2000/09/xmldsig# SignatureValue"`
KeyInfo KeyInfo
}
Signature element is the root element of an XML Signature.
type SignedInfo ¶
type SignedInfo struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# SignedInfo"`
CanonicalizationMethod Algorithm `xml:"http://www.w3.org/2000/09/xmldsig# CanonicalizationMethod"`
SignatureMethod Algorithm `xml:"http://www.w3.org/2000/09/xmldsig# SignatureMethod"`
Reference Reference
}
SignedInfo includes a canonicalization algorithm, a signature algorithm, and a reference.
type Signer ¶
type Signer interface {
Sign([]byte) (string, error)
CreateSignature(interface{}) (*Signature, error)
Algorithm() string
}
Signer is used to create a Signature for the provided object.
func NewSigner ¶
func NewSigner(cert *x509.Certificate, key *rsa.PrivateKey, options ...SignerOptions) (Signer, error)
NewSigner creates a new Signer with the certificate and options
type SignerOptions ¶
type Transforms ¶
type Transforms struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Transforms"`
Transform []Algorithm `xml:"http://www.w3.org/2000/09/xmldsig# Transform"`
}
Transforms is an optional ordered list of processing steps that were applied to the resource's content before it was digested.
type Verifier ¶
type Verifier interface {
Verify([]byte, *Signature) (bool, error)
VerifySignature(interface{}, *Signature) (bool, error)
Algorithm() string
}
func NewVerifier ¶
func NewVerifier(cert *x509.Certificate, options ...VerifierOptions) (Verifier, error)
NewVerifier creates a new Signer with the certificate and options