Reputation: 191
I am trying to verify and change pin of gemalto .net card using c#. But when i tried to verify, using -
byte cla_verify = 0;
byte p2_pinReference = 0x80;
CardCommandAPDU quickVerify = new CardCommandAPDU(cla_verify, 0x20, 0x00, p2_pinReference, CardHex.ToByteArray("FFFFFFFFFFFFFFFF"));
CardResponseAPDU aRespAPDU = aCard.SendCommand(quickVerify);
it is returning -SW 27033 (RSP 6999)
.
Any idea. Whats wrong I am doing?
Upvotes: 1
Views: 2902
Reputation: 590
You want to verify PIN sending APDU, right. Lookup for document IDPrime .NET Smart Card - Integration Guide (APDU Encoding and Hivecodes). According to this document APDU for method verifyPIN (see Table 16 - Hivecodes for V5) should looks like this (example for role USER = 0x01 and PIN=1234) for:
80C200001BD800056F00C04B4E7FBD506B00044D53434D010000000431323334
Explanation:
APDU = APDU Header + APDU Payload
APDU Header is equal 80C20000 1B where:
APDU Payload is equal D8 0005 6F 00C04B4E 7FBD 506B 0004 4D53434D 01 00000004 31323334 where:
If PIN is correct You should get 9000 in response.
Another example for PIN = 12345:
80C200001CD800056F00C04B4E7FBD506B00044D53434D01000000053132333435
Upvotes: 0
Reputation: 4504
PIN verification is explained here. You can try this code instead of yours. Looks good to me.
Upvotes: 0
Reputation: 5333
Note, that while your PIN reference states a specific reference, the identifier zero from P2 means: "card shall know the addressed PIN". This may require additional previously sent commands like Manage Security ENvironment in the SET mode, or a certain security environment object or similar. Especially for the following Change Reference Data I would recommend to state the ID explicitly.
Upvotes: 1
Reputation: 4047
Status Word 69XX
means: Command not allowed.
I have looked at NETSmartcardFramework.chm provided inside the NET Smartcard Framework SDK. There is no clue what CLA, INS, P1, dan P2, and Lc to be used. Instead, the PIN verification is already wrapped into PIN Class.
To verify a PIN value you can use
// PIN Class members
// PIN.Verify Method
public void Verify(byte[],int,int);
public void Verify(string);
But before that you need to initialize the PIN using constructor PIN(byte[],int,int,int)
or PIN(string,int)
and do checking if the PIN isBlocked()
or isVerified()
.
Some interesting articles and guides:
Upvotes: 1