Update signature.go

This commit is contained in:
zhenglixin
2017-02-18 18:04:59 +08:00
committed by GitHub
parent 1aa2f9374a
commit ccd046e860

View File

@@ -24,14 +24,18 @@ type Method struct {
// buf, _ := xml.Marshal(f) // buf, _ := xml.Marshal(f)
// buf, _ = Sign(key, buf) // buf, _ = Sign(key, buf)
// //
type Reference struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Reference"`
Transforms []Method `xml:"Transforms>Transform"`
DigestMethod Method `xml:"DigestMethod"`
DigestValue string `xml:"DigestValue"`
}
type Signature struct { type Signature struct {
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"` XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`
CanonicalizationMethod Method `xml:"SignedInfo>CanonicalizationMethod"` CanonicalizationMethod Method `xml:"SignedInfo>CanonicalizationMethod"`
SignatureMethod Method `xml:"SignedInfo>SignatureMethod"` SignatureMethod Method `xml:"SignedInfo>SignatureMethod"`
ReferenceTransforms []Method `xml:"SignedInfo>Reference>Transforms>Transform"` Reference Reference `xml:"http://www.w3.org/2000/09/xmldsig# Reference"`
DigestMethod Method `xml:"SignedInfo>Reference>DigestMethod"`
DigestValue string `xml:"SignedInfo>Reference>DigestValue"`
SignatureValue string `xml:"SignatureValue"` SignatureValue string `xml:"SignatureValue"`
KeyName string `xml:"KeyInfo>KeyName,omitempty"` KeyName string `xml:"KeyInfo>KeyName,omitempty"`
X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"` X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"`
@@ -56,11 +60,13 @@ func DefaultSignature(pemEncodedPublicKey []byte) Signature {
SignatureMethod: Method{ SignatureMethod: Method{
Algorithm: "http://www.w3.org/2000/09/xmldsig#rsa-sha1", Algorithm: "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
}, },
ReferenceTransforms: []Method{ Reference: Reference{
Method{Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature"}, Transforms: []Method{
}, Method{Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature"},
DigestMethod: Method{ },
Algorithm: "http://www.w3.org/2000/09/xmldsig#sha1", DigestMethod: Method{
Algorithm: "http://www.w3.org/2000/09/xmldsig#sha1",
},
}, },
X509Certificate: &SignatureX509Data{ X509Certificate: &SignatureX509Data{
X509Certificate: certStr, X509Certificate: certStr,