change sectors keys THEN write application data.
This should avoid failure in some advanced use cases and when the example will be able to add user-provided data without data-loss. Suggested by: Romuald Conty <rconty@il4p.fr>
This commit is contained in:
parent
0ada18e508
commit
6631491dec
1 changed files with 6 additions and 7 deletions
|
@ -277,14 +277,7 @@ main(int argc, char *argv[])
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ssize_t) encoded_size != mad_application_write (tags[i], mad, aid, tlv_data, encoded_size, card_write_keys[sectors[0]].key, card_write_keys[sectors[0]].type)) {
|
|
||||||
perror ("mad_application_write");
|
|
||||||
error = EXIT_FAILURE;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int s = 0;
|
int s = 0;
|
||||||
|
|
||||||
while (sectors[s]) {
|
while (sectors[s]) {
|
||||||
MifareClassicBlockNumber block = mifare_classic_sector_last_block (sectors[s]);
|
MifareClassicBlockNumber block = mifare_classic_sector_last_block (sectors[s]);
|
||||||
MifareClassicBlock block_data;
|
MifareClassicBlock block_data;
|
||||||
|
@ -302,6 +295,12 @@ main(int argc, char *argv[])
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((ssize_t) encoded_size != mad_application_write (tags[i], mad, aid, tlv_data, encoded_size, default_keyb, MCAB_WRITE_KEYB)) {
|
||||||
|
perror ("mad_application_write");
|
||||||
|
error = EXIT_FAILURE;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
free (sectors);
|
free (sectors);
|
||||||
|
|
||||||
free (tlv_data);
|
free (tlv_data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue