XML Decryption Transform #13

Or Part Thereof; a Suggestion

Authors/Editors:
Merlin Hughes, Baltimore Technologies Ltd., <merlin@baltimore.ie>

Status of this document

This document has no status; it is a suggestion proposed for possible consideration.

1. Specification

The decryption transform has two modes of operation: Binary mode and XML mode. Characteristics held in common by these two modes are described in the following sections, followed by an explicit specification of each mode.

1.1 Input and Output

The input required by this transform is an XPath node-set over the input document. If the input is an octet stream, then the application MUST convert the octet stream to an XPath node-set, as specified in XMLDSIG.

The output of the transform depends on its operation mode: The binary mode transform produces an octet stream. The XML mode transform produces a node set, from a different document to the input document.

1.2 Parameters

The parameter to this transform is a set of same-document exception URIs which, when deferenced in the context of the input document to the transform (i.e., not necessarily the same document as the transform itself), identify EncryptedData elements that should not be decrypted. These are data that were already encrypted when the signature was generated. Blah blah.

1.2½ Syntax

Blah blah blah encoding the set of exception URIs in Except elements.

1.3 Binary Mode

The binary mode of operation is intended for use when generating a signature over binary data that are to be encrypted for transmission to the recipient. Use of this mode of the transform allows a signature to be computed over the plaintext form of the data, rather than the opaque ciphertext. This further allows the ciphertext to be stored elsewhere, identified by a cipher reference, without the need for the signature to take this into account.

As described in section 1.1, the input to this mode of the transform is a node set, and the output is an octet stream.

1.3.1 Algorithm Identifier

The XML Signature Recommendation [XML-DSig] uses a URI [URI] to identify each algorithm to be performed when creating or validating a signature. The binary-mode decryption transform is identified as follows:

Algorithm Identifier
http://merlin.org/xml-decrypt#Binary

1.3.2 Processing Model of Binary-Mode Decryption Transform

The input to this transform is a node set N. The parameter to this transform is a set of exception URIs E. The output is a node set O, computed as follows:

  1. Dereference each exception URI e, from E, in the context of the owner document of the input node set N, resulting in the location sets xe.
  2. Let the node set D be all element nodes in N, with the namespace URI &xenc; and local name EncryptedData, that are not identified by any location set xe.
  3. Decrypt each EncryptedData element d, from D, without regard for which, if any, of its descendants are in N, and without consideration of its Type attribute, resulting in the octet streams od.
  4. Let O, the output of this transform, be the concatentation of the octet streams od, ordered in the document order of d.

1.3.3 Example of Binary-Mode Decryption Transform

Consider the following example signed document:

<Document>
  <xenc:EncryptedData Id="image" MimeType="image/png" ...>
    ...
    <!-- image data -->
    ...
  </xenc:EncryptedData>
  <dsig:Signature ...>
    ...
    <dsig:Reference URI="#image">
      <dsig:Transforms>
        <dsig:Transform Algorithm="http://merlin.org/xml-decrypt#Binary" />
      </dsig:Transforms>
      ...
    </dsig:Reference>
    ...
  </dsig:Signature>
</Document>

Much of the encrypted data and signature are elided; the implication of the comment in the encrypted data is that the encrypted content is a binary image.

Execution of the decryption transform will proceed as follows:

1.4 XML Mode

The XML mode of operation is intended for use when generating a signature over XML data, parts of which may be encrypted by subsequent processing. Use of this mode of the transform allows the recipient to verify a signature over the XML data, automatically decrypting parts of the data that were encrypted after generation of the signature. Support is provided for identifying parts of XML that were encrypted when the signature was generated; and, with some limitations, for undoing super-encryption of parts of the signed data.

As described in section 1.1, the input to this mode of the transform is a node set, and the output is a node set.

1.4.1 Algorithm Identifier

The XML Signature Recommendation [XML-DSig] uses a URI [URI] to identify each algorithm to be performed when creating or validating a signature. The XML-mode decryption transform is identified as follows:

Algorithm Identifier
http://merlin.org/xml-decrypt#XML

1.4.2 Processing Model of XML-Mode Decryption Transform

