S.Orioli
S.Orioli

Reputation: 441

Read consecutive memory blocks smartcard Mifare 1k

I'm using a Mifare 1k card and the acr1252 reader; I'm developing using visual c++ and the Winscard library.

I've successful achieved to read the single block using the following code:

// Read binary blocks
// Class: FF
// INS: B0
// P1: 00
// P2: the starting block number
// Le: length to read (multiple of 16)
BYTE    ReadBinary[] = { 0xFF, 0xB0, 0x00, 0x00, 0x10 };

BYTE readRes[256] = { 0 };
DWORD lenRead = sizeof(readRes);

SCardTransmit(hCard, SCARD_PCI_T1, ReadBinary, sizeof(ReadBinary), NULL, readRes, &lenRead)

This function call returns SCARD_S_SUCCESS and readRes contains the block value + SW1 and SW2 with values 0x90 0x00 (success)

What i'm trying to do is reading 2 consecutive memory blocks (i.e. the block 0 and the block 1 of sector 0) using the same function only changing the apdu command with:

ReadBinary[] = { 0xFF, 0xB0, 0x00, 0x00, 0x20 }; 
// Last byte changed to read 2 blocks

But is not working: the return status still SCARD_S_SUCCESS but the data read contains only SW1 and SW2 with values 0x63 0x00 (error).

AFAIK with Mifare 1k cards is possible to read the first 3 blocks of a sector but all the reading tests that try to read more than a sector fail with that error.

Am i missing something?

Upvotes: 1

Views: 429

Answers (0)

Related Questions