Beispiel #1
0
        public bool Authenticate(byte msb, byte lsb, KeyType keyType, byte keyNumber)
        {
            var authBlock = new GeneralAuthenticate {
                MSB       = msb,
                LSB       = lsb,
                KeyNumber = keyNumber,
                KeyType   = keyType
            };

            var authKeyCmd = new CommandApdu(IsoCase.Case3Short, SCardProtocol.Any)
            {
                CLA         = CUSTOM_CLA,
                Instruction = InstructionCode.InternalAuthenticate,
                P1          = 0x00,
                P2          = 0x00,
                Data        = authBlock.ToArray()
            };

            Debug.WriteLine("General Authenticate: {0}", BitConverter.ToString(authKeyCmd.ToArray()));
            var response = _isoReader.Transmit(authKeyCmd);

            Debug.WriteLine("SW1 SW2 = {0:X2} {1:X2}", response.SW1, response.SW2);

            return((response.SW1 == 0x90) && (response.SW2 == 0x00));
        }
Beispiel #2
0
        public bool Authenticate(int msb, int lsb, KeyType keyType, int keyNumber) {
            unchecked {
                var authBlock = new GeneralAuthenticate {
                    MSB = (byte)msb,
                    LSB = (byte)lsb,
                    KeyNumber = (byte)keyNumber,
                    KeyType = keyType
                };

                var authKeyCmd = new CommandApdu(IsoCase.Case3Short, SCardProtocol.Any) {
                    CLA = 0xFF,
                    Instruction = InstructionCode.InternalAuthenticate,
                    P1 = 0x00,
                    P2 = 0x00,
                    Data = authBlock.ToArray()
                };

                Debug.WriteLine(string.Format("General Authenticate: {0}", BitConverter.ToString(authKeyCmd.ToArray())));
                var response = _isoReader.Transmit(authKeyCmd);
                Debug.WriteLine(string.Format("SW1 SW2 = {0:X2} {1:X2}", response.SW1, response.SW2));

                return (response.SW1 == 0x90) && (response.SW2 == 0x00);
            }
        }