Beispiel #1
0
 /// <summary>
 /// Create a Credit Card class
 /// </summary>
 /// <param name="nfc">A compatible Card reader</param>
 /// <param name="target">The target number as some readers needs it</param>
 /// <param name="tailerSize">Size of the tailer, most NFC readers add an extra byte 0x00</param>
 /// <remarks>The target number can be found with the NFC/Card reader you are using. For example the PN532 require a target number,
 /// the normal smart card readers usually don't as they only support 1 card at a time.</remarks>
 public CreditCard(CardTransceiver nfc, byte target, int tailerSize = 3)
 {
     _nfc       = nfc;
     _target    = target;
     Tags       = new List <Tag>();
     LogEntries = new List <byte[]>();
     TailerSize = tailerSize;
 }
Beispiel #2
0
 /// <summary>
 /// Create a Credit Card class
 /// </summary>
 /// <param name="nfc">A compatible Card reader</param>
 /// <param name="target">The target number as some readers needs it</param>
 /// <param name="tailerSize">Size of the tailer, most NFC readers add an extra byte 0x00</param>
 /// <remarks>The target number can be found with the NFC/Card reader you are using. For example the PN532 require a target number,
 /// the normal smart card readers usually don't as they only support 1 card at a time.</remarks>
 public CreditCard(CardTransceiver nfc, byte target, int tailerSize = 3)
 {
     _nfc       = nfc;
     _target    = target;
     Tags       = new List <Tag>();
     LogEntries = new List <byte[]>();
     TailerSize = tailerSize;
     _logger    = this.GetCurrentClassLogger();
 }
Beispiel #3
0
 /// <summary>
 /// Constructor for Mifarecard
 /// </summary>
 /// <param name="rfid">A card transceiver class</param>
 /// <param name="target">The target number as some card readers attribute one</param>
 public MifareCard(CardTransceiver rfid, byte target)
 {
     _rfid   = rfid;
     Target  = target;
     _logger = this.GetCurrentClassLogger();
 }
Beispiel #4
0
 /// <summary>
 /// Constructor for Mifarecard
 /// </summary>
 /// <param name="rfid">A card transceiver class</param>
 /// <param name="target">The target number as some card readers attribute one</param>
 public MifareCard(CardTransceiver rfid, byte target)
 {
     _rfid  = rfid;
     Target = target;
 }
Beispiel #5
0
 /// <summary>
 /// Constructor for Ultralight
 /// </summary>
 /// <param name="rfid">A card transceiver class</param>
 /// <param name="target">The target number as some card readers attribute one</param>
 public UltralightCard(CardTransceiver rfid, byte target)
 {
     _logger = this.GetCurrentClassLogger();
     _rfid   = rfid;
     Target  = target;
     // Try to get the version, if not sucessful than it's one of the early model or C
     // See https://stackmirror.com/questions/37002498
     GetVersion();
     if ((Data != null) && (Data.Length == 8))
     {
         if ((Data[2] == 0x04) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0B))
         {
             NdefCapacity       = 48;
             UltralightCardType = UltralightCardType.UltralightNtag210;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0E))
         {
             NdefCapacity       = 128;
             UltralightCardType = UltralightCardType.UltralightNtag212;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0F))
         {
             NdefCapacity       = 144;
             UltralightCardType = UltralightCardType.UltralightNtag213;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x04) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0F))
         {
             NdefCapacity       = 144;
             UltralightCardType = UltralightCardType.UltralightNtag213F;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x11))
         {
             NdefCapacity       = 504;
             UltralightCardType = UltralightCardType.UltralightNtag215;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x13))
         {
             NdefCapacity       = 888;
             UltralightCardType = UltralightCardType.UltralightNtag216;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x04) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x13))
         {
             NdefCapacity       = 888;
             UltralightCardType = UltralightCardType.UltralightNtag216F;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x01) && (Data[6] == 0x13))
         {
             NdefCapacity       = 888;
             UltralightCardType = UltralightCardType.UltralightNtagI2cNT3H1101;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x05) && (Data[4] == 0x02) && (Data[5] == 0x01) && (Data[6] == 0x13))
         {
             NdefCapacity       = 888;
             UltralightCardType = UltralightCardType.UltralightNtagI2cNT3H1101W0;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x05) && (Data[4] == 0x02) && (Data[5] == 0x02) && (Data[6] == 0x13))
         {
             NdefCapacity       = 888;
             UltralightCardType = UltralightCardType.UltralightNtagI2cNT3H2111W0;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x01) && (Data[6] == 0x15))
         {
             NdefCapacity       = 1912;
             UltralightCardType = UltralightCardType.UltralightNtagI2cNT3H2101;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x05) && (Data[4] == 0x02) && (Data[5] == 0x01) && (Data[6] == 0x15))
         {
             NdefCapacity       = 1912;
             UltralightCardType = UltralightCardType.UltralightNtagI2cNT3H1201W0;
         }
         else if ((Data[2] == 0x04) && (Data[3] == 0x05) && (Data[4] == 0x02) && (Data[5] == 0x02) && (Data[6] == 0x15))
         {
             NdefCapacity       = 1912;
             UltralightCardType = UltralightCardType.UltralightNtagI2cNT3H2211W0;
         }
         else if ((Data[2] == 0x03) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0B))
         {
             NdefCapacity       = 48;
             UltralightCardType = UltralightCardType.UltralightEV1MF0UL1101;
         }
         else if ((Data[2] == 0x03) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0B))
         {
             NdefCapacity       = 48;
             UltralightCardType = UltralightCardType.UltralightEV1MF0ULH1101;
         }
         else if ((Data[2] == 0x03) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0E))
         {
             NdefCapacity       = 128;
             UltralightCardType = UltralightCardType.UltralightEV1MF0UL2101;
         }
         else if ((Data[2] == 0x03) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0E))
         {
             NdefCapacity       = 128;
             UltralightCardType = UltralightCardType.UltralightEV1MF0ULH2101;
         }
         else if ((Data[2] == 0x21) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x0E))
         {
             NdefCapacity       = 128;
             UltralightCardType = UltralightCardType.UltralightNtag203;
         }
         else
         {
             NdefCapacity = 1 << (Data[6] >> 1);
         }
     }
     else
     {
         // Check if AuthenticationPart1 returns something
         Command = UltralightCommand.ThreeDsAuthenticationPart1;
         var res = RunUltralightCommand();
         if (res > 0)
         {
             NdefCapacity       = 144;
             UltralightCardType = UltralightCardType.UltralightC;
         }
         else
         {
             // Then it's either a Ultralight or 203. Read block 41
             Command = UltralightCommand.Read16Bytes;
             res     = RunUltralightCommand();
             if (res > 0)
             {
                 NdefCapacity       = 137;
                 UltralightCardType = UltralightCardType.UltralightNtag203;
             }
             else
             {
                 NdefCapacity       = 144;
                 UltralightCardType = UltralightCardType.MifareUltralight;
             }
         }
     }
 }