Skip to content

Signature shouldn't ever be valid #3

@Nerzal

Description

@Nerzal

Steps to Reproduce

  1. 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
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions