148
Chapter 5 XML Digital Signatures
There may be zero or more Transforms steps. If there are multiple Transforms,
each ones output provides the input for the next.
The CanonicalizationMethod element contains the algorithm used to canoni-
calize the data, or structure the data in a common way agreed on by almost
everyone.This process is very important for the reasons mentioned at the begin-
ning of this section. Canonicalization can be used to do such things as apply a
standard end-of-line convention, removing comments, or doing any other manip-
ulation of the signed document that your needs require.
The Reference element identifies the resource to be signed and any algorithms
used to preprocess the data.These algorithms are listed in the Transforms element
and can include operations such as canonicalization, encoding/decoding, com-
pression/inflation, or even XPath or XSLT transformations.The Reference element
can contain multiple Transforms elements; each one that is listed in Reference will
operate in turn on the data. Notice that the Reference element contains a URI
attribute that is optional. If a signature contains more than one Reference element,
the presence of the URI attribute is optional for only one Reference element; all
the others must have a URI attribute.The syntax of the definition of Signature
displayed previously in Figure 5.1 does not make this point very clear; however,
the W3C XML Digital Signature specification document (www.w3.org/TR/
2002/REC-xmldsig-core-20020212) does.
The DigestMethod is the algorithm applied to the data after any defined trans-
formations are applied to generate the value within DigestValue. It should be rec-
ognized that the DigestValue is applied to result of the canonicalization and
transform process, not the original data. Consequently, if a change is made to
these documents that is transparent to these manipulations, the signature of the
document will still verify. As a simple example, suppose we had created a canoni-
calization method that converts all text in a file to lowercase and used it to sign a
document that originally contained mixed case. If we subsequently changed the
original document by converting it to entirely uppercase, that modified docu-
ment would still be validly verified by the original signature.
Signing the DigestValue binds resource content to the signers key.The algo-
rithm used to convert the canonicalized and transformed SignedInfo into the
SignatureValue is specified in the SignatureMethod element.The SignatureValue con-
tains the actual value of the digital signature.
The KeyInfo element is where the information about the signing key is to be
placed. Notice that this element is allowed to occur zero times; in other words,
its optional. Under typical circumstances, when you want to create a standalone
signature, the KeyInfo element needs to be there, since the signers public key is
www.syngress.com