<?xml version="1.0" encoding="UTF-8"?>
<!--
  xenc-schema-11.rnc (derived from xenc-schema.xsd)
  
  Copyright 2011 W3C (Massachusetts Institute of Technology, 
  Institut National de Recherche en Informatique et en Automatique, 
  Keio University). All Rights Reserved.  http://www.w3.org/Consortium/Legal/
  
  Use and distribution of all schemas in this directory are permitted under the terms
  W3C Software Notice and License
  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="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">
    <attribute name="Algorithm">
      <data type="anyURI"/>
    </attribute>
    <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">
    <!-- Restricts xenc11:AlgorithmIdentifierType -->
    <attribute name="Algorithm">
      <data type="anyURI"/>
    </attribute>
  </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="xenc_EncryptionMethodOtherParams" combine="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>
  </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>
      <!-- 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>
