Howdy.

I need help.  Please and thank you.

I have an application that does the following:
- erases the card
- provides credentials
- creates a few files
- attempts to write to a file by doing:
     - (a) read to confirm zeros
     - (b) write data
     - (c) read to confirm data written correctly.


The problem is that when I read the data I have written, it's not always the same.

I'm trying to write to and confirm the write to a smart card (GPK8000) in java and using OCF1.2 and your gpk et al. 

Here's a transcript of a specific set of APDU commands being issued.  See below for the full transcript. (I modified the java code to print commands and responses)

<-------snip-------->

Writing 60 bytes to offset 300.
executeCommand : APDU Command is as follows :
00 D0 00 4B 3C 97 EA 24 67 6B 49 FE F4 86 97 2E
72 BB 3E C8 A0 4F 3E 59 6B F8 2E 53 C2 F6 14 DC
B2 CF AF 42 CC 83 65 40 08 F3 D6 90 C9 12 42 7D
20 7E 30 69 E9 A7 19 54 63 40 22 C9 95 3B 98 AE
BB
executeCommand : response from internalSendCommandAPDU:
90 00

Reading 60 bytes from offset 300.
executeCommand : APDU Command is as follows :
00 B0 00 4B 3C
executeCommand : response from internalSendCommandAPDU:
97 EA 2F*67 6B 4D*FF*FE*86 97 2F*73*BF*3E CC*A2*
4F 7F*7B*FF*FC*FE*F3*F6*F7*36*FD*B7*CF FF*FE*CD*
C7*FD*46*A8*F7*FF*9F*EB*D3*57*FD*76*7E 71*F9*FD*
FF*BD*5D*E7*FA*AA*EF*DD*BB*9A*AE BF*

<-------snip-------->

Look closely at the dumped response and compare to the write ADPU command.  Any bytes read with an * after them are *not* the same as the bytes written.  There is more going on for this program, and I have a lot more results and tests but typing them would be a very long process.  I will include below the entire transcript of the session I made.  Do you have *any idea* why the read data would be different than the written data?

Any help would  be *greatly* appreciated.  If you want I can describe the problem on the phone, which would be a lot faster je pense.

-- Sean



----------------------------------------------------

notes:
- any time a comparison is done, the bytes that do not match will be suffixed with an asterisk.
- the internalSendCommandAPDU was modified to print the command and response.
- In this example I loop 7 times with 60 byte blocks.  The results are similar if I try to write it all at once, or if I try to use a different block size.
- I am confident there is no problem with my code (which I can provide if you want) because if I replace the data in the writeBuffer variable (the variable that holds the certificate read from disk) with a pattern (i.e. 0x55AA55AA) everything will write and read successfully.
- I have noticed some problems in the GPK code where the data block size is hard-coded to 4, or returns 4 even if it is 1.
- I have noticed some other problems where calling write is actually doing an update.  For example if I call write with a buffer full of 0xAA, then write with a buffer full of 0x55 on the same location in the file, then read, the results will be 0xFF.  I was under the impression that *writing* overwrote and *updating* did a binary OR on the data.  Am I mistaken?
- I have noticed other problems and other results for similar attempts on trying to write to the card.
- In this example the first 300 bytes are written and read successfully, but after that things screw up.
- The file created on the smart card was created large enough.
- If I offset everything by at least 272 bytes (e.g. start to write data at offset 272 in the file instead of offset 0) everything will be written and verified correctly.
- There's a lot more notes...

and the dump:


--------------------------------

Starting smartcard
Creating CardRequest
Waiting for card

Certificate Size : 1177
Data Unit Size   : 4
Max Session Key  : 64
isGPK8000        : true
isStandardCard   : false

Erase Card
executeCommand : APDU Command is as follows :
DB DE 00 00
executeCommand : response from internalSendCommandAPDU:
90 00

Getting Info (04)
executeCommand : APDU Command is as follows :
80 C0 02 A4 0D
executeCommand : response from internalSendCommandAPDU:
A2 08 01 01 52 00 FF 00 10 05 FF 86 86 90 00

Creating DF :3F00:D000
executeCommand : APDU Command is as follows :
80 E0 01 00 0C D0 00 38 00 00 00 00 00 00 00 00
00
executeCommand : response from internalSendCommandAPDU:
2F D3 12 90 00
Creating EF :3F00:D000:D001
executeCommand : APDU Command is as follows :
80 E0 02 00 0C D0 01 01 00 04 99 00 00 00 00 00
00
executeCommand : response from internalSendCommandAPDU:
90 00

Writing to :3F00:D000:D001
Reading 60 bytes from 0.
executeCommand : APDU Command is as follows :
00 B0 00 00 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 0.
executeCommand : APDU Command is as follows :
00 D0 00 00 3C FE ED FE ED 00 00 00 02 00 00 00
01 00 00 00 01 00 08 62 75 73 69 6E 65 73 73 00
00 00 E5 24 0F 91 D7 00 00 01 8F 30 82 01 8B 30
0E 06 0A 2B 06 01 04 01 2A 02 11 01 01 05 00 04
82
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 0.
executeCommand : APDU Command is as follows :
00 B0 00 00 3C
executeCommand : response from internalSendCommandAPDU:
FE ED FE ED 00 00 00 02 00 00 00 01 00 00 00 01
00 08 62 75 73 69 6E 65 73 73 00 00 00 E5 24 0F
91 D7 00 00 01 8F 30 82 01 8B 30 0E 06 0A 2B 06
01 04 01 2A 02 11 01 01 05 00 04 82 90 00
Comping 60 bytes from 0:
------Read Data--------------------------------       ------Original Data----------------------------
FE ED FE ED 00 00 00 02 00 00 00 01 00 00 00 01  ---  FE ED FE ED 00 00 00 02 00 00 00 01 00 00 00 01
00 08 62 75 73 69 6E 65 73 73 00 00 00 E5 24 0F  ---  00 08 62 75 73 69 6E 65 73 73 00 00 00 E5 24 0F
91 D7 00 00 01 8F 30 82 01 8B 30 0E 06 0A 2B 06  ---  91 D7 00 00 01 8F 30 82 01 8B 30 0E 06 0A 2B 06
01 04 01 2A 02 11 01 01 05 00 04 82              ---  01 04 01 2A 02 11 01 01 05 00 04 82

Reading 60 bytes from 60.
executeCommand : APDU Command is as follows :
00 B0 00 0F 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 60.
executeCommand : APDU Command is as follows :
00 D0 00 0F 3C 01 77 73 DE DC FA F0 F6 27 32 3D
85 85 57 FC 05 47 D8 06 A8 97 BF 8F AA C3 15 85
76 3A 41 D1 95 FB BD 49 87 BA A8 E6 DC 98 92 84
BF 65 66 DC F6 97 BC 89 AF D4 77 54 9C AE 0C D8
9E
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 60.
executeCommand : APDU Command is as follows :
00 B0 00 0F 3C
executeCommand : response from internalSendCommandAPDU:
01 77 73 DE DC FA F0 F6 27 32 3D 85 85 57 FC 05
47 D8 06 A8 97 BF 8F AA C3 15 85 76 3A 41 D1 95
FB BD 49 87 BA A8 E6 DC 98 92 84 BF 65 66 DC F6
97 BC 89 AF D4 77 54 9C AE 0C D8 9E 90 00
Comping 60 bytes from 60:
------Read Data--------------------------------       ------Original Data----------------------------
01 77 73 DE DC FA F0 F6 27 32 3D 85 85 57 FC 05  ---  01 77 73 DE DC FA F0 F6 27 32 3D 85 85 57 FC 05
47 D8 06 A8 97 BF 8F AA C3 15 85 76 3A 41 D1 95  ---  47 D8 06 A8 97 BF 8F AA C3 15 85 76 3A 41 D1 95
FB BD 49 87 BA A8 E6 DC 98 92 84 BF 65 66 DC F6  ---  FB BD 49 87 BA A8 E6 DC 98 92 84 BF 65 66 DC F6
97 BC 89 AF D4 77 54 9C AE 0C D8 9E              ---  97 BC 89 AF D4 77 54 9C AE 0C D8 9E

Reading 60 bytes from 120.
executeCommand : APDU Command is as follows :
00 B0 00 1E 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 120.
executeCommand : APDU Command is as follows :
00 D0 00 1E 3C 24 AB A3 2D FE 1D B5 7A 3F 66 75
D7 E9 52 7E C8 92 E2 F7 A6 13 BF 6D 85 6C 0C 5B
90 C5 66 F1 41 7B EF F2 B8 02 F6 42 CB C5 A9 CE
2A 87 FE FA 2C 9E 4C 41 3B 16 D2 3E A3 51 8E 0B
0E
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 120.
executeCommand : APDU Command is as follows :
00 B0 00 1E 3C
executeCommand : response from internalSendCommandAPDU:
24 AB A3 2D FE 1D B5 7A 3F 66 75 D7 E9 52 7E C8
92 E2 F7 A6 13 BF 6D 85 6C 0C 5B 90 C5 66 F1 41
7B EF F2 B8 02 F6 42 CB C5 A9 CE 2A 87 FE FA 2C
9E 4C 41 3B 16 D2 3E A3 51 8E 0B 0E 90 00
Comping 60 bytes from 120:
------Read Data--------------------------------       ------Original Data----------------------------
24 AB A3 2D FE 1D B5 7A 3F 66 75 D7 E9 52 7E C8  ---  24 AB A3 2D FE 1D B5 7A 3F 66 75 D7 E9 52 7E C8
92 E2 F7 A6 13 BF 6D 85 6C 0C 5B 90 C5 66 F1 41  ---  92 E2 F7 A6 13 BF 6D 85 6C 0C 5B 90 C5 66 F1 41
7B EF F2 B8 02 F6 42 CB C5 A9 CE 2A 87 FE FA 2C  ---  7B EF F2 B8 02 F6 42 CB C5 A9 CE 2A 87 FE FA 2C
9E 4C 41 3B 16 D2 3E A3 51 8E 0B 0E              ---  9E 4C 41 3B 16 D2 3E A3 51 8E 0B 0E

Reading 60 bytes from 180.
executeCommand : APDU Command is as follows :
00 B0 00 2D 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 180.
executeCommand : APDU Command is as follows :
00 D0 00 2D 3C AF C5 84 BD 31 42 4F 7A 18 F7 7B
00 00 F4 95 FB D1 A7 36 AB A6 44 2C 9C FB 5E E9
78 E7 52 61 45 2C E6 1E A1 8A A3 84 6A 87 C9 68
4A 5B 0D 20 2F 31 30 35 07 F1 BE CF 56 5B CC CC
22
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 180.
executeCommand : APDU Command is as follows :
00 B0 00 2D 3C
executeCommand : response from internalSendCommandAPDU:
AF C5 84 BD 31 42 4F 7A 18 F7 7B 00 00 F4 95 FB
D1 A7 36 AB A6 44 2C 9C FB 5E E9 78 E7 52 61 45
2C E6 1E A1 8A A3 84 6A 87 C9 68 4A 5B 0D 20 2F
31 30 35 07 F1 BE CF 56 5B CC CC 22 90 00
Comping 60 bytes from 180:
------Read Data--------------------------------       ------Original Data----------------------------
AF C5 84 BD 31 42 4F 7A 18 F7 7B 00 00 F4 95 FB  ---  AF C5 84 BD 31 42 4F 7A 18 F7 7B 00 00 F4 95 FB
D1 A7 36 AB A6 44 2C 9C FB 5E E9 78 E7 52 61 45  ---  D1 A7 36 AB A6 44 2C 9C FB 5E E9 78 E7 52 61 45
2C E6 1E A1 8A A3 84 6A 87 C9 68 4A 5B 0D 20 2F  ---  2C E6 1E A1 8A A3 84 6A 87 C9 68 4A 5B 0D 20 2F
31 30 35 07 F1 BE CF 56 5B CC CC 22              ---  31 30 35 07 F1 BE CF 56 5B CC CC 22

Reading 60 bytes from 240.
executeCommand : APDU Command is as follows :
00 B0 00 3C 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 240.
executeCommand : APDU Command is as follows :
00 D0 00 3C 3C FE CF F0 C1 B7 00 1D C9 AD C6 8D
15 15 38 20 33 CD 42 71 82 04 ED 46 4D 74 36 B3
8C 92 EF 46 1C FE E1 72 68 F5 00 67 46 B2 D5 F2
1F 3C E7 0D B9 C6 65 F6 E8 DE B0 CE 1B 13 AF 20
54
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 240.
executeCommand : APDU Command is as follows :
00 B0 00 3C 3C
executeCommand : response from internalSendCommandAPDU:
FE CF F0 C1 B7 00 1D C9 AD C6 8D 15 15 38 20 33
CD 42 71 82 04 ED 46 4D 74 36 B3 8C 92 EF 46 1C
FE E1 72 68 F5 00 67 46 B2 D5 F2 1F 3C E7 0D B9
C6 65 F6 E8 DE B0 CE 1B 13 AF 20 54 90 00
Comping 60 bytes from 240:
------Read Data--------------------------------       ------Original Data----------------------------
FE CF F0 C1 B7 00 1D C9 AD C6 8D 15 15 38 20 33  ---  FE CF F0 C1 B7 00 1D C9 AD C6 8D 15 15 38 20 33
CD 42 71 82 04 ED 46 4D 74 36 B3 8C 92 EF 46 1C  ---  CD 42 71 82 04 ED 46 4D 74 36 B3 8C 92 EF 46 1C
FE E1 72 68 F5 00 67 46 B2 D5 F2 1F 3C E7 0D B9  ---  FE E1 72 68 F5 00 67 46 B2 D5 F2 1F 3C E7 0D B9
C6 65 F6 E8 DE B0 CE 1B 13 AF 20 54              ---  C6 65 F6 E8 DE B0 CE 1B 13 AF 20 54

