Home arrow Security arrow Page 6 - Safeguarding the Identity and Integrity of XML Messages

XML Signature Processing - Security

XML Signature and XML Encryption, two of the three major pillars of the WS-Security standard, are so predominant in current thinking about Web Services Security that some people mistake them as the only strategy for securing Web services. This is really not the case at all. Read more in this chapter from Securing Web Services with WS-Security, by Rosenberg and Remy (ISBN 0672326515, SAMS, 2004).

  1. Safeguarding the Identity and Integrity of XML Messages
  2. XML Signature Fundamentals
  3. XML Signature Structure
  4. Types of XML Signatures
  5. The Signature Element Schema
  6. XML Signature Processing
  7. XML Signature Validation
  8. The XML Signature Elements
  9. Canonicalization Actions from Canonical XML Version 1.0
  10. The SignatureMethod Element
  11. The Reference Element
  12. The Transform Element
  13. XPath Filtering Transform
  14. Enveloped Signature Transform
  15. XPath Filter 2.0 Transform
  16. The DigestMethod Element
  17. The Object Element
  18. The Manifest Element
  19. The KeyInfo Element
  20. Security Strategies for XML Signature
  21. Summary
By: Sams Publishing
Rating: starstarstarstarstar / 7
September 09, 2004

print this article



We have reviewed at a high level the XML Signature elements. Now let's review how an XML Signature is created and then subsequently verified before we go into each element in more detail. This process is actually relatively straightforward. The basic steps are described in the following sections. (Note that unless you are writing a signature processing engine, you won't be performing this process yourself. This description is provided mainly so that you understand what is going on under the covers.)

XML Signature Generation

XML Signature generation is broken down into two components: Reference generation and Signature generation.

Reference Generation

When generating an XML Signature, an XML Signature processing engine first creates all the References. This process involves iterating through all the data objects that are to be signed and calculating their digest value. This basic process is as follows:

  1. Obtain the resource specified by the Reference URI or, if not specified, as determined by the application. Note that seeing XML Signatures that do not use that Reference element to refer to what is being signed is rare; however, the specification allows for the possibility that what is being signed is known from the context of the situation and therefore does not have to be specified.

    In the example earlier, the reference http://www.foo.com/securePage.html would be dereferenced.

  2. Apply the Transforms.

    Transforms were used in the earlier example. A simple Transform might be an XPath statement that causes the signature to apply only to a part of an XML document. We describe Transforms in more detail later in the chapter.

  3. Calculate the Digest using the DigestMethod specified. This step results in the creation of the DigestValue element.

  4. Create the Reference element, including all the sub-elements described previously.

At the end of Reference generation, the XML Signature processing engine will have everything necessary to generate the Reference element. In the simple example used earlier, this looks like Listing 4.9.

Listing 4.9 The XML Signature <Reference> Element

<Reference URI="http://www.foo.com/securePage.html">
 <DigestMethod Algorithm="
http://www.w3.org/2000/09/xmldsig#sha1" />

Signature Generation

After all the Reference elements are created, the XML processing engine can create the Signature itself. To do this, it must gather all the information necessary to create the SignedInfo element, which is what is actually signed in an XML Signature. Here are the steps:

  1. Create the SignedInfo element itself, including the Reference objects created in Reference generation and the CanonicalizationMethod, SignatureMethod, and DigestMethod. The information in SignedInfo is what is actually signed. Listing 4.10 shows the SignedInfo from the earlier example.

    Listing 4.10 The <SignedInfo> Element

       Algorithm="http://www.w3.org/TR/2000/WD-xml-c14n-20001011" />
     <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
     <Reference URI="http://www.foo.com/securePage.html">
      <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />

  2. Canonicalize SignedInfo using the CanonicalizationMethod specified. We talk in detail about canonicalization later, but suffice it to say that whenever XML is being signed, it needs to be "normalized" before creating the hash and actually signing the SignedInfo information.

  3. Using the output from the canonicalization algorithm, create a hash of the SignedInfo element using the specified DigestMethod.

  4. Calculate the SignatureValue using the algorithm specified in SignatureMethod against the hashed, canonicalized SignedInfo element that was calculated in step 3. Listing 4.11 shows the SignatureValue element from the earlier example:

    Listing 4.11 The <SignatureValue> Element


  5. Bundle the SignedInfo, SignatureValue, KeyInfo (if supplied), and Object (if necessary) into the Signature element.

You now have an XML Signature. The key point to remember here is that the SignedInfo element is what is really being signed, not the direct resource(s) targeted by the Reference URI(s). Of course, because a digest of the target URI(s) is included in the SignedInfo element, it is being indirectly signed along with the information about the signature in the SignedInfo element.

SamsThis chapter is from Securing Web Services Security with WS-Security, by Jothy Rosenberg and David Remy (Sams, 2004, ISBN: 0672326515). Check it out at your favorite bookstore today.

Buy this book now.

>>> More Security Articles          >>> More By Sams Publishing

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Secure Your Business for Data Privacy Day
- Google Testing Security Fob Password Alterna...
- Security News Highlights Concerns
- Going to Extremes for Data Security
- Skipfish Website Vulnerability Scanner
- Critical Microsoft Visual Studio Security Pa...
- US Faces Tech Security Expert Deficit
- LAN Reconnaissance
- An Epilogue to Cryptography
- A Sequel to Cryptography
- An Introduction to Cryptography
- Security Overview
- Network Security Assessment
- Firewalls
- What’s behind the curtain? Part II

Developer Shed Affiliates


Dev Shed Tutorial Topics: