You can do your own transfers as you need.
ReadFile is a convenience function, which just takes the file ID and then does various commands to get the file.
So it does a select command (A4) and then a loop with read commands (B0)
but if the file is in a sublevel
(MF \ DF 1 \ EF_personal_data)
Can I directly use a single call to the ReadFile method, directly indexing the file containing the personal data?
dim mydata as MemoryBlock
Dim comando1 as new MemoryBlock(2)
comando1.UInt8Value(0) = &h3F
comando1.UInt8Value(1) = &h00
mydata = card.ReadFile(comando1)
Well, it’s a convenience function, which works for swiss Health cards and Belgian identify cards for us.
It may work for others if they use the same format (APDU protocol).
For Swiss health cards, the relevant IDs are 2F06 and 2F07.
For Belgian EID:
4031 ID RN
4032 SGN RN
4033 ID Address
4034 SGN Address
4035 ID Photo
You find the IDs for files usually in documentation or your card!
For some cards you may first need to move down a hierarchy of folders to get an item via Transmit().
In “Trasmi” with command, command2 and command3, I obtain “90”, so I think it’s ok
at moment of command4 I obtain “670000000000000000000000000000…”, so no data.
Is 67 an error code? I don’t know.
I managed to get a “9000”, ie an ok, when reading the file using the “transmit” command. But unfortunately I don’t have the contents of the file. I think the content should immediately follow.
Dear Christian, I think I resolved my situation.
Look the new code:
dim header as new memoryBlock(8)
header.Int32Value(0) = SmartCardMBS.kProtocolT1 // T1
header.Int32Value(4) = 8 // size of this block
dim buffer as new MemoryBlock(256)
dim bufferFinale as new MemoryBlock(258)
dim ReceiveHeader as new MemoryBlock(8)
dim RecvLength as UInt32 = 256 'buffer.Size
dim RecvLengthFinale as UInt32 = 258
'MF
dim command1 as new MemoryBlock(7)
command1.Int8Value(0) = &h00
command1.Int8Value(1) = &hA4
command1.Int8Value(2) = &h00
command1.Int8Value(3) = &h00
command1.Int8Value(4) = &h02
command1.Int8Value(5) = &h3F
command1.Int8Value(6) = &h00
card.Transmit(header, command1, command1.Size, nil, buffer, RecvLength)
'DF1
dim command2 as new MemoryBlock(7)
command2.Int8Value(0) = &h00
command2.Int8Value(1) = &hA4
command2.Int8Value(2) = &h00
command2.Int8Value(3) = &h00
command2.Int8Value(4) = &h02
command2.Int8Value(5) = &h11
command2.Int8Value(6) = &h00
card.Transmit(header, command2, command2.Size, nil, buffer, RecvLength)
'EF_dati_personali
dim command3 as new MemoryBlock(7)
command3.Int8Value(0) = &h00
command3.Int8Value(1) = &hA4
command3.Int8Value(2) = &h00
command3.Int8Value(3) = &h00
command3.Int8Value(4) = &h02
command3.Int8Value(5) = &h11
command3.Int8Value(6) = &h02
card.Transmit(header, command3, command3.Size, nil, buffer, RecvLength)
'lettura
dim command4 as new MemoryBlock(5)
command4.Int8Value(0) = &h00
command4.Int8Value(1) = &hB0
command4.Int8Value(2) = &h00
command4.Int8Value(3) = &h00
command4.Int8Value(4) = &h00
'command4.Int8Value(5) = &h00
'command4.Int8Value(6) = &h22
card.Transmit(header, command4, command4.Size, nil, bufferFinale, RecvLengthFinale)
I simply created a new and different “buffer” variable (bufferFinale) and a new and different RecvLength variable (RecvLengthFinale). Isn’t that a weird behavior anyway?