<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <title>XML Encryption Syntax and Processing</title>
  <style type="text/css">

    u,ins        { background: white; color: red;}
    del,strike,.strike   { background: white; color: silver;
 text-decoration: line-through;}
    code     {font-weight: normal; }
    .link-def   { background: #FFFFFF; color: teal;  font-style: italic;}
    .comment    { background: #FFFFF5; color: black; padding: .7em; border:
 navy thin solid;}
    .discuss    { color: blue; background: yellow; }
    .xml-example,.xml-dtd { margin-left: -1em; padding: .5em; white-space:
 pre; border: none;}
    .xml-dtd    { background: #efeff8; color: black;}
    </style>
  <link rel="stylesheet" type="text/css"
  href="http://www.w3.org/StyleSheets/TR/W3C-WD.css" />
</head>

<body xml:lang="en" lang="en">
<h1 class="notoc">Using XML Encryption and XML Signature for Partial
Signature Validation</h1>

<p>Amir has identified a requirement that is under discussion.</p>
<ol>
  <li>It should provide strong authentication of plaintext that is later
    encrypted.</li>
  <li>It should permit the partial revelation of an encrypted document to
    verify those parts of the document. 
    <ol>
      <li>The <a href="http://www.w3.org/TR/xmlenc-decrypt">Decryption
        Transform for XML Signature</a> permits one to describe the signing
        and encryption of a document in layered steps. For instance, if A and
        B were encrypted, then the document was signed, then one encrypted C
        and D. Using the Decryption Transform, I can decrypt C <a name="and"
        id="and">and</a> D, then validate the signature. Note, I have to
        decrypt C <strong>and</strong> D; if I want validate C, but not D,
        its contrary to data minimization to have to reveal D just to
        validate the signature on C. Amir desires (and the present
        specification) provides for this using a DigestMethod and DigestValue
        in the EncryptedData. This document shows how to do it soly using
        XMLDSIG.</li>
      <li>Schaad does not like the plaintext of encrypted document to be in
        the clear. However, this is part of Amir's desired functionality,
        Schaad's concern can be addressed by using nonces with the plaintext,
        and Schaad's proposal introduces the possibility (when used for
        authentication instead of simple random error checksum functionality)
        that an attacker can find a new plaintext message
        <strong>and</strong> key which will yield the same CipherValue. The
        DigestValue that is encrypted within CipherValue will be different,
        but since this wasn't specifically signed, it can be replaced with
        the new digest of the new plaintext message without detection.</li>
    </ol>
  </li>
  <li>Merlin and Amir have stated the partial revelation could be done with a
    Signature Manifest, wherein a new Reference in created for every possible
    partial revelation one would like to make. This isn't very different from
    the present specfication which spreads these places these digests in the
    encrypted data instead of a Signature Manfist.</li>
  <li>We need to figure out which approach is better: Amir describes the <a
    href="http://lists.w3.org/Archives/Public/xml-encryption/2001Sep/0018.html">trade
    off</a> well. However, the one outstanding problem with the Manifest
    approach is, "I'm not sure how the Reference elements in the Manifest
    will identify the hashed elements. They need to refer to the decrypted
    value of an EncryptedData element - how do you do this?"</li>
</ol>

<p>The follow scenario attempts to address this question:</p>

<p>Some piece of data file://foo.xml</p>
<pre class="xml-example">&lt;AlphabetiSphagetti&gt;
  &lt;A id="a"/&gt;
  &lt;B id="b"/&gt;
  &lt;C id="c"/&gt;
&lt;/AlphabetiSphagetti&gt;</pre>

<p>A separate Reference is created for each letter element:</p>
<pre class="xml-example">&lt;Signature Id="MyFirstSignature" xmlns="http://www.w3.org/2000/09/xmldsig#"&gt; 
  &lt;SignedInfo&gt; 
    &lt;CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/&gt; 
    &lt;SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/&gt; 
    &lt;Reference URI="#Manifest1"&gt; 
       &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt; 
       &lt;DigestValue&gt;j6lwx3rvEPO0vKtMup4NbeVu8nk=&lt;/DigestValue&gt; 
    &lt;/Reference&gt;
  &lt;/SignedInfo&gt; 
  &lt;SignatureValue&gt;MC0CFFrVLtRlk=...&lt;/SignatureValue&gt; 
  &lt;Object&gt;
    &lt;Manifest ID="Manifest1"&gt;
      &lt;Reference URI="foo.xml#a"&gt; 
         &lt;Transforms&gt;
           &lt;Transform Algorithm="http://www.w3.org/2001/04/xmlenc#decryption"/&gt;
         &lt;/Transforms&gt;
         &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt; 
         &lt;DigestValue&gt;aj6lwx3rvEPO0vKtMup4NbeVu8nk=&lt;/DigestValue&gt; 
      &lt;/Reference&gt;
      &lt;Reference URI="foo.xml#b"&gt; 
         &lt;Transforms&gt;
           &lt;Transform Algorithm="http://www.w3.org/2001/04/xmlenc#decryption"/&gt;
         &lt;/Transforms&gt; 
        &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt; 
         &lt;DigestValue&gt;bj6lwx3rvEPO0vKtMup4NbeVu8nk=&lt;/DigestValue&gt; 
      &lt;/Reference&gt;
      &lt;Reference URI="foo.xml#c"&gt; 
         &lt;Transforms&gt;
           &lt;Transform Algorithm="http://www.w3.org/2001/04/xmlenc#decryption"/&gt;
         &lt;/Transforms&gt;
         &lt;DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt; 
         &lt;DigestValue&gt;cj6lwx3rvEPO0vKtMup4NbeVu8nk=&lt;/DigestValue&gt; 
      &lt;/Reference&gt;
    &lt;/Manifest&gt;
&lt;/Signature&gt;</pre>

<p>The decryption transform means, "If I'm subsequently encrypted, to
validate me, you need to decrypt all EncryptedData elements except the
following (which is an empty list in this example." If I then encrypt B and
C.</p>
<pre class="xml-example">&lt;AlphabetiSphagetti&gt;
  &lt;A id="a"/&gt;
  &lt;EncryptedData xmlns='http://www.w3.org/2001/04/xmlenc#'
   Type='http://www.w3.org/2001/04/xmlenc#Element'&gt;
    &lt;CipherData&gt;
      &lt;CipherValue&gt;BA23B45C56&lt;/CipherValue&gt;
    &lt;/<code>CipherDat</code>a&gt;
   &lt;/<code>EncryptedDat</code>a&gt;
  &lt;EncryptedData xmlns='http://www.w3.org/2001/04/xmlenc#'
   Type='http://www.w3.org/2001/04/xmlenc#Element'&gt;
    &lt;CipherData&gt;
      &lt;CipherValue&gt;BA23B45C56&lt;/CipherValue&gt;
    &lt;/<code>CipherDat</code>a&gt;
   &lt;/<code>EncryptedDat</code>a&gt;
&lt;/AlphabetiSphagetti&gt;</pre>

<p>Results:</p>
<ol>
  <li>The Signature over the original foo.xml is clearly broken, as it should
    be.</li>
  <li>However, the application can still confirm the integrity/authenticity
    of element A using the digest in the Manifest. (Note, these references
    must be stable even after encryption, consequently relative pointers like
    (3 cousin from the 2nd paragraph might be too brittle for post encryption
    processing).</li>
  <li>If the signer is challenged to demonstrate the authenticity/integrity
    of B, but doesn't want to reveal C to do this, he only has to decrypt B
    and can confirm the value in the manifest.</li>
  <li>I'm not convinced this is any better or worse than that already
    specified. If there's no faults in the scenario the trade off is as
    follows: this scenario doesn't have to add any processing to encryption,
    but it the digests have to sit in a manifest elsewhere, and it is
    convenient to locate them in the EncryptedData. (The functionality
    requires some complexity regardless, and I think I prefer to address
    authenticity solely with the Signature spec...)</li>
</ol>
</body>
</html>
