<cards>
  <card name="card" >

    <commands>

      <command name="IsoReadBinary" >
        <send>
          <APDU>
            <ELEM type="word">0x00b0</ELEM>
            <ELEM name="offset" type="word" />
          </APDU>
        </send>
        <results>
          <result sw1="0x61" type="success" >
            Command executed, correct size in SW2
          </result>
          <result sw1="0x62" sw2="0x82" type="success" >
            Command executed, EOF met.
          </result>
          <result sw1="0x69" sw2="0x86" type="error" >
            No EF selected (internal error)
          </result>
        </results>
        <responses>
          <response type="success">
            <ELEM name="data" type="bytes" />
          </response>
        </responses>
      </command>

      <command name="IsoWriteBinary" >
        <send>
          <APDU>
            <ELEM type="word">0x00d0</ELEM>
            <ELEM name="offset" type="word" />
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>
        <results>
          <result sw1="0x61" type="success" >
            Command executed, correct size in SW2
          </result>
          <result sw1="0x69" sw2="0x86" type="error" >
            No EF selected (internal error)
          </result>
        </results>
      </command>

      <command name="IsoUpdateBinary" >
        <send>
          <APDU>
            <ELEM type="word">0x00d6</ELEM>
            <ELEM name="offset" type="word" />
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>
        <results>
          <result sw1="0x61" type="success" >
            Command executed, correct size in SW2
          </result>
          <result sw1="0x69" sw2="0x86" type="error" >
            No EF selected (internal error)
          </result>
        </results>
      </command>


      <command name="IsoEraseBinary" >
        <send>
          <APDU>
            <ELEM type="word">0x000e</ELEM>
            <ELEM name="offset" type="word" />
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>
        <results>
          <result sw1="0x61" type="success" >
            Command executed, correct size in SW2
          </result>
          <result sw1="0x69" sw2="0x86" type="error" >
            No EF selected (internal error)
          </result>
        </results>
      </command>


      <command name="IsoVerifyPin_Fpin2" >
        <send>
          <APDU >
            <ELEM type="word">0x0020</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="pid" type="byte" />
          </APDU>
          <DATA>
            <ELEM name="pin" type="bytes" size="8"/>
          </DATA>
        </send>
        <results>
          <result sw1="0x63" sw2="0xc0" type="error" >
            Bad PIN (only one try left !)
          </result>
          <result sw1="0x63" type="error" >Bad PIN</result>
          <result sw1="0x63" sw2="0xc1" type="error" >
            Bad PIN (only two tries left !)
          </result>
          <result sw1="0x63" sw2="0xc2" type="error" >
            Bad PIN (only three tries left !)
          </result>
          <result sw1="0x69" sw2="0x83" type="error" >
            Card seems to be destroyed, this might have the following reasons:
             1) you entered a bad PIN too often
             2) the card is of a new and yet unknown type
          </result>
        </results>
      </command>


      <command name="IsoVerifyPin_Ascii" >
        <send>
          <APDU >
            <ELEM type="word">0x0020</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="pid" type="byte" />
          </APDU>
          <DATA>
            <ELEM name="pin" type="bytes" 
                  minsize="4" maxsize="12" 
                  filler="32" />
          </DATA>
        </send>
        <results>
          <result sw1="0x63" sw2="0xc0" type="error" >
            Bad PIN (only one try left !)
          </result>
          <result sw1="0x63" type="error" >Bad PIN</result>
          <result sw1="0x63" sw2="0xc1" type="error" >
            Bad PIN (only two tries left !)
          </result>
          <result sw1="0x63" sw2="0xc2" type="error" >
            Bad PIN (only three tries left !)
          </result>
          <result sw1="0x69" sw2="0x83" type="error" >
            Card seems to be destroyed, this might have the following reasons:
             1) you entered a bad PIN too often
             2) the card is of a new and yet unknown type
          </result>
        </results>
      </command>


      <command name="IsoVerifyPin_Bcd" >
        <send>
          <APDU >
            <ELEM type="word">0x0020</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="pid" type="byte" />
          </APDU>
          <DATA>
            <ELEM name="pin" type="bytes" 
                  minsize="4" maxsize="8" filler="0" />
          </DATA>
        </send>
        <results>
          <result sw1="0x63" sw2="0xc0" type="error" >
            Bad PIN (only one try left !)
          </result>
          <result sw1="0x63" type="error" >Bad PIN</result>
          <result sw1="0x63" sw2="0xc1" type="error" >
            Bad PIN (only two tries left !)
          </result>
          <result sw1="0x63" sw2="0xc2" type="error" >
            Bad PIN (only three tries left !)
          </result>
          <result sw1="0x69" sw2="0x83" type="error" >
            Card seems to be destroyed, this might have the following reasons:
             1) you entered a bad PIN too often
             2) the card is of a new and yet unknown type
          </result>
        </results>
      </command>

      <!-- Modify PIN -->
      <command name="IsoModifyPin_Ascii" >
        <send>
          <APDU >
            <ELEM type="word">0x0024</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="pid" type="byte" />
          </APDU>
          <DATA>
            <ELEM name="oldpin" type="bytes" size="8" filler="32" />
            <ELEM name="newpin" type="bytes" size="8" filler="32" />
          </DATA>
        </send>
        <results>
          <result sw1="0x63" sw2="0xc0" type="error" >
            Bad PIN (only one try left !)
          </result>
            <result sw1="0x63" type="error" >Bad PIN</result>
            <result sw1="0x63" sw2="0xc1" type="error" >
            Bad PIN (only two tries left !)
          </result>
            <result sw1="0x63" sw2="0xc2" type="error" >
            Bad PIN (only three tries left !)
          </result>
            <result sw1="0x69" sw2="0x83" type="error" >
            Card seems to be destroyed, this might have the following reasons:
             1) you entered a bad PIN too often
             2) the card is of a new and yet unknown type
          </result>
            <result sw1="0x69" sw2="0x85" type="error" >
            PIN is still initial PIN, please change it first.
          </result>
            <result sw1="0x6a" sw2="0x88" type="error" >
            Unknown PIN id.
          </result>
        </results>
      </command>

      
      <command name="IsoReadRecord" >
        <send>
          <APDU lr="0" >
            <ELEM type="word">0x00b2</ELEM>
            <ELEM name="recNum" type="byte" />
            <ELEM name="p2" type="byte" />
          </APDU>
        </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
         <result sw1="0x6a" sw2="0x83" type="error" >
           Record not found
         </result>
       </results>
        <responses>
          <response type="success">
            <ELEM name="data" type="bytes" />
          </response>
        </responses>
      </command>

      <command name="IsoUpdateRecord" >
        <send>
          <APDU >
            <ELEM type="word">0x00dc</ELEM>
            <ELEM name="recNum" type="byte" />
            <ELEM name="p2" type="byte" />
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
         <result sw1="0x6a" sw2="0x83" type="error" >
           Record not found
         </result>
       </results>
      </command>


