





















































All the components in web services are described in XML. SOAP and all the WS -Security specifications are XML formats. Hence it just makes sense for expressing security data in XML format. Fortunately, there has been no need to invent new cryptography technologies for XML. The XML security standards have used existing cryptography directly. XML-based data transfer has emerged as the standard for organizations to exchange business data. As with all communications over the public Internet, XML-based transfers have their own set of vulnerabilities to confront. Like any other document exchange, XML document exchange must support the usual security measures which are Confidentiality, Integrity, Authenticity, and Non-Repudiation. The following list illustrates some specific XML security threats:
These threats pose potentially serious problems to developers creating applications, components, and systems that depend on XML data. The solution for the above problems is XML Encryption.
XML Encryption provides end-to-end security for applications that require secure exchange of structured data. XML itself is the most popular technology for structuring data, and therefore XML-based encryption is the natural way to handle complex requirements for security in data interchange applications.
XML Encryption is a process for encrypting and decrypting parts of XML documents. Most of today's encryption schemes use transport-level techniques that encrypt an entire request and response stream between a sender and receiver, offering zero visibility into contents of the interchange to intermediaries. Contentlevel encryption converts document fragments into illegible ciphertext, while other elements remain legible as plaintext.
Some features of XML encryption are:
Here's a short sample XML file that can serve to demonstrate XML encryption:
<?xml version='1.0'?>
<POInfo >
<Name>FJ</Name>
<Amount>125.00</Amount>
<CreditCardNumber>1234-5678-4564-4321</CreditCardNumber>
<Date>July 6, 2006</Date>
</POInfo>
When you encrypt an entire XML file, the process simply replaces the root element (<POInfo> in the sample) with an <EncryptedData> element that contains the encryption details, including the encrypted content.
Here is how the encrypted file will look:
<?xml version="1.0" encoding="UTF-8"?>
<xenc:EncryptedData
Type="http://www.w3.org/2001/04/xmlenc#Element">
<xenc:EncryptionMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"
/>
<ds:KeyInfo >
<xenc:EncryptedKey
>
<xenc:EncryptionMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#kw-tripledes"
/>
<xenc:CipherData
>
<xenc:CipherValue
>
MKeT0ZmHFLwnZaSXO+oZSxlSJ5/BqvblqG76B3nOMU0=
</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedKey>
</ds:KeyInfo>
<xenc:CipherData
>
<xenc:CipherValue
>
+M/Tamk/62Lut4HqLpU/es9sdhnNTTpasbeszN8GN8EAJZsX0vvClcKEW
UAgIdbvyJpprQ+jUIiWJKTz1X3L6VAefHqO963pU3bzmGMo
pHLqS1Eg7iAPFhKV1PJclyswyyepEjyu+bOgqzgGnS1XA0/V
NP7kLK70rB2Zb0DSbaCi+7HjTNGWF9YKtPIP5bvrs5xw+x
HnKO++2EuqzK+deD7mCu8w6sG9vmRCrUR99Mx1QDZon9a2962ZD
FSwoIJKg5I83GzOU+RObBBUme+yTf7UWybEiwtHp5ZgvuaQYJA=
</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
To encrypt a single element of an XML file, you specify the desired child element, rather than the root element of the input file as the element to encrypt. The following snippet shows the results of encrypting only the <CreditCardNumber> element of the sample file.
<?xml version="1.0" encoding="UTF-8"?>
<POInfo >
<Name>John Doe</Name>
<Amount>125.00</Amount>
<xenc:EncryptedData
Type="http://www.w3.org/2001/04/xmlenc#Element">
<xenc:EncryptionMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"
/>
<ds:KeyInfo >
<xenc:EncryptedKey
>
<xenc:EncryptionMethod
Algorithm=
"http://www.w3.org/2001/04/xmlenc#kw-tripledes"
/>
<xenc:CipherData
>
<xenc:CipherValue
>
6zhAcEW7KIKrbSjEOkXDrVkmws5zhQQLDO4YYW+RfRY=
</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedKey>
</ds:KeyInfo>
<xenc:CipherData
>
<xenc:CipherValue
>
JqsRmdSoS+PXqCe80Y8zNiQ49sHTLNaAgHX1Ja7d+u9fv
TFBrkBMK7C7EHsQTglZ3yT9yCZDuFnjBoQTLULKqOy71Qw
EPRPObtYLPIJgy1vUdNrw47uDmJ/R5r/B0SH37HN8mfNv
i50zPt1qPxxRwA==
</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
<Date>July 6, 2005</Date>
</POInfo>
Notice that the encryption process replaced the <CreditCardNumber> tag and its contents with an <EncryptedData> tag, while leaving the siblings of the <CreditCardNumber> element unaltered.
This type of encryption can be performed using XML Signature and Encryption. The interested reader may look up the implementation at the Apache site (http://xml.apache.org/security/).
Best practices for XML encryption, can be summarized as follows: