pátek 5. prosince 2014

Reading of Smart Cards on Apple iOS devices - Part 1


In this tutorial, I would like to show you, how to read data from smart cards using iOS devices. First, what we need is to connect our iPhone / iPad with hardware device for reading smart cards and SDK to develop our own application. We have used PKard Reader from Thursby Software which is available in several form factors. 

Thursby Software's PKard Reader support the major standard smart card formats including PIV and PIV-I smart cards, the CAC / CAC Dual Persona (
Common Access Card) used by the U.S. military and DOD (Department of Defense).




Using Thursby's PKard Reader and PKard Toolkit for iOS, we can start reading data from smart card. I will show you how to read data from smart card's "Printed information", "CHUID" and get image data from "Facial Image".


Printed information

















// Printed Infromation
TSS_PKI_Data *printedInfo = [TSS_PKI_Data dataObjectWithName:@"Printed Information"];
        
if (printedInfo) {
            
  NSData *nameData = [printedInfo dataWithBerTlvTag:1];
  NSString *name = [[NSString alloc] initWithData:nameData encoding:NSUTF8StringEncoding];
  
  // other tags 
  NSData *employeeAffiliationData = [printedInfo dataWithBerTlvTag:2];
  NSData *expirationDateData = [printedInfo dataWithBerTlvTag:4];
  NSData *agencyCardSerialNumberData = [printedInfo dataWithBerTlvTag:5];
  NSData *issuerIdentificationData = [printedInfo dataWithBerTlvTag:6];
  NSData *organizationAffiliation1Data = [printedInfo dataWithBerTlvTag:7];
  NSData *organizationAffiliation2Data = [printedInfo dataWithBerTlvTag:8];
}


Facial image

If you need to get facial image data, you can do it like this:

// Facial image
NSData *facialImageData = nil;
TSS_PKI_Data *pkiFacialImageData = [TSS_PKI_Data dataObjectWithName:@"Facial Image"];
if (pkiFacialImageData) {
   NSData *cbeffData = [pkiFacialImageData cbeffData];
   
   if (cbeffData) {
      NistBiometricExchangeFormat *cbeff = [[NistBiometricExchangeFormat alloc] initWithCBEFFData:cbeffData];
      facialImageData = cbeff.jpeg;
   }
}

You can find sample project which is included in PKard Toolkit. In case, there are things you are not able to find in documentation, ask Thursby for the answer. Their support works great.

Next part we will read data from "CHUID" especially reading and formating FASC-N, GUID and from X509 extension Authority Key Identifier. 
 


Žádné komentáře:

Okomentovat