Steps to Reproduce
- Execute the example code
Description of the Problem
In the Process of creating the signature, the data is canonicalized etc. and in the end of that process this altered data is used to calculate the digest.
While validating the signature, you'd take this digest and the data you have and calculate the digest on your own.
So whats the Problem?
The Method CreateSignature only returns an signature object, but not the canonicalized and transformed, etc. xml data. So the data in the signature and the data we use will never match.
When does the Problem apply?
The Problem applies mostly when using enveloped signature algorithm (http://www.w3.org/2000/09/xmldsig#enveloped-signature)
canonData, id, err := canonicalize(data)
if err != nil {
return nil, err
}
if id != "" {
signature.SignedInfo.Reference.URI = "#" + id
}
//signature.CanonicalizedInput = string(canonData)
// calculate the digest
digest := s.digest(canonData) // <-- We calculate the digest on the canonicalized data, but we never return this data to the user
signature.SignedInfo.Reference.DigestValue = digest
// canonicalize the SignedInfo
canonData, _, err = canonicalize(signature.SignedInfo)
if err != nil {
return nil, err
}
sig, err := s.Sign(canonData)
if err != nil {
return nil, err
}
signature.SignatureValue = sig
`
Steps to Reproduce
Description of the Problem
In the Process of creating the signature, the data is canonicalized etc. and in the end of that process this altered data is used to calculate the digest.
While validating the signature, you'd take this digest and the data you have and calculate the digest on your own.
So whats the Problem?
The Method CreateSignature only returns an signature object, but not the canonicalized and transformed, etc. xml data. So the data in the signature and the data we use will never match.
When does the Problem apply?
The Problem applies mostly when using enveloped signature algorithm (http://www.w3.org/2000/09/xmldsig#enveloped-signature)