I have a Grabba smart card reader. I am trying to get card information with APDU commands. I have read a lot about EMV standards and related ISO 7816-4 standard but I am not able to execute simple select command with success. Here is some details:
I have successfully powered my VISA card and get its attributes:
NSError *error = nil;
GRGrabbaSmartcardSession *session = [GRGrabba.sharedGrabba.smartcard startSession:&error];
NSLog(@"EMV : smartCardInsertedEvent : Attribute : %@", [session getATR]);
Result: 3b690000 8072a445 6400ff00 10
When I parse this attribute on here I get this information for my card:
My contactless card is a credit card from Akbank from Turkey but it is listed as a Denizbank card from Turkey in this list.
Now I am tring to run a select command on card like this:
NSError *error = nil;
GRGrabbaSmartcardSession *session = [GRGrabba.sharedGrabba.smartcard startSession:&error];
NSLog(@"EMV : smartCardInsertedEvent : Attribute : %@", [session getATR]);
session.protocol = 1;
uint8_t aid[] = {'2', 'P', 'A', 'Y', '.', 'S', 'Y', 'S', '.', 'D', 'D', 'F', '0', '1'};
NSData *data = [NSData dataWithBytes:aid length:sizeof(aid)];
NSError *err = nil;
GRGrabbaCommandAPDU *apduCMD =
[[GRGrabbaCommandAPDU alloc]
initWithCLA:0x00
INS:0xA4
P1:0x04
P2:0x00
Data:data
Le:0x00
Error:&err];
GRGrabbaResponseAPDU *response = [[GRGrabbaResponseAPDU alloc] initWithData:nil SW1:0 SW2:0];
BOOL success = [session exchangeAPDUCommand:apduCMD withResponse:response error:&error];
if (!success) {
NSLog(@"EMV : smartCardInsertedEvent : ERROR: Could not read ADF");
return;
}
But it is failing with could not read ADF error. Can anyone show me what am I doing wrong?
UPDATE:
I have tried following combinations but still not able to run select command with success:
PROTOCOL DATA CLA LE STATUS
0 1PAY.SYS.DDF01 0x00 - unrecognised SW in response: SW1 = 61, SW2 = 52
0 1PAY.SYS.DDF01 0x00 0x00 Smartcard protocol error.
0 2PAY.SYS.DDF01 0x00 - unrecognised SW in response: SW1 = 61, SW2 = 66
0 2PAY.SYS.DDF01 0x00 0x00 Smartcard protocol error.
0 1PAY.SYS.DDF01 0x80 - card returned Incorrect application CLA - SW1 = 6E, SW2 = 00
0 1PAY.SYS.DDF01 0x80 0x00 card returned Incorrect application CLA - SW1 = 6E, SW2 = 00
0 2PAY.SYS.DDF01 0x80 - card returned Incorrect application CLA - SW1 = 6E, SW2 = 00
0 2PAY.SYS.DDF01 0x80 0x00 card returned Incorrect application CLA - SW1 = 6E, SW2 = 00
1 1PAY.SYS.DDF01 0x00 - unrecognised SW in response: SW1 = 00, SW2 = 00
1 1PAY.SYS.DDF01 0x00 0x00 unrecognised SW in response: SW1 = 00, SW2 = 00
1 2PAY.SYS.DDF01 0x00 - unrecognised SW in response: SW1 = 00, SW2 = 00
1 2PAY.SYS.DDF01 0x00 0x00 unrecognised SW in response: SW1 = 00, SW2 = 00
1 1PAY.SYS.DDF01 0x80 - unrecognised SW in response: SW1 = 00, SW2 = 00
1 1PAY.SYS.DDF01 0x80 0x00 unrecognised SW in response: SW1 = 00, SW2 = 00
1 2PAY.SYS.DDF01 0x80 - unrecognised SW in response: SW1 = 00, SW2 = 00
1 2PAY.SYS.DDF01 0x80 0x00 unrecognised SW in response: SW1 = 00, SW2 = 00