Esempio n. 1
0
        public void GeneralAuthenticate(ushort address, GeneralAuthenticateKeyType keyType, byte keyIndex)
        {
            const int AuthenticateDataLen = 5;

            CApdu command = new CApdu();

            command.Cla = CLA;
            command.Ins = INSGeneralAuthenticate;
            command.P1  = 0x00; // Always null
            command.P2  = 0x00; // Always null

            byte[] data = new byte[AuthenticateDataLen];
            data[0] = 0x01; // Static version
            data[1] = (byte)(address >> 8);
            data[2] = (byte)(address & 0xFF);
            data[3] = (byte)keyType;
            data[4] = 0;

            command.Data = data;

            RApdu response = myProtocol.Transceive(command);

            // Validate the response,
            if (response.IsError)
            {
                throw response.ThrowBySW("GeneralAuthenticate");
            }
        }
 public GeneralAuthenticate(ushort address, byte keySlotNumber, GeneralAuthenticateKeyType keyType)
     : base(GeneralAuthenticateVersionNumber.VersionOne, address, keyType, keySlotNumber)
 {
     if (keyType != GeneralAuthenticateKeyType.MifareKeyA && keyType != GeneralAuthenticateKeyType.PicoTagPassKeyB)
     {
         throw new Exception("Invalid key type for MIFARE Standard General Authenticate");
     }
 }
Esempio n. 3
0
 public GeneralAuthenticate(ushort address, byte keySlotNumber, GeneralAuthenticateKeyType keyType)
     : base(GeneralAuthenticateVersionNumber.VersionOne, address, keyType, keySlotNumber)
 {
     if (keyType != GeneralAuthenticateKeyType.MifareKeyA && keyType != GeneralAuthenticateKeyType.PicoTagPassKeyB)
     {
         throw new Exception("Invalid key type for MIFARE Standard General Authenticate");
     }
 }
Esempio n. 4
0
 public GeneralAuthenticate(GeneralAuthenticateVersionNumber version, ushort address, GeneralAuthenticateKeyType keyType, byte keyNo)
     : base((byte)Iso7816.Cla.ReservedForPts, (byte)Pcsc.Ins.GeneralAuthenticate, 0, 0, new byte[5] { (byte)version, (byte)(address >> 8), (byte)(address & 0x00FF), (byte)keyType, keyNo }, null)
 {
 }
Esempio n. 5
0
 public GeneralAuthenticate(GeneralAuthenticateVersionNumber version, ushort address, GeneralAuthenticateKeyType keyType, byte keyNo)
     : base((byte)Iso7816.Cla.ReservedForPts, (byte)Pcsc.Ins.GeneralAuthenticate, 0, 0, new byte[5] {
     (byte)version, (byte)(address >> 8), (byte)(address & 0x00FF), (byte)keyType, keyNo
 }, null)
 {
 }