<?xml version="1.0" encoding="UTF-8"?>
<!--
  xenc-schema-11.rnc
  
  This schema is expected to be used together with xenc-schema.rnc.
  
  This schema defines elements specific to 1.1.  Note that the definitions of 
  xenc_EncryptionMethodOtherParams, xenc_EncryptionMethodOtherParams, 
  xenc_EncryptionAlgorithms, xenc_KeyAgreementAlgorithms, and 
  xenc_EncryptionAlgorithms have been extended so that elements specific 
  to 1.1 are allowed.
  
  This schema provide one customization point, namely xenc11_KeyDerivationMethodType.
-->
<grammar ns="http://www.w3.org/2009/xmlenc11#" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <define name="xenc_EncryptionMethodOtherParams" combine="choice">
    <attribute name="Algorithm">
      <choice>
        <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes128-gcm</value>
        <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes256-gcm</value>
      </choice>
    </attribute>
  </define>
  <define name="xenc_EncryptionMethodOtherParams" combine="choice">
    <attribute name="Algorithm">
      <choice>
        <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>
  </define>
  <define name="xenc_EncryptionAlgorithms" combine="choice">
    <choice>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes128-gcm</value>
      <value type="anyURI">http://www.w3.org/2009/xmlenc11#aes256-gcm</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="xenc_EncryptionAlgorithms" combine="choice">
    <choice>
      <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="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"/>
    </optional>
    <optional>
      <element name="Parameters">
        <zeroOrMore>
          <ref name="anyAttribute"/>
        </zeroOrMore>
        <mixed>
          <zeroOrMore>
            <ref name="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_AgreementMethodParams">
    <choice>
      <group>
        <attribute name="Algorithm">
          <value type="anyURI">http://www.w3.org/2001/04/xmlenc#dh</value>
        </attribute>
        <ref name="ds_DigestMethod"/>
      </group>
      <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>
  <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>
