2

By using WinsCard.dll, I want to use APDU commands to reset PIN code and set a new into the smartcard. But when I launch these commands, I obtain error "67 00" ("Wrong length").

My APDU commands:

// First command, I verify the code PUK (return "90 00")
00 20 00 02 08 36 35 32 34 39 38 37 36  
// Second command, I try to set a new code PIN into the card
00 2C 03 01 0C 36 35 32 34 39 38 37 36 31 32 33 34

For second command:

36 35 32 34 39 38 37 36 -> code PUK
31 32 33 34 -> new code PIN

After some searches, the only explanation that I have found is that the "Lc" parameter was wrong. But, in my case, it is equal to "0C", and the length of my data is "0C".

So, I don't understand where is my error.

Have you got an idea?

Thank you very much for your help!

Note: If I reset the code PIN without put a new PIN (it restores previous code PIN), it works fine:

00 20 00 02 08 31 38 39 30 31 36 39 32
// Reset code PIN
00 2C 03 01 00
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
Amatukami
  • 93
  • 1
  • 7

2 Answers2

1

Using the RESET RETRY COUNTER command (INS = 0x2C) with P1 = 0x03 means that you want to reset the retry counter without setting new reference data (i.e. a new PIN). If you want to set new reference data (a new PIN) when resetting the retry counter, you could try (depending on what your card supports)

  • P1 = 0x00 (for the format you tried):

    00 2C 00 01 0C 36 35 32 34 39 38 37 36 31 32 33 34
    
  • P1 = 0x02 (only the new reference data is sent):

    00 2C 02 01 04 31 32 33 34
    
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • I have tried and it works perfectly ! Thank you very much for your held! – Amatukami Oct 21 '14 at 15:17
  • How did this ever worked? I tried all of your commands, and they all return '6A86' or '6A88'. According to the NIST specification section 3.2.3, you are supposed to set P2 to '80' no? http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-73-4.pdf – codenamezero Jan 02 '17 at 19:55
  • @codenamezero Parameter P2 is the PIN reference number, so this value (just as the format specified in P1 and the size of the PIN/PUK fields) may vary depending on the actual implementation and the used PINs. Just that these specific parameters worked for the OP does not mean that this would work unmodified for all cards/applications. – Michael Roland Jan 03 '17 at 02:16
  • @MichaelRoland ah.. so the card OP tries to deal with is not ISO7816... – codenamezero Jan 03 '17 at 18:22
  • @codenamezero It certainly is, but the ISO standard is a whole framework of which cards typically only support a limited subset. In case of the value of P2 it's even a bit more complicated since the value of P2 is application specific. – Michael Roland Jan 03 '17 at 19:08
0

Your length should be 0x10. Plz refer below example: A0 2C 00 01 10 3636303535333132 31323334 FFFFFFFF

Command : A0 2C 00 01 10 Input Data : 36 36 30 35 35 33 31 32 31 32 33 34 FF FF FF FF
Output Data : none Status : 90 00

here 3636303535333132 is unblock key and 31323334 is new pin