<?xml version="1.0" encoding="UTF-8"?>
<!--
  xenc-schema-11.rnc (derived from xenc-schema.xsd)
  
  Copyright ©[2011] World Wide Web Consortium 
  (Massachusetts Institute of Technology,  
   European Research Consortium for Informatics and Mathematics, 
   Keio University). All Rights Reserved.  
  This work is distributed under the W3C® Software License [1] in the
  hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE. 
  [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
  
  
  This schema complements "xenc-schema.rnc" by introducing 
  elements specific to 1.1.  Note that the definitions of
  xenc_EncryptionMethodOtherParams and 
  xenc_AgreementMethodParams have been extended so that 
  elements specific to 1.1 are allowed.
-->
<grammar ns="http://www.w3.org/2009/xmlenc11#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <define name="xenc11_ConcatKDFParams">
    <element name="ConcatKDFParams">
      <ref name="xenc11_ConcatKDFParamsType"/>
    </element>
  </define>
  <define name="xenc11_ConcatKDFParamsType">
    <optional>
      <attribute name="AlgorithmID">
        <data type="hexBinary"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="PartyUInfo">
        <data type="hexBinary"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="PartyVInfo">
        <data type="hexBinary"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="SuppPubInfo">
        <data type="hexBinary"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="SuppPrivInfo">
        <data type="hexBinary"/>
      </attribute>
    </optional>
    <ref name="ds_DigestMethod"/>
  </define>
  <define name="xenc11_DerivedKey">
    <element name="DerivedKey">
      <ref name="xenc11_DerivedKeyType"/>
    </element>
  </define>
  <define name="xenc11_DerivedKeyType">
    <optional>
      <attribute name="Recipient">
        <data type="string"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="Id">
        <ref name="xenc11_IdType"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="Type">
        <data type="anyURI"/>
      </attribute>
    </optional>
    <optional>
      <ref name="xenc11_KeyDerivationMethod"/>
    </optional>
    <optional>
      <ref name="xenc_ReferenceList"/>
    </optional>
    <optional>
      <element name="DerivedKeyName">
        <data type="string"/>
      </element>
    </optional>
    <optional>
      <element name="MasterKeyName">
        <data type="string"/>
      </element>
    </optional>
  </define>
  <define name="xenc11_KeyDerivationMethod">
    <element name="KeyDerivationMethod">
      <ref name="xenc11_KeyDerivationMethodType"/>
    </element>
  </define>
  <define name="xenc11_KeyDerivationMethodType">
    <choice>
      <group>
        <attribute name="Algorithm">
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#ConcatKDF</value>
        </attribute>
        <ref name="xenc11_ConcatKDFParams"/>
      </group>
      <group>
        <attribute name="Algorithm">
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#pbkdf2</value>
        </attribute>
        <ref name="xenc11_PBKDF2-params"/>
      </group>
    </choice>
  </define>
  <define name="xenc11_PBKDF2-params">
    <element name="PBKDF2-params">
      <ref name="xenc11_PBKDF2ParameterType"/>
    </element>
  </define>
  <define name="xenc11_AlgorithmIdentifierType">
    <optional>
      <attribute name="Algorithm">
        <data type="anyURI"/>
      </attribute>
    </optional>
    <optional>
      <element name="Parameters">
        <zeroOrMore>
          <ref name="security_anyAttribute"/>
        </zeroOrMore>
        <mixed>
          <zeroOrMore>
            <ref name="security_anyElement"/>
          </zeroOrMore>
        </mixed>
      </element>
    </optional>
  </define>
  <define name="xenc11_PRFAlgorithmIdentifierType">
    <optional>
      <!-- Restricts xenc11:AlgorithmIdentifierType -->
      <attribute name="Algorithm">
        <data type="anyURI"/>
      </attribute>
    </optional>
  </define>
  <define name="xenc11_PBKDF2ParameterType">
    <element name="Salt">
      <choice>
        <element name="Specified">
          <data type="base64Binary"/>
        </element>
        <element name="OtherSource">
          <ref name="xenc11_AlgorithmIdentifierType"/>
        </element>
      </choice>
    </element>
    <element name="IterationCount">
      <data type="positiveInteger"/>
    </element>
    <element name="KeyLength">
      <data type="positiveInteger"/>
    </element>
    <element name="PRF">
      <ref name="xenc11_PRFAlgorithmIdentifierType"/>
    </element>
  </define>
  <define name="xenc11_IdType">
    <data type="NCName"/>
  </define>
  <!-- xsd:ID does not work -->
  <define name="xenc11_MGF">
    <element name="MGF">
      <ref name="xenc11_MGFType"/>
    </element>
  </define>
  <define name="xenc11_MGFType">
    <!-- Restricts xenc11:AlgorithmIdentifierType -->
    <attribute name="Algorithm">
      <data type="anyURI"/>
    </attribute>
  </define>
  <define name="xenc_EncryptionMethodOtherParams" combine="choice">
    <choice>
      <attribute name="Algorithm">
        <choice>
          <!-- Block Encryption -->
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes128-gcm</value>
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes256-gcm</value>
          <!-- Symmetric Key Wrap -->
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#kw-aes-128-pad</value>
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#kw-aes-192-pad</value>
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#kw-aes-256-pad</value>
        </choice>
      </attribute>
      <!-- Key Transport -->
      <group>
        <attribute name="Algorithm">
          <value type="anyURI">http://www.w3.org/2009/xmlenc11#rsa-oaep</value>
        </attribute>
        <optional>
          <element name="xenc:OAEPparams">
            <data type="base64Binary"/>
          </element>
        </optional>
        <optional>
          <ref name="xenc11_MGF"/>
        </optional>
        <optional>
          <ref name="ds_DigestMethod"/>
        </optional>
      </group>
    </choice>
  </define>
  <define name="xenc_AgreementMethodParams" combine="choice">
    <choice>
      <attribute name="Algorithm">
        <value type="anyURI">http://www.w3.org/2009/xmlenc11#dh-es</value>
      </attribute>
      <attribute name="Algorithm">
        <value type="anyURI">http://www.w3.org/2009/xmlenc11#ECDH-ES</value>
      </attribute>
    </choice>
  </define>
  <!-- List of known algorithms -->
  <define name="xenc_EncryptionAlgorithms" combine="choice">
    <choice>
      <!-- Block Encryption -->
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes128-gcm</value>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes256-gcm</value>
      <!-- Key Transport -->
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#rsa-oaep</value>
      <!-- Symmetric Key Wrap -->
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#kw-aes-128-pad</value>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#kw-aes-192-pad</value>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#kw-aes-256-pad</value>
    </choice>
  </define>
  <define name="xenc_KeyAgreementAlgorithms" combine="choice">
    <choice>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#dh-es</value>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#ECDH-ES</value>
    </choice>
  </define>
  <define name="xenc11_KeyDerivationAlgorithms">
    <choice>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#ConcatKDF</value>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#pbkdf2</value>
    </choice>
  </define>
</grammar>