<!--
      <command name="IsoWriteRecord" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoAppendRecord" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoUpdateRecord" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoSign" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoVerifyPin" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoModifyPin_Bin" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoModifyPin_Bcd" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoModifyPin_Ascii" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

      <command name="IsoModifyPin_Fpin2" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x11223344</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x1122</ELEM>
          </DATA>
        </send>
      </command>

    -->












      <!-- Select Master File -->
      <command name="SelectMF" >
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x00a40000</ELEM>
          </APDU>
          <DATA>
            <ELEM type="word">0x3f00</ELEM>
          </DATA>
        </send>
        <results>
          <result sw1="0x6a" sw2="0x82" type="error">File not found</result>
        </results>
        <responses>
          <response type="success">
            <ELEM name="fileInfo" type="tlv" tlvtype="simple" minnum="0">
              <tlv id="0x6f">
                <ELEM name="fci" type="tlv" tlvtype="simple"
                      maxnum="0">
                  <tlv id="0x81">
                    <ELEM name="space" type="word" />
                  </tlv>
                  <tlv id="0x82">
                    <ELEM name="fileDescr" type="bytes" />
                  </tlv>
                  <tlv id="0x83">
                    <ELEM name="shortFileId" type="word" />
                  </tlv>
                  <tlv id="0x84">
                    <ELEM name="fileName" type="bytes" />
                  </tlv>
                  <tlv id="0x85">
                    <ELEM name="sfi" type="byte" />
                    <ELEM name="filePath" type="bytes" />
                  </tlv>
                  <tlv id="0x86" name="AC" >
                    <ELEM name="AC_admin" type="word" />
                    <GROUP name="AC_cmd" minnum="0" maxnum="0" >
                      <ELEM name="cla" type="byte" />
                      <ELEM name="ins" type="byte" />
                      <ELEM name="ac" type="word" />
                    </GROUP>
                  </tlv>
                  <tlv id="0xa5">
                    <ELEM name="accessControl" type="tlv" tlvtype="simple"
                          maxnum="0">
                      <tlv id="0x86" name="AC" >
                        <ELEM name="sfi" type="byte" />
                        <ELEM name="AC_admin" type="word" />
                        <ELEM name="moreACs" type="bytes" minnum="0" />
                      </tlv>
                    </ELEM>
                  </tlv>
                </ELEM>
              </tlv>
            </ELEM>
          </response>
          
        </responses>
      </command>

      <!-- Read Binary -->
      <command name="ReadBinary" >
        <send>
          <APDU lr="0" >
            <ELEM type="word">0x00b0</ELEM>
            <ELEM name="offset" type="word" />
          </APDU>
        </send>
        <results>
          <result sw1="0x61" type="success" >
            Command executed, correct size in SW2
          </result>
          <result sw1="0x69" sw2="0x86" type="error" >
            No EF selected (internal error)
          </result>
        </results>
      </command>

      <!-- Write Binary -->
      <command name="WriteBinary" >
        <send>
          <APDU>
            <ELEM type="word">0x00d0</ELEM>
            <ELEM name="offset" type="word" />
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>
        <results>
          <result sw1="0x61" type="success" >
            Command executed, correct size in SW2
          </result>
          <result sw1="0x69" sw2="0x86" type="error" >
            No EF selected (internal error)
          </result>
        </results>
      </command>

      <!-- Update Binary -->
      <command name="UpdateBinary" >
        <send>
                <APDU>
                <ELEM type="word">0x00d6</ELEM>
            <ELEM name="offset" type="word" />
                </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
                </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
       </results>
        </command>

      <!-- Erase Binary -->
      <command name="EraseBinary" >
        <send>
                <APDU>
                <ELEM type="word">0x000e</ELEM>
            <ELEM name="offset" type="word" />
                </APDU>
          <DATA>
            <ELEM name="len" type="word" minnum="0" />
          </DATA>
                </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
       </results>
        </command>


      <!-- Read Record -->
      <command name="ReadRecord" >
        <send>
                <APDU lr="0" >
                <ELEM type="word">0x00b2</ELEM>
            <ELEM name="recNum" type="byte" />
            <ELEM type="byte">0x04</ELEM>
                </APDU>
                </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
         <result sw1="0x6a" sw2="0x83" type="error" >
           Record not found
         </result>
       </results>
        </command>

      <!-- Write Record -->
      <command name="WriteRecord" >
        <send>
                <APDU>
                <ELEM type="word">0x00dc</ELEM>
            <ELEM name="recNum" type="byte" />
            <ELEM name="p2" type="byte" />
                </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
                </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
         <result sw1="0x6a" sw2="0x83" type="error" >
           Record not found
         </result>
       </results>
        </command>

      <!-- Update Record -->
      <command name="UpdateRecord" >
        <send>
                <APDU>
                <ELEM type="word">0x00dc</ELEM>
            <ELEM name="recNum" type="byte" />
            <ELEM name="p2" type="byte" />
                </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
                </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
         <result sw1="0x6a" sw2="0x83" type="error" >
           Record not found
         </result>
       </results>
        </command>

      <!-- Append Record -->
      <command name="AppendRecord" >
        <send>
                <APDU>
                <ELEM type="word">0x00e2</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="p2" type="byte" />
                </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
                </send>
       <results>
         <result sw1="0x61" type="success" >
           Command executed, correct size in SW2
         </result>
         <result sw1="0x69" sw2="0x86" type="error" >
           No EF selected (internal error)
         </result>
         <result sw1="0x6a" sw2="0x83" type="error" >
           Record not found
         </result>
       </results>
        </command>

      <!-- Verify -->
      <command name="IsoVerifyPin" >
        <send>
                <APDU >
                <ELEM type="word">0x0020</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="pid" type="byte" />
                </APDU>
                <DATA>
                    <ELEM name="pin" type="bytes" />
                </DATA>
                </send>
                <results>
            <result sw1="0x63" sw2="0xc0" type="error" >
            Bad PIN (only one try left !)
          </result>
            <result sw1="0x63" type="error" >Bad PIN</result>
            <result sw1="0x63" sw2="0xc1" type="error" >
            Bad PIN (only two tries left !)
          </result>
            <result sw1="0x63" sw2="0xc2" type="error" >
            Bad PIN (only three tries left !)
          </result>
            <result sw1="0x69" sw2="0x83" type="error" >
            Card seems to be destroyed, this might have the following reasons:
             1) you entered a bad PIN too often
             2) the card is of a new and yet unknown type
          </result>
                </results>
      </command>




      <!-- Modify -->
      <command name="IsoModifyPin" >
        <send>
                <APDU >
                <ELEM type="word">0x0024</ELEM>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="pid" type="byte" />
                </APDU>
                <DATA>
                    <ELEM name="oldpin" type="bytes" />
                    <ELEM name="newpin" type="bytes" />
                </DATA>
                </send>
                <results>
            <result sw1="0x63" sw2="0xc0" type="error" >
            Bad PIN (only one try left !)
          </result>
            <result sw1="0x63" type="error" >Bad PIN</result>
            <result sw1="0x63" sw2="0xc1" type="error" >
            Bad PIN (only two tries left !)
          </result>
            <result sw1="0x63" sw2="0xc2" type="error" >
            Bad PIN (only three tries left !)
          </result>
            <result sw1="0x69" sw2="0x83" type="error" >
            Card seems to be destroyed, this might have the following reasons:
             1) you entered a bad PIN too often
             2) the card is of a new and yet unknown type
          </result>
                </results>
      </command>

      <!-- Manage SE -->
      <command name="IsoManageSE" >
        <DESCR>
          This command selects the public key, the private key and 
          the algorith to be used for padding/hashing.
        </DESCR>
        <send>
                <APDU >
            <ELEM type="word">0x0022</ELEM>
            <ELEM type="byte">0x41</ELEM>
            <ELEM name="template" type="byte">
              <DESCR>
                There are 3 templates:
                  0xa4: authenticate
                  0xb6: digital signature
                  0xb8: cipher
              </DESCR>
            </ELEM>
                </APDU>
                <DATA>
            <ELEM name="data" type="bytes" />
                </DATA>
                </send>

                <results>
            <result sw1="0x69" sw2="0x85" type="error" >
            Condition of use not satisfied (key algorithm).
          </result>
          <result sw1="0x6a" sw2="0x80" type="error" >
            Bad kid or algo.
          </result>
          <result sw1="0x6a" sw2="0x88" type="error" >
            Referenced data not found.
          </result>
          <result sw1="0x6f" sw2="0x01" type="error" >
            Public key not complete.
          </result>
          <result sw1="0x6f" sw2="0x0a" type="error" >
            Key format list does not match key length.
          </result>
                </results>
      </command>


      <!-- Encipher -->
      <command name="IsoEncipher" >
        <DESCR>
          This command enciphers the given data.
        </DESCR>
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x002a8680</ELEM>
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>

        <responses>
          <response type="success">
            <ELEM name="data" type="bytes" />
          </response>
        </responses>
      </command>

      <!-- Decipher -->
      <command name="IsoDecipher" >
        <DESCR>
          This command deciphers the given data.
        </DESCR>
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x002a8086</ELEM>
          </APDU>
          <DATA>
            <ELEM type="byte">0x00</ELEM>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>
	
        <responses>
          <response type="success">
            <ELEM name="data" type="bytes" />
          </response>
        </responses>
      </command>

      <!-- InternalAuth -->
      <command name="IsoInternalAuth" >
        <DESCR>
          This Internal authentication
        </DESCR>
        <send>
          <APDU lr="0" >
            <ELEM type="dword">0x00880000</ELEM>
            <!-- <ELEM type="dword">0x008800</ELEM>
		 <ELEM name="kid" type="byte" /> -->
          </APDU>
          <DATA>
            <ELEM name="data" type="bytes" />
          </DATA>
        </send>

        <responses>
          <response type="success">
            <ELEM name="data" type="bytes" />
          </response>
        </responses>
      </command>


    </commands>


    
    <!-- generic command responses -->
    <results>
      <!-- success -->
      <result sw1="0x90" type="success">
        Command successfully executed
      </result>
      <result sw1="0x61" type="success">
        Command executed, correct size in SW2
      </result>
      <result sw1="0x63" type="success" >
        Success after internal retries (see SW2 for number of retries)
      </result>

      <!-- errors -->
      <result sw1="0x64" sw2="0x00" type="error" >
        No precise diagnosis (no change on card)
      </result>
      <result sw1="0x65" sw2="0x81" type="error" >
        Memory failure (error while reading)
      </result>
      <result sw1="0x67" sw2="0x00" type="error" >
        Wrong APDU length (internal error)
      </result>
      <result sw1="0x67" sw2="0x81" type="error" >
        Response too long (internal error)
      </result>
      <result sw1="0x69" sw2="0x82" type="error" >
        Security status not satisfied (please verify E/G PIN before).
      </result>
      <result sw1="0x69" sw2="0x86" type="error" >
        Command not allowed (internal error)
      </result>
      <result sw1="0x6a" sw2="0x86" type="error" >
        Incorrect parameters in p1-p2 (internal error)
      </result>
      <result sw1="0x6d" sw2="0x00" type="error" >
        Wrong instruction code (internal error)
      </result>
      <result sw1="0x6e" sw2="0x00" type="error" >
        CLA not supported (internal error)
      </result>

      <result type="error">Unhandled error</result>
    </results>

  </card>
</cards>