Reading 60 bytes from 300.
executeCommand : APDU Command is as follows :
00 B0 00 4B 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 300.
executeCommand : APDU Command is as follows :
00 D0 00 4B 3C 97 EA 24 67 6B 49 FE F4 86 97 2E
72 BB 3E C8 A0 4F 3E 59 6B F8 2E 53 C2 F6 14 DC
B2 CF AF 42 CC 83 65 40 08 F3 D6 90 C9 12 42 7D
20 7E 30 69 E9 A7 19 54 63 40 22 C9 95 3B 98 AE
BB
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 300.
executeCommand : APDU Command is as follows :
00 B0 00 4B 3C
executeCommand : response from internalSendCommandAPDU:
97 EA 2F 67 6B 4D FF FE 86 97 2F 73 BF 3E CC A2
4F 7F 7B FF FC FE F3 F6 F7 36 FD B7 CF FF FE CD
C7 FD 46 A8 F7 FF 9F EB D3 57 FD 76 7E 71 F9 FD
FF BD 5D E7 FA AA EF DD BB 9A AE BF 90 00
Comping 60 bytes from 300:
------Read Data--------------------------------       ------Original Data----------------------------
97 EA 2F*67 6B 4D*FF*FE*86 97 2F*73*BF*3E CC*A2* ---  97 EA 24*67 6B 49*FE*F4*86 97 2E*72*BB*3E C8*A0*
4F 7F*7B*FF*FC*FE*F3*F6*F7*36*FD*B7*CF FF*FE*CD* ---  4F 3E*59*6B*F8*2E*53*C2*F6*14*DC*B2*CF AF*42*CC*
C7*FD*46*A8*F7*FF*9F*EB*D3*57*FD*76*7E 71*F9*FD* ---  83*65*40*08*F3*D6*90*C9*12*42*7D*20*7E 30*69*E9*
FF*BD*5D*E7*FA*AA*EF*DD*BB*9A*AE BF*             ---  A7*19*54*63*40*22*C9*95*3B*98*AE BB*

Reading 60 bytes from 360.
executeCommand : APDU Command is as follows :
00 B0 00 5A 3C
executeCommand : response from internalSendCommandAPDU:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 90 00


Writing 60 bytes from 360.
executeCommand : APDU Command is as follows :
00 D0 00 5A 3C E8 6A 83 C1 C3 BF 9C 17 D8 A4 44
B8 17 40 81 A7 9D 85 21 8A F8 3A 45 62 70 7B 98
F7 5B 6F C2 DD 95 D5 8D 24 D0 43 9E 6D 39 AD 7D
12 A9 42 48 B3 4B A8 E7 0F 21 E6 14 F1 56 FF B5
45
executeCommand : response from internalSendCommandAPDU:
90 00
Reading 60 bytes from 360.
executeCommand : APDU Command is as follows :
00 B0 00 5A 3C
executeCommand : response from internalSendCommandAPDU:
ED 6E DF F7 D7 BF 9D BF DC F7 54 BC BF 4C D9 BF
BD AF A3 AF FE 3F F5 7A 7F 7F FD F7 FB 7F FE DD
97 F7 FF A6 D3 FF FF ED 7D AD 7F 92 ED 66 F9 F3
7B EF F7 BF 23 F6 56 FB D7 FF FF 6F 90 00
Comping 60 bytes from 360:
------Read Data--------------------------------       ------Original Data----------------------------
ED*6E*DF*F7*D7*BF 9D*BF*DC*F7*54*BC*BF*4C*D9*BF* ---  E8*6A*83*C1*C3*BF 9C*17*D8*A4*44*B8*17*40*81*A7*
BD*AF*A3*AF*FE*3F*F5*7A*7F*7F*FD*F7 FB*7F*FE*DD  ---  9D*85*21*8A*F8*3A*45*62*70*7B*98*F7 5B*6F*C2*DD
97*F7*FF*A6*D3*FF*FF*ED*7D*AD 7F*92*ED*66*F9*F3* ---  95*D5*8D*24*D0*43*9E*6D*39*AD 7D*12*A9*42*48*B3*
7B*EF*F7*BF*23*F6*56*FB*D7*FF FF*6F*             ---  4B*A8*E7*0F*21*E6*14*F1*56*FF B5*45*


Press Ctrl+C to terminate the application...
--- > Visit the OpenCard web site at http://www.opencard.org/ for more > information on OpenCard---binaries, source code, documents. > This list is being archived at http://www.opencard.org/archive/opencard/ ! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email ! to ! [EMAIL PROTECTED] ! containing the word ! unsubscribe ! in the body.

Reply via email to