The input to this transform is a node set N. The parameter to this transform is a set of exception URIs E. The output is a node set O, computed as follows:

  1. Dereference each exception URI e, from E, in the context of the owner document of the input node set N, resulting in the location sets xe.
  2. Let the node set D0 be all element nodes in N with the namespace URI &xenc; and local name EncryptedData, that are not identified by any location set xe.
  3. Decrypt each EncryptedData element d, from Di (initially i is 0), without regard for which, if any, of its descendants are in N, and process it in accordance with the value of its Type attribute, resulting in the node sets od.
  4. Let the set Di+1 be all element nodes in any replacement node set od with the namespace URI &xenc; and local name EncryptedData, that are not identified by a barename ID reference from any exception URI in E.
  5. Repeat steps 3 and 4 for i ← i+1 while Di+1 is non-empty; i.e., as long as new, unexceptional super-encrypted EncryptedData are identified.
  6. Canonicalize the input node set N according to C14N (with comments); but, in place of any EncryptedData element d, from any Di, and its descendants, canonicalize the decrypted node set od. Let the resulting octet stream be C.
  7. Let O, the output of this transform, be the result of parsing C in accordance with XMLDSIG.

1.4.3 Example of XML-Mode Decryption Transform

Consider the following example signed document:

<Document>
  <ToBeSigned Id="tbs">
    <Part number="1">
      <Data>...</Data>
      <xenc:EncryptedData Id="#secret-1" ... />
    </Part>
    <Part number="2">
      <Data>...</Data>
    </Part>
    <Secrets>
      <xenc:EncryptedData ... />
      <xenc:EncryptedData ... />
    </Secrets>
  </ToBeSigned>
  <dsig:Signature ...>
    ...
    <dsig:Reference URI="#tbs">
      <dsig:Transforms>
        <dsig:Transform Algorithm="http://merlin.org/xml-decrypt#Binary">
          <dcrpt:Except URI="#secret-1" />
          <dcrpt:Except URI="#xpointer(id('tbs')/Secrets/*)" />
        </dsig:Transform>
      </dsig:Transforms>
      ...
    </dsig:Reference>
    ...
  </dsig:Signature>
</Document>

Much of the encrypted data and signature are elided. The Except elements identify parts of the document that were encrypted when the signature was generated.

Consider, then, that this document is subsequently encrypted by various processes, resulting in the following:

<Document>
  <ToBeSigned Id="tbs">
    <xenc:EncryptedData Id="part-1" Type="&enc;Element" ... />
    <xenc:EncryptedData Id="part-2" Type="&enc;Element" ... />
    <Secrets>
      <xenc:EncryptedData ... />
      <xenc:EncryptedData ... />
    </Secrets>
  </ToBeSigned>
  <dsig:Signature ...>
    ...
    <dsig:Reference URI="#tbs">
      <dsig:Transforms>
        <dsig:Transform Algorithm="http://merlin.org/xml-decrypt#Binary">
          <dcrpt:Except URI="#secret-1" />
          <dcrpt:Except URI="#xpointer(id('tbs')/Secrets/*)" />
        </dsig:Transform>
      </dsig:Transforms>
      ...
    </dsig:Reference>
    ...
  </dsig:Signature>
</Document>

Execution of the decryption transform will proceed as follows:

1.5 Limitations

In XML mode, the octet stream resulting from canonicalization-with-replacement MUST be well-formed. Typically this will be characterized by a single-rooted input node set. Additionally, if this node set has, at its top level, an EncryptedData element, then this should correspond to an encrypted single-rooted node set. However, this need not be the case: After decryption, multiple top-level nodes may be well-formed if they consist of whitespace, comments, processing instructions and a single element. No special processing is required to test for this condition because non-well-formed data will result in a parsing error.

Super-encryption MAY cause problems if a super-encrypted EncryptedData uses same-document references, or if an exceptional super-encrypted EncryptedData is referenced by a non-barename XPointer. Superencryption of signed data when these conditions are met is NOT RECOMMENDED. However, applications MAY solve some of these super-encryption problems through the use of encryption properties that identify exceptional super-encrypted elements, how same-document references from the encrypted data should be resolved, and to which signature such encryption properties apply. However, details of such a solution are beyond the scope of this specification.

Full XPointer URIs (whether in exceptions or encrypted data) may fail to resolve if encryption results in a structural change to part of the document relied upon by the reference. For example, the URI #xpointer(/ToBeSigned/*[3]) will no longer function if the first two children of the ToBeSigned element are encrypted together. Care should be taken when employing such references in association with the decryption transform.

EncryptedKey text, etc.

Local Variables:
fill-column: 72
End: