Java Card Read Data from Array

Viewed 514

I have created an Smartcard application where i can store data up to 60KB in an Byte Array. But when i read the Array multiple Times i get an error and i cant access the Data anymore.

Code create Array:

public void createFile(short fileID, short fileSize) {
    short index = getFileIndex(fileID);

    if(listFiles[index] == null) {
        listFiles[index] = new byte[fileSize];
    }

    listfileSizes[index] = fileSize;
}

Code Read Data:

public byte[] readDataFromFile(short fileID, short fileOffset, short length) {

    short selFileSize = getFileSize(fileID);
    byte[] data = new byte[length];

    if (selFileSize < (short)(fileOffset + length)) {
        ISOException.throwIt(ISO7816.SW_FILE_FULL); 
    }

    Util.arrayCopy(getFile(fileID), fileOffset, data, (short)0, length);

    return (byte[])data;
}

Code access Read:

short data_length = Util.getShort(buf, (short)(offset_cdata + 2));
    short file_offset = Util.getShort(buf, offset_cdata);

    if(p2 == (byte)0x01) {

        Util.arrayCopy(myfile.readDataFromFile(myfile.keepassData1, file_offset, data_length), (short)0, buf, (short)0, data_length);

    } else if (p2 == (byte)0x02) {

        Util.arrayCopy(myfile.readDataFromFile(myfile.keepassData2, file_offset, data_length), (short)0, buf, (short)0, data_length);

    }

when i reinstall the app i can read and write, but only a few time until the data is blocked. I get the error 6f00.

1 Answers
Related