]> cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/mifareutil.c
FIX: Another try to see if the "lf em4x 410xsim" becomes better, added the clock...
[proxmark3-svn] / armsrc / mifareutil.c
1 //-----------------------------------------------------------------------------
2 // Merlok, May 2011, 2012
3 // Many authors, whom made it possible
4 //
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
7 // the license.
8 //-----------------------------------------------------------------------------
9 // Work with mifare cards.
10 //-----------------------------------------------------------------------------
11
12 #include "../include/proxmark3.h"
13 #include "apps.h"
14 #include "util.h"
15 #include "string.h"
16
17 #include "../common/iso14443crc.h"
18 #include "iso14443a.h"
19 #include "crapto1.h"
20 #include "mifareutil.h"
21
22 int MF_DBGLEVEL = MF_DBG_ALL;
23
24 // memory management
25 uint8_t* mifare_get_bigbufptr(void) {
26 return (((uint8_t *)BigBuf) + MIFARE_BUFF_OFFSET); // was 3560 - tied to other size changes
27 }
28 uint8_t* eml_get_bigbufptr_sendbuf(void) {
29 return (((uint8_t *)BigBuf) + RECV_CMD_OFFSET);
30 }
31 uint8_t* eml_get_bigbufptr_recbuf(void) {
32 return (((uint8_t *)BigBuf) + MIFARE_BUFF_OFFSET);
33 }
34 uint8_t* eml_get_bigbufptr_cardmem(void) {
35 return (((uint8_t *)BigBuf) + CARD_MEMORY);
36 }
37
38 // crypto1 helpers
39 void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len){
40 uint8_t bt = 0;
41 int i;
42
43 if (len != 1) {
44 for (i = 0; i < len; i++)
45 data[i] = crypto1_byte(pcs, 0x00, 0) ^ data[i];
46 } else {
47 bt = 0;
48 for (i = 0; i < 4; i++)
49 bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data[0], i)) << i;
50
51 data[0] = bt;
52 }
53 return;
54 }
55
56 void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, int len, uint32_t *par) {
57 uint8_t bt = 0;
58 int i;
59 uint32_t mltpl = 1 << (len - 1); // for len=18 it=0x20000
60 *par = 0;
61 for (i = 0; i < len; i++) {
62 bt = data[i];
63 data[i] = crypto1_byte(pcs, 0x00, 0) ^ data[i];
64 *par = (*par >> 1) | ( ((filter(pcs->odd) ^ oddparity(bt)) & 0x01) * mltpl );
65 }
66 return;
67 }
68
69 uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data) {
70 uint8_t bt = 0;
71 int i;
72
73 for (i = 0; i < 4; i++)
74 bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data, i)) << i;
75
76 return bt;
77 }
78
79 // send commands
80 int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint32_t *timing)
81 {
82 return mifare_sendcmd_shortex(pcs, crypted, cmd, data, answer, NULL, timing);
83 }
84
85 int mifare_sendcmd_short_special(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer, uint8_t *timing)
86 {
87 uint8_t dcmd[8];
88 dcmd[0] = cmd;
89 memcpy(dcmd+1,data,5);
90 AppendCrc14443a(dcmd, 6);
91 ReaderTransmit(dcmd, sizeof(dcmd), NULL);
92 int len = ReaderReceive(answer);
93 if(!len) {
94 if (MF_DBGLEVEL >= 1) Dbprintf("Authentication failed. Card timeout.");
95 return 2;
96 }
97 return len;
98 }
99
100 int mifare_sendcmd_short_mfucauth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer, uint32_t *timing)
101 {
102 uint8_t dcmd[19];
103 int len;
104 dcmd[0] = cmd;
105 memcpy(dcmd+1,data,16);
106 AppendCrc14443a(dcmd, 17);
107
108 ReaderTransmit(dcmd, sizeof(dcmd), timing);
109 len = ReaderReceive(answer);
110 if(!len) {
111 if (MF_DBGLEVEL >= 1) Dbprintf("Authentication failed. Card timeout.");
112 len = ReaderReceive(answer);
113 }
114 if(len==1) {
115 if (MF_DBGLEVEL >= 1) Dbprintf("NAK - Authentication failed.");
116 return 1;
117 }
118 return len;
119 }
120
121 int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint32_t * parptr, uint32_t *timing)
122 {
123 uint8_t dcmd[4], ecmd[4];
124 uint32_t pos, par, res;
125
126 dcmd[0] = cmd;
127 dcmd[1] = data;
128 AppendCrc14443a(dcmd, 2);
129
130 memcpy(ecmd, dcmd, sizeof(dcmd));
131
132 if (crypted) {
133 par = 0;
134 for (pos = 0; pos < 4; pos++)
135 {
136 ecmd[pos] = crypto1_byte(pcs, 0x00, 0) ^ dcmd[pos];
137 par = (par >> 1) | ( ((filter(pcs->odd) ^ oddparity(dcmd[pos])) & 0x01) * 0x08 );
138 }
139
140 ReaderTransmitPar(ecmd, sizeof(ecmd), par, timing);
141
142 } else {
143 ReaderTransmit(dcmd, sizeof(dcmd), timing);
144 }
145
146 int len = ReaderReceivePar(answer, &par);
147
148 if (parptr) *parptr = par;
149
150 if (crypted == CRYPT_ALL) {
151 if (len == 1) {
152 res = 0;
153 for (pos = 0; pos < 4; pos++)
154 res |= (crypto1_bit(pcs, 0, 0) ^ BIT(answer[0], pos)) << pos;
155
156 answer[0] = res;
157
158 } else {
159 for (pos = 0; pos < len; pos++)
160 {
161 answer[pos] = crypto1_byte(pcs, 0x00, 0) ^ answer[pos];
162 }
163 }
164 }
165
166 return len;
167 }
168
169 // mifare commands
170 int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint64_t isNested)
171 {
172 return mifare_classic_authex(pcs, uid, blockNo, keyType, ui64Key, isNested, NULL, NULL);
173 }
174
175 int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint64_t isNested, uint32_t * ntptr, uint32_t *timing)
176 {
177 // variables
178 int len;
179 uint32_t pos;
180 uint8_t tmp4[4];
181 byte_t par = 0;
182 byte_t ar[4];
183 uint32_t nt, ntpp; // Supplied tag nonce
184
185 uint8_t mf_nr_ar[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
186 uint8_t* receivedAnswer = mifare_get_bigbufptr();
187
188 // Transmit MIFARE_CLASSIC_AUTH
189 len = mifare_sendcmd_short(pcs, isNested, 0x60 + (keyType & 0x01), blockNo, receivedAnswer, timing);
190 if (MF_DBGLEVEL >= 4) Dbprintf("rand nonce len: %x", len);
191 if (len != 4) return 1;
192
193 ar[0] = 0x55;
194 ar[1] = 0x41;
195 ar[2] = 0x49;
196 ar[3] = 0x92;
197
198 // Save the tag nonce (nt)
199 nt = bytes_to_num(receivedAnswer, 4);
200
201 // ----------------------------- crypto1 create
202 if (isNested)
203 crypto1_destroy(pcs);
204
205 // Init cipher with key
206 crypto1_create(pcs, ui64Key);
207
208 if (isNested == AUTH_NESTED) {
209 // decrypt nt with help of new key
210 nt = crypto1_word(pcs, nt ^ uid, 1) ^ nt;
211 } else {
212 // Load (plain) uid^nt into the cipher
213 crypto1_word(pcs, nt ^ uid, 0);
214 }
215
216 // some statistic
217 if (!ntptr && (MF_DBGLEVEL >= 3))
218 Dbprintf("auth uid: %08x nt: %08x", uid, nt);
219
220 // save Nt
221 if (ntptr)
222 *ntptr = nt;
223
224 par = 0;
225 // Generate (encrypted) nr+parity by loading it into the cipher (Nr)
226 for (pos = 0; pos < 4; pos++)
227 {
228 mf_nr_ar[pos] = crypto1_byte(pcs, ar[pos], 0) ^ ar[pos];
229 par = (par >> 1) | ( ((filter(pcs->odd) ^ oddparity(ar[pos])) & 0x01) * 0x80 );
230 }
231
232 // Skip 32 bits in pseudo random generator
233 nt = prng_successor(nt,32);
234
235 // ar+parity
236 for (pos = 4; pos < 8; pos++)
237 {
238 nt = prng_successor(nt,8);
239 mf_nr_ar[pos] = crypto1_byte(pcs,0x00,0) ^ (nt & 0xff);
240 par = (par >> 1)| ( ((filter(pcs->odd) ^ oddparity(nt & 0xff)) & 0x01) * 0x80 );
241 }
242
243 // Transmit reader nonce and reader answer
244 ReaderTransmitPar(mf_nr_ar, sizeof(mf_nr_ar), par, NULL);
245
246 // Receive 4 bit answer
247 len = ReaderReceive(receivedAnswer);
248 if (!len)
249 {
250 if (MF_DBGLEVEL >= 1) Dbprintf("Authentication failed. Card timeout.");
251 return 2;
252 }
253
254 memcpy(tmp4, receivedAnswer, 4);
255 ntpp = prng_successor(nt, 32) ^ crypto1_word(pcs, 0,0);
256
257 if (ntpp != bytes_to_num(tmp4, 4)) {
258 if (MF_DBGLEVEL >= 1) Dbprintf("Authentication failed. Error card response.");
259 return 3;
260 }
261
262 return 0;
263 }
264
265 int mifare_classic_readblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData)
266 {
267 // variables
268 int len;
269 uint8_t bt[2];
270
271 uint8_t* receivedAnswer = mifare_get_bigbufptr();
272
273 // command MIFARE_CLASSIC_READBLOCK
274 len = mifare_sendcmd_short(pcs, 1, 0x30, blockNo, receivedAnswer, NULL);
275 if (len == 1) {
276 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
277 return 1;
278 }
279 if (len != 18) {
280 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: card timeout. len: %x", len);
281 return 2;
282 }
283
284 memcpy(bt, receivedAnswer + 16, 2);
285 AppendCrc14443a(receivedAnswer, 16);
286 if (bt[0] != receivedAnswer[16] || bt[1] != receivedAnswer[17]) {
287 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd CRC response error.");
288 return 3;
289 }
290
291 memcpy(blockData, receivedAnswer, 16);
292 return 0;
293 }
294
295 int mifare_ultra_auth1(uint32_t uid, uint8_t *blockData){
296 // variables
297 int len;
298
299 uint8_t* receivedAnswer = mifare_get_bigbufptr();
300
301 // command MIFARE_CLASSIC_READBLOCK
302 len = mifare_sendcmd_short(NULL, 1, 0x1A, 0x00, receivedAnswer,NULL);
303 if (len == 1) {
304 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
305 return 1;
306 }
307 if (len == 11) {
308 if (MF_DBGLEVEL >= 1) Dbprintf("Auth1 Resp: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
309 receivedAnswer[0],receivedAnswer[1],receivedAnswer[2],receivedAnswer[3],receivedAnswer[4],
310 receivedAnswer[5],receivedAnswer[6],receivedAnswer[7],receivedAnswer[8],receivedAnswer[9],
311 receivedAnswer[10]);
312 memcpy(blockData, receivedAnswer, 11);
313 return 0;
314 }
315 //else something went wrong???
316 return 1;
317 }
318
319 int mifare_ultra_auth2(uint32_t uid, uint8_t *key, uint8_t *blockData){
320 // variables
321 int len;
322
323 uint8_t* receivedAnswer = mifare_get_bigbufptr();
324
325
326 // command MIFARE_CLASSIC_READBLOCK
327 len = mifare_sendcmd_short_mfucauth(NULL, 1, 0xAF, key, receivedAnswer,NULL);
328 if (len == 1) {
329 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
330 return 1;
331 }
332 if (len == 11){
333 if (MF_DBGLEVEL >= 1) Dbprintf("Auth2 Resp: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
334 receivedAnswer[0],receivedAnswer[1],receivedAnswer[2],receivedAnswer[3],receivedAnswer[4],
335 receivedAnswer[5],receivedAnswer[6],receivedAnswer[7],receivedAnswer[8],receivedAnswer[9],
336 receivedAnswer[10]);
337 memcpy(blockData, receivedAnswer, 11);
338 return 0;
339 }
340 //something went wrong?
341 return 1;
342 }
343
344 int mifare_ultra_readblock(uint32_t uid, uint8_t blockNo, uint8_t *blockData)
345 {
346 // variables
347 int len;
348 uint8_t bt[2];
349
350 uint8_t* receivedAnswer = mifare_get_bigbufptr();
351
352 // command MIFARE_CLASSIC_READBLOCK
353 len = mifare_sendcmd_short(NULL, 1, 0x30, blockNo, receivedAnswer,NULL);
354 if (len == 1) {
355 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
356 return 1;
357 }
358 if (len != 18) {
359 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: card timeout. len: %x", len);
360 return 2;
361 }
362
363 memcpy(bt, receivedAnswer + 16, 2);
364 AppendCrc14443a(receivedAnswer, 16);
365 if (bt[0] != receivedAnswer[16] || bt[1] != receivedAnswer[17]) {
366 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd CRC response error.");
367 return 3;
368 }
369
370 memcpy(blockData, receivedAnswer, 14);
371 return 0;
372 }
373
374
375 int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData)
376 {
377 // variables
378 int len, i;
379 uint32_t pos;
380 uint32_t par = 0;
381 byte_t res;
382
383 uint8_t d_block[18], d_block_enc[18];
384 uint8_t* receivedAnswer = mifare_get_bigbufptr();
385
386 // command MIFARE_CLASSIC_WRITEBLOCK
387 len = mifare_sendcmd_short(pcs, 1, 0xA0, blockNo, receivedAnswer, NULL);
388
389 if ((len != 1) || (receivedAnswer[0] != 0x0A)) { // 0x0a - ACK
390 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
391 return 1;
392 }
393
394 memcpy(d_block, blockData, 16);
395 AppendCrc14443a(d_block, 16);
396
397 // crypto
398 par = 0;
399 for (pos = 0; pos < 18; pos++)
400 {
401 d_block_enc[pos] = crypto1_byte(pcs, 0x00, 0) ^ d_block[pos];
402 par = (par >> 1) | ( ((filter(pcs->odd) ^ oddparity(d_block[pos])) & 0x01) * 0x20000 );
403 }
404
405 ReaderTransmitPar(d_block_enc, sizeof(d_block_enc), par, NULL);
406
407 // Receive the response
408 len = ReaderReceive(receivedAnswer);
409
410 res = 0;
411 for (i = 0; i < 4; i++)
412 res |= (crypto1_bit(pcs, 0, 0) ^ BIT(receivedAnswer[0], i)) << i;
413
414 if ((len != 1) || (res != 0x0A)) {
415 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd send data2 Error: %02x", res);
416 return 2;
417 }
418
419 return 0;
420 }
421
422 int mifare_ultra_writeblock(uint32_t uid, uint8_t blockNo, uint8_t *blockData)
423 {
424 // variables
425 int len;
426 uint32_t par = 0;
427
428 uint8_t d_block[18];
429 uint8_t* receivedAnswer = mifare_get_bigbufptr();
430
431 // command MIFARE_CLASSIC_WRITEBLOCK
432 len = mifare_sendcmd_short(NULL, 1, 0xA0, blockNo, receivedAnswer,NULL);
433
434 if ((len != 1) || (receivedAnswer[0] != 0x0A)) { // 0x0a - ACK
435 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Addr Error: %02x", receivedAnswer[0]);
436 return 1;
437 }
438
439 memset(d_block,'\0',18);
440 memcpy(d_block, blockData, 16);
441 AppendCrc14443a(d_block, 16);
442
443 ReaderTransmitPar(d_block, sizeof(d_block), par, NULL);
444
445 // Receive the response
446 len = ReaderReceive(receivedAnswer);
447
448 if ((len != 1) || (receivedAnswer[0] != 0x0A)) { // 0x0a - ACK
449 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Data Error: %02x %d", receivedAnswer[0],len);
450 return 2;
451 }
452
453 return 0;
454 }
455
456 int mifare_ultra_special_writeblock(uint32_t uid, uint8_t blockNo, uint8_t *blockData)
457 {
458 // variables
459 int len;
460 //uint32_t par = 0;
461
462 uint8_t d_block[8];
463 uint8_t* receivedAnswer = mifare_get_bigbufptr();
464
465 // command MIFARE_CLASSIC_WRITEBLOCK
466 memset(d_block,'\0',8);
467 d_block[0]= blockNo;
468 memcpy(d_block+1,blockData,4);
469 AppendCrc14443a(d_block, 6);
470
471 //i know the data send here is correct
472 len = mifare_sendcmd_short_special(NULL, 1, 0xA2, d_block, receivedAnswer,NULL);
473
474 if (receivedAnswer[0] != 0x0A) { // 0x0a - ACK
475 if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Send Error: %02x %d", receivedAnswer[0],len);
476 return 1;
477 }
478 return 0;
479 }
480
481 int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid)
482 {
483 // variables
484 int len;
485
486 // Mifare HALT
487 uint8_t* receivedAnswer = mifare_get_bigbufptr();
488
489 len = mifare_sendcmd_short(pcs, pcs == NULL ? 0:1, 0x50, 0x00, receivedAnswer, NULL);
490 if (len != 0) {
491 if (MF_DBGLEVEL >= 1) Dbprintf("halt error. response len: %x", len);
492 return 1;
493 }
494
495 return 0;
496 }
497
498 int mifare_ultra_halt(uint32_t uid)
499 {
500 // variables
501 int len;
502
503 // Mifare HALT
504 uint8_t* receivedAnswer = mifare_get_bigbufptr();
505
506 len = mifare_sendcmd_short(NULL, 1, 0x50, 0x00, receivedAnswer, NULL);
507 if (len != 0) {
508 if (MF_DBGLEVEL >= 1) Dbprintf("halt error. response len: %x", len);
509 return 1;
510 }
511
512 return 0;
513 }
514
515
516 // Mifare Memory Structure: up to 32 Sectors with 4 blocks each (1k and 2k cards),
517 // plus evtl. 8 sectors with 16 blocks each (4k cards)
518 uint8_t NumBlocksPerSector(uint8_t sectorNo)
519 {
520 if (sectorNo < 32)
521 return 4;
522 else
523 return 16;
524 }
525
526 uint8_t FirstBlockOfSector(uint8_t sectorNo)
527 {
528 if (sectorNo < 32)
529 return sectorNo * 4;
530 else
531 return 32*4 + (sectorNo - 32) * 16;
532
533 }
534
535
536 // work with emulator memory
537 void emlSetMem(uint8_t *data, int blockNum, int blocksCount) {
538 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
539
540 memcpy(emCARD + blockNum * 16, data, blocksCount * 16);
541 }
542
543 void emlGetMem(uint8_t *data, int blockNum, int blocksCount) {
544 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
545
546 memcpy(data, emCARD + blockNum * 16, blocksCount * 16);
547 }
548
549 void emlGetMemBt(uint8_t *data, int bytePtr, int byteCount) {
550 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
551
552 memcpy(data, emCARD + bytePtr, byteCount);
553 }
554
555 int emlCheckValBl(int blockNum) {
556 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
557 uint8_t* data = emCARD + blockNum * 16;
558
559 if ((data[0] != (data[4] ^ 0xff)) || (data[0] != data[8]) ||
560 (data[1] != (data[5] ^ 0xff)) || (data[1] != data[9]) ||
561 (data[2] != (data[6] ^ 0xff)) || (data[2] != data[10]) ||
562 (data[3] != (data[7] ^ 0xff)) || (data[3] != data[11]) ||
563 (data[12] != (data[13] ^ 0xff)) || (data[12] != data[14]) ||
564 (data[12] != (data[15] ^ 0xff))
565 )
566 return 1;
567 return 0;
568 }
569
570 int emlGetValBl(uint32_t *blReg, uint8_t *blBlock, int blockNum) {
571 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
572 uint8_t* data = emCARD + blockNum * 16;
573
574 if (emlCheckValBl(blockNum)) {
575 return 1;
576 }
577
578 memcpy(blReg, data, 4);
579 *blBlock = data[12];
580
581 return 0;
582 }
583
584 int emlSetValBl(uint32_t blReg, uint8_t blBlock, int blockNum) {
585 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
586 uint8_t* data = emCARD + blockNum * 16;
587
588 memcpy(data + 0, &blReg, 4);
589 memcpy(data + 8, &blReg, 4);
590 blReg = blReg ^ 0xffffffff;
591 memcpy(data + 4, &blReg, 4);
592
593 data[12] = blBlock;
594 data[13] = blBlock ^ 0xff;
595 data[14] = blBlock;
596 data[15] = blBlock ^ 0xff;
597
598 return 0;
599 }
600
601 uint64_t emlGetKey(int sectorNum, int keyType) {
602 uint8_t key[6];
603 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
604
605 memcpy(key, emCARD + 16 * (FirstBlockOfSector(sectorNum) + NumBlocksPerSector(sectorNum) - 1) + keyType * 10, 6);
606 return bytes_to_num(key, 6);
607 }
608
609 void emlClearMem(void) {
610 int b;
611
612 const uint8_t trailer[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
613 const uint8_t uid[] = {0xe6, 0x84, 0x87, 0xf3, 0x16, 0x88, 0x04, 0x00, 0x46, 0x8e, 0x45, 0x55, 0x4d, 0x70, 0x41, 0x04};
614 uint8_t* emCARD = eml_get_bigbufptr_cardmem();
615
616 memset(emCARD, 0, CARD_MEMORY_LEN);
617
618 // fill sectors trailer data
619 for(b = 3; b < 256; b<127?(b+=4):(b+=16)) {
620 emlSetMem((uint8_t *)trailer, b , 1);
621 }
622
623 // uid
624 emlSetMem((uint8_t *)uid, 0, 1);
625 return;
626 }
Impressum, Datenschutz