OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Receiving 67 00 ("Wrong length") for INITIALIZE UPDATE on GlobalPlatform Java Card

  • Thread starter Thread starter Tuija Palovuori
  • Start date Start date
T

Tuija Palovuori

Guest
I am new to Java Card development, so I might not be correct in my statements, but I have at least tried to do my research.

I am trying to install an applet onto my smart card using a custom program which uses WinSCard for APDU communication (SCardTransmit function). This program was successful in installing applets for the previous card I used, which was a JavaCOS A22, but unsuccessful with my new card, which is an NXP J3H145. The error happens in the INITIALIZE UPDATE command, which returns the error code 67 00, or "Wrong length".

The sequence is the following:

  1. I select the card manager using a SELECT command. APDU: (CLA) 00 (INS) A4 (P1) 04 (P2) 00 (Lc) 00. (Note: I am aware that the data field is empty instead of specifying an AID, but for some reason this seems to be able to select the card manager by default (correct AID highlighted in response) while specifying the card manager specifically leads to an odd response with code 90 00 but no data.)
  2. I receive a response from the card, which shows that the card manager has been selected. APDU: (Data) 6F 10 84 08 A0 00 00 01 51 00 00 00 A5 04 9F 65 01 FF (SW1) 90 (SW2) 00.
  3. I send an INITIALIZE UPDATE command to the card. The host challenge is randomly generated and 8 bytes long. APDU: (CLA) 80 (INS ) 50 (PI) 00 (P2) 00 (Lc) 08 (Data) FE 6E CE 4A 85 55 C3 DE.
  4. I receive a response from the card, which is an error. APDU: (SW1) 67 (SW2) 00.

There are no commands preceding these commands.

Now, "wrong length" sounds like it could be talking about the Lc or the Le, which you may notice is not present in either of my commands.

Lc I have triple-checked to be correct. Its value is set directly with the length of the byte array that is sent as data.

Le I have tried to append to the APDU's data field (where I understand it should go) with several different values: 00 (as the GlobalPlatform Card Specification 2.2.1 says it should be (E.5.1.2)), 20 (32 in decimal, the maximum length of the INITIALIZE UPDATE response in bytes according to SCP03's specification (7.1.1.6)) and FF (maximum value), but the error message is still the same (67 00, "Wrong length").

I also happen to have another one of these new cards, so I have tested it as well, and it behaves the same way.

I also tried sending the SELECT command twice to see if the second APDU was always failing (I have heard that this happens sometimes), but it was successful, and the INITIALIZE UPDATE command after that was still unsuccessful the same way.

I have also sent different length host challenges in case the challenge is not supposed to be the 8 bytes that the GlobalPlatform Card Specification specifies. The lengths I tried were 16, 32, 64, 4, 6, 7, 9, 10 and 12, but they all resulted in the same "wrong length" error.

Hopefully there's some kind of answer to this. I've been at this for quite a while. Thank you for your time.
<p>I am new to Java Card development, so I might not be correct in my statements, but I have at least tried to do my research.</p>
<p>I am trying to install an applet onto my smart card using a custom program which uses WinSCard for APDU communication (SCardTransmit function). This program was successful in installing applets for the previous card I used, which was a <a href="https://www.smartcardfocus.com/shop/ilp/id~712/javacos-a22-dual-interface-java-card-150k/p/" rel="nofollow noreferrer">JavaCOS A22</a>, but unsuccessful with my new card, which is an <a href="https://www.cardlogix.com/product/nxp-jcop3-j2h145-java-card-145k/" rel="nofollow noreferrer">NXP J3H145</a>. The error happens in the INITIALIZE UPDATE command, which returns the error code 67 00, or "Wrong length".</p>
<p>The sequence is the following:</p>
<ol>
<li>I select the card manager using a SELECT command. <strong>APDU:</strong> (CLA) 00 (INS) A4 (P1) 04 (P2) 00 (Lc) 00. (Note: I am aware that the data field is empty instead of specifying an AID, but for some reason this seems to be able to select the card manager by default (correct AID highlighted in response) while specifying the card manager specifically leads to an odd response with code 90 00 but no data.)</li>
<li>I receive a response from the card, which shows that the card manager has been selected. <strong>APDU:</strong> (Data) 6F 10 84 08 <strong>A0 00 00 01 51 00 00 00</strong> A5 04 9F 65 01 FF (SW1) 90 (SW2) 00.</li>
<li>I send an INITIALIZE UPDATE command to the card. The host challenge is randomly generated and 8 bytes long. <strong>APDU:</strong> (CLA) 80 (INS ) 50 (PI) 00 (P2) 00 (Lc) 08 (Data) FE 6E CE 4A 85 55 C3 DE.</li>
<li>I receive a response from the card, which is an error. <strong>APDU:</strong> (SW1) 67 (SW2) 00.</li>
</ol>
<p>There are no commands preceding these commands.</p>
<p>Now, "wrong length" sounds like it could be talking about the Lc or the Le, which you may notice is not present in either of my commands.</p>
<p>Lc I have triple-checked to be correct. Its value is set directly with the length of the byte array that is sent as data.</p>
<p>Le I have tried to append to the APDU's data field (where I understand it should go) with several different values: 00 (as the <a href="https://www.pdf-archive.com/2017/06/09/gpc-specification-2-2-1/gpc-specification-2-2-1.pdf" rel="nofollow noreferrer">GlobalPlatform Card Specification 2.2.1</a> says it should be (E.5.1.2)), 20 (32 in decimal, the maximum length of the INITIALIZE UPDATE response in bytes according to <a href="https://globalplatform.org/wp-content/uploads/2014/07/GPC_2.3_D_SCP03_v1.1.2_PublicRelease.pdf" rel="nofollow noreferrer">SCP03's specification</a> (7.1.1.6)) and FF (maximum value), but the error message is still the same (67 00, "Wrong length").</p>
<p>I also happen to have another one of these new cards, so I have tested it as well, and it behaves the same way.</p>
<p>I also tried sending the SELECT command twice to see if the second APDU was always failing (I have heard that this happens sometimes), but it was successful, and the INITIALIZE UPDATE command after that was still unsuccessful the same way.</p>
<p>I have also sent different length host challenges in case the challenge is not supposed to be the 8 bytes that the GlobalPlatform Card Specification specifies. The lengths I tried were 16, 32, 64, 4, 6, 7, 9, 10 and 12, but they all resulted in the same "wrong length" error.</p>
<p>Hopefully there's some kind of answer to this. I've been at this for quite a while. Thank you for your time.</p>
I have found how to fix this.
 

Latest posts

U
Replies
0
Views
1
user2774120
U
P
Replies
0
Views
1
Pramod Karandikar
P
Top