mirror of
https://github.com/status-im/status-keycard.git
synced 2025-02-05 10:24:09 +00:00
more tolerant SET NDEF
This commit is contained in:
parent
c574944153
commit
0d650d0838
@ -463,13 +463,17 @@ public class KeycardApplet extends Applet {
|
||||
}
|
||||
|
||||
short dataLen = Util.makeShort((byte) 0x00, apduBuffer[ISO7816.OFFSET_LC]);
|
||||
short offset;
|
||||
|
||||
if (Util.makeShort(apduBuffer[ISO7816.OFFSET_CDATA], apduBuffer[(short)(ISO7816.OFFSET_CDATA + 1)]) != (short)(dataLen - 2)) {
|
||||
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
|
||||
offset = ISO7816.OFFSET_P2;
|
||||
apduBuffer[ISO7816.OFFSET_P2] = 0;
|
||||
} else {
|
||||
offset = ISO7816.OFFSET_CDATA;
|
||||
}
|
||||
|
||||
JCSystem.beginTransaction();
|
||||
Util.arrayCopy(apduBuffer, ISO7816.OFFSET_CDATA, SharedMemory.ndefDataFile, (short) 0, dataLen);
|
||||
Util.arrayCopy(apduBuffer, offset, SharedMemory.ndefDataFile, (short) 0, dataLen);
|
||||
JCSystem.commitTransaction();
|
||||
}
|
||||
|
||||
|
@ -498,10 +498,9 @@ public class KeycardTest {
|
||||
response = cmdSet.setNDEF(ndefData);
|
||||
assertEquals(0x9000, response.getSw());
|
||||
|
||||
// Wrong length
|
||||
ndefData[1]++;
|
||||
response = cmdSet.setNDEF(ndefData);
|
||||
assertEquals(0x6A80, response.getSw());
|
||||
// Good case with no length.
|
||||
response = cmdSet.setNDEF(Arrays.copyOfRange(ndefData, 2, ndefData.length));
|
||||
assertEquals(0x9000, response.getSw());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user