Page 1 of 1

About generateAsymetricKey() function

Posted: Tue Dec 15, 2015 5:32 am
by bigWhite
From the source code, generateAsymetricKey()function is to generate three types KEY pairs, and the types of key pairs are:
signatureKey, confidentialityKey and authenticationKey.

But, when I send APDU, only signatureKey (OFFSET_CDATA, is 0xB6) generated successfully, the others all returned 0x6A82.
WHY???

My sending APDU commands are:

Code: Select all

>> 00 20 00 82 06 31 32 33 34 35 36
<< 90 00

>> 00 20 00 83 08 31 32 33 34 35 36 37 38
<< 90 00

>> 00 20 00 83 08 31 32 33 34 35 36 37 38
<< 90 00

>> 80 47 81 00 01 B8
<< 6A 82   File or application not found

>> 80 47 81 00 01 B6
<< 7F 49 82 01 09 82 03 01 00 01 81 82 01 00 61 00   Response bytes remaining

>> 00 C0 00 00
<< 90 00

>> 80 47 81 00 01 A4
<< 6A 82   File or application not found


Re: About generateAsymetricKey() function

Posted: Wed Dec 16, 2015 5:51 am
by predators
While sending APDU command, the P1 of your incoming APDU is 0x81,

Code: Select all

if (buffer[ISO7816.OFFSET_P1] == (byte) 0x81) {
      if (!(key.getPublic()).isInitialized()) {
        ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
      }
    }
   

From the code, it will check the KEY isInitialized(), Maybe the corresponding Key is not initialized.

And I debug this applet, after I select the applet and verify the PIN1, PIN3, I send the APDU is "8047810001 KeyTypes", no matter what key types, the response APDU are all 0x6A82.