]> cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/mifarecmd.c
de2b4db29ddb1e46ef0e418c14ecad3b6527d36e
[proxmark3-svn] / armsrc / mifarecmd.c
1 //-----------------------------------------------------------------------------
2 // Merlok - June 2011, 2012
3 // Gerhard de Koning Gans - May 2008
4 // Hagen Fritsch - June 2010
5 // Midnitesnake - Dec 2013
6 // Andy Davies - Apr 2014
7 // Iceman - May 2014
8 //
9 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
10 // at your option, any later version. See the LICENSE.txt file for the text of
11 // the license.
12 //-----------------------------------------------------------------------------
13 // Routines to support ISO 14443 type A.
14 //-----------------------------------------------------------------------------
15
16 #include "mifarecmd.h"
17 #include "apps.h"
18 #include "util.h"
19
20 #include "crc.h"
21
22 //-----------------------------------------------------------------------------
23 // Select, Authenticate, Read a MIFARE tag.
24 // read block
25 //-----------------------------------------------------------------------------
26 void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
27 {
28 // params
29 uint8_t blockNo = arg0;
30 uint8_t keyType = arg1;
31 uint64_t ui64Key = 0;
32 ui64Key = bytes_to_num(datain, 6);
33
34 // variables
35 byte_t isOK = 0;
36 byte_t dataoutbuf[16];
37 uint8_t uid[10];
38 uint32_t cuid;
39 struct Crypto1State mpcs = {0, 0};
40 struct Crypto1State *pcs;
41 pcs = &mpcs;
42
43 // clear trace
44 clear_trace();
45 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
46
47 LED_A_ON();
48 LED_B_OFF();
49 LED_C_OFF();
50
51 while (true) {
52 if(!iso14443a_select_card(uid, NULL, &cuid)) {
53 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
54 break;
55 };
56
57 if(mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) {
58 if (MF_DBGLEVEL >= 1) Dbprintf("Auth error");
59 break;
60 };
61
62 if(mifare_classic_readblock(pcs, cuid, blockNo, dataoutbuf)) {
63 if (MF_DBGLEVEL >= 1) Dbprintf("Read block error");
64 break;
65 };
66
67 if(mifare_classic_halt(pcs, cuid)) {
68 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
69 break;
70 };
71
72 isOK = 1;
73 break;
74 }
75
76 // ----------------------------- crypto1 destroy
77 crypto1_destroy(pcs);
78
79 if (MF_DBGLEVEL >= 2) DbpString("READ BLOCK FINISHED");
80
81 LED_B_ON();
82 cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,16);
83 LED_B_OFF();
84
85 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
86 LEDsoff();
87 }
88
89
90 void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes){
91
92 bool turnOffField = (arg0 == 1);
93
94 LED_A_ON(); LED_B_OFF(); LED_C_OFF();
95 clear_trace();
96 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
97
98 if(!iso14443a_select_card(NULL, NULL, NULL)) {
99 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card");
100 OnError(0);
101 return;
102 };
103
104 if(!mifare_ultra_auth(keybytes)){
105 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Authentication failed");
106 OnError(1);
107 return;
108 }
109
110 if (turnOffField) {
111 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
112 LEDsoff();
113 }
114 cmd_send(CMD_ACK,1,0,0,0,0);
115 }
116
117 // Arg0 = BlockNo,
118 // Arg1 = UsePwd bool
119 // datain = PWD bytes,
120 void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain)
121 {
122 uint8_t blockNo = arg0;
123 byte_t dataout[16] = {0x00};
124 bool useKey = (arg1 == 1); //UL_C
125 bool usePwd = (arg1 == 2); //UL_EV1/NTAG
126
127 LEDsoff();
128 LED_A_ON();
129 clear_trace();
130 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
131
132 int len = iso14443a_select_card(NULL, NULL, NULL);
133 if(!len) {
134 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card (RC:%02X)",len);
135 OnError(1);
136 return;
137 }
138
139 // UL-C authentication
140 if ( useKey ) {
141 uint8_t key[16] = {0x00};
142 memcpy(key, datain, sizeof(key) );
143
144 if ( !mifare_ultra_auth(key) ) {
145 OnError(1);
146 return;
147 }
148 }
149
150 // UL-EV1 / NTAG authentication
151 if (usePwd) {
152 uint8_t pwd[4] = {0x00};
153 memcpy(pwd, datain, 4);
154 uint8_t pack[4] = {0,0,0,0};
155 if (!mifare_ul_ev1_auth(pwd, pack)) {
156 OnError(1);
157 return;
158 }
159 }
160
161 if( mifare_ultra_readblock(blockNo, dataout) ) {
162 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Read block error");
163 OnError(2);
164 return;
165 }
166
167 if( mifare_ultra_halt() ) {
168 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Halt error");
169 OnError(3);
170 return;
171 }
172
173 cmd_send(CMD_ACK,1,0,0,dataout,16);
174 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
175 LEDsoff();
176 }
177
178 //-----------------------------------------------------------------------------
179 // Select, Authenticate, Read a MIFARE tag.
180 // read sector (data = 4 x 16 bytes = 64 bytes, or 16 x 16 bytes = 256 bytes)
181 //-----------------------------------------------------------------------------
182 void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
183 {
184 // params
185 uint8_t sectorNo = arg0;
186 uint8_t keyType = arg1;
187 uint64_t ui64Key = 0;
188 ui64Key = bytes_to_num(datain, 6);
189
190 // variables
191 byte_t isOK = 0;
192 byte_t dataoutbuf[16 * 16];
193 uint8_t uid[10];
194 uint32_t cuid;
195 struct Crypto1State mpcs = {0, 0};
196 struct Crypto1State *pcs;
197 pcs = &mpcs;
198
199 // clear trace
200 clear_trace();
201
202 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
203
204 LED_A_ON();
205 LED_B_OFF();
206 LED_C_OFF();
207
208 isOK = 1;
209 if(!iso14443a_select_card(uid, NULL, &cuid)) {
210 isOK = 0;
211 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
212 }
213
214
215 if(isOK && mifare_classic_auth(pcs, cuid, FirstBlockOfSector(sectorNo), keyType, ui64Key, AUTH_FIRST)) {
216 isOK = 0;
217 if (MF_DBGLEVEL >= 1) Dbprintf("Auth error");
218 }
219
220 for (uint8_t blockNo = 0; isOK && blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
221 if(mifare_classic_readblock(pcs, cuid, FirstBlockOfSector(sectorNo) + blockNo, dataoutbuf + 16 * blockNo)) {
222 isOK = 0;
223 if (MF_DBGLEVEL >= 1) Dbprintf("Read sector %2d block %2d error", sectorNo, blockNo);
224 break;
225 }
226 }
227
228 if(mifare_classic_halt(pcs, cuid)) {
229 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
230 }
231
232 // ----------------------------- crypto1 destroy
233 crypto1_destroy(pcs);
234
235 if (MF_DBGLEVEL >= 2) DbpString("READ SECTOR FINISHED");
236
237 LED_B_ON();
238 cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,16*NumBlocksPerSector(sectorNo));
239 LED_B_OFF();
240
241 // Thats it...
242 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
243 LEDsoff();
244 }
245
246 // arg0 = blockNo (start)
247 // arg1 = Pages (number of blocks)
248 // arg2 = useKey
249 // datain = KEY bytes
250 void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
251 {
252 // free eventually allocated BigBuf memory
253 BigBuf_free();
254 // clear trace
255 clear_trace();
256
257 // params
258 uint8_t blockNo = arg0;
259 uint16_t blocks = arg1;
260 bool useKey = (arg2 == 1); //UL_C
261 bool usePwd = (arg2 == 2); //UL_EV1/NTAG
262 uint32_t countblocks = 0;
263 uint8_t *dataout = BigBuf_malloc(CARD_MEMORY_SIZE);
264 if (dataout == NULL){
265 Dbprintf("out of memory");
266 OnError(1);
267 return;
268 }
269
270 LEDsoff();
271 LED_A_ON();
272 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
273
274 int len = iso14443a_select_card(NULL, NULL, NULL);
275 if (!len) {
276 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card (RC:%d)",len);
277 OnError(1);
278 return;
279 }
280
281 // UL-C authentication
282 if ( useKey ) {
283 uint8_t key[16] = {0x00};
284 memcpy(key, datain, sizeof(key) );
285
286 if ( !mifare_ultra_auth(key) ) {
287 OnError(1);
288 return;
289 }
290 }
291
292 // UL-EV1 / NTAG authentication
293 if (usePwd) {
294 uint8_t pwd[4] = {0x00};
295 memcpy(pwd, datain, sizeof(pwd));
296 uint8_t pack[4] = {0,0,0,0};
297
298 if (!mifare_ul_ev1_auth(pwd, pack)){
299 OnError(1);
300 return;
301 }
302 }
303
304 for (int i = 0; i < blocks; i++){
305 if ((i*4) + 4 > CARD_MEMORY_SIZE) {
306 Dbprintf("Data exceeds buffer!!");
307 break;
308 }
309
310 len = mifare_ultra_readblock(blockNo + i, dataout + 4 * i);
311
312 if (len) {
313 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Read block %d error",i);
314 // if no blocks read - error out
315 if (i==0){
316 OnError(2);
317 return;
318 } else {
319 //stop at last successful read block and return what we got
320 break;
321 }
322 } else {
323 countblocks++;
324 }
325 }
326
327 len = mifare_ultra_halt();
328 if (len) {
329 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Halt error");
330 OnError(3);
331 return;
332 }
333
334 if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Blocks read %d", countblocks);
335
336 countblocks *= 4;
337 cmd_send(CMD_ACK, 1, countblocks, countblocks, 0, 0);
338 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
339 LEDsoff();
340 }
341
342 //-----------------------------------------------------------------------------
343 // Select, Authenticate, Write a MIFARE tag.
344 // read block
345 //-----------------------------------------------------------------------------
346 void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
347 {
348 // params
349 uint8_t blockNo = arg0;
350 uint8_t keyType = arg1;
351 uint64_t ui64Key = 0;
352 byte_t blockdata[16];
353
354 ui64Key = bytes_to_num(datain, 6);
355 memcpy(blockdata, datain + 10, 16);
356
357 // variables
358 byte_t isOK = 0;
359 uint8_t uid[10];
360 uint32_t cuid;
361 struct Crypto1State mpcs = {0, 0};
362 struct Crypto1State *pcs;
363 pcs = &mpcs;
364
365 // clear trace
366 clear_trace();
367
368 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
369
370 LED_A_ON();
371 LED_B_OFF();
372 LED_C_OFF();
373
374 while (true) {
375 if(!iso14443a_select_card(uid, NULL, &cuid)) {
376 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
377 break;
378 };
379
380 if(mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) {
381 if (MF_DBGLEVEL >= 1) Dbprintf("Auth error");
382 break;
383 };
384
385 if(mifare_classic_writeblock(pcs, cuid, blockNo, blockdata)) {
386 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
387 break;
388 };
389
390 if(mifare_classic_halt(pcs, cuid)) {
391 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
392 break;
393 };
394
395 isOK = 1;
396 break;
397 }
398
399 // ----------------------------- crypto1 destroy
400 crypto1_destroy(pcs);
401
402 if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
403
404 LED_B_ON();
405 cmd_send(CMD_ACK,isOK,0,0,0,0);
406 LED_B_OFF();
407
408
409 // Thats it...
410 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
411 LEDsoff();
412 }
413
414 void MifareUWriteBlock(uint8_t arg0, uint8_t *datain)
415 {
416 uint8_t blockNo = arg0;
417 byte_t blockdata[16] = {0x00};
418
419 memcpy(blockdata, datain, 16);
420
421 uint8_t uid[10] = {0x00};
422
423 LED_A_ON(); LED_B_OFF(); LED_C_OFF();
424
425 clear_trace();
426 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
427
428 if(!iso14443a_select_card(uid, NULL, NULL)) {
429 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
430 OnError(0);
431 return;
432 };
433
434 if(mifare_ultra_writeblock(blockNo, blockdata)) {
435 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
436 OnError(0);
437 return; };
438
439 if(mifare_ultra_halt()) {
440 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
441 OnError(0);
442 return;
443 };
444
445 if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
446
447 cmd_send(CMD_ACK,1,0,0,0,0);
448 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
449 LEDsoff();
450 }
451
452 void MifareUWriteBlock_Special(uint8_t arg0, uint8_t *datain)
453 {
454 uint8_t blockNo = arg0;
455 byte_t blockdata[4] = {0x00};
456
457 memcpy(blockdata, datain,4);
458
459 LEDsoff();
460 LED_A_ON();
461 clear_trace();
462 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
463
464 if(!iso14443a_select_card(NULL, NULL, NULL)) {
465 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
466 OnError(0);
467 return;
468 };
469
470 if(mifare_ultra_special_writeblock(blockNo, blockdata)) {
471 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
472 OnError(0);
473 return;
474 };
475
476 if(mifare_ultra_halt()) {
477 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
478 OnError(0);
479 return;
480 };
481
482 if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
483
484 cmd_send(CMD_ACK,1,0,0,0,0);
485 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
486 LEDsoff();
487 }
488
489 void MifareUSetPwd(uint8_t arg0, uint8_t *datain){
490
491 uint8_t pwd[16] = {0x00};
492 byte_t blockdata[4] = {0x00};
493
494 memcpy(pwd, datain, 16);
495
496 LED_A_ON(); LED_B_OFF(); LED_C_OFF();
497 clear_trace();
498 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
499
500 if(!iso14443a_select_card(NULL, NULL, NULL)) {
501 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
502 OnError(0);
503 return;
504 };
505
506 blockdata[0] = pwd[7];
507 blockdata[1] = pwd[6];
508 blockdata[2] = pwd[5];
509 blockdata[3] = pwd[4];
510 if(mifare_ultra_special_writeblock( 44, blockdata)) {
511 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
512 OnError(44);
513 return;
514 };
515
516 blockdata[0] = pwd[3];
517 blockdata[1] = pwd[2];
518 blockdata[2] = pwd[1];
519 blockdata[3] = pwd[0];
520 if(mifare_ultra_special_writeblock( 45, blockdata)) {
521 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
522 OnError(45);
523 return;
524 };
525
526 blockdata[0] = pwd[15];
527 blockdata[1] = pwd[14];
528 blockdata[2] = pwd[13];
529 blockdata[3] = pwd[12];
530 if(mifare_ultra_special_writeblock( 46, blockdata)) {
531 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
532 OnError(46);
533 return;
534 };
535
536 blockdata[0] = pwd[11];
537 blockdata[1] = pwd[10];
538 blockdata[2] = pwd[9];
539 blockdata[3] = pwd[8];
540 if(mifare_ultra_special_writeblock( 47, blockdata)) {
541 if (MF_DBGLEVEL >= 1) Dbprintf("Write block error");
542 OnError(47);
543 return;
544 };
545
546 if(mifare_ultra_halt()) {
547 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
548 OnError(0);
549 return;
550 };
551
552 cmd_send(CMD_ACK,1,0,0,0,0);
553 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
554 LEDsoff();
555 }
556
557 // Return 1 if the nonce is invalid else return 0
558 int valid_nonce(uint32_t Nt, uint32_t NtEnc, uint32_t Ks1, uint8_t *parity) {
559 return ((oddparity((Nt >> 24) & 0xFF) == ((parity[0]) ^ oddparity((NtEnc >> 24) & 0xFF) ^ BIT(Ks1,16))) & \
560 (oddparity((Nt >> 16) & 0xFF) == ((parity[1]) ^ oddparity((NtEnc >> 16) & 0xFF) ^ BIT(Ks1,8))) & \
561 (oddparity((Nt >> 8) & 0xFF) == ((parity[2]) ^ oddparity((NtEnc >> 8) & 0xFF) ^ BIT(Ks1,0)))) ? 1 : 0;
562 }
563
564
565 //-----------------------------------------------------------------------------
566 // MIFARE nested authentication.
567 //
568 //-----------------------------------------------------------------------------
569 void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *datain)
570 {
571 // params
572 uint8_t blockNo = arg0 & 0xff;
573 uint8_t keyType = (arg0 >> 8) & 0xff;
574 uint8_t targetBlockNo = arg1 & 0xff;
575 uint8_t targetKeyType = (arg1 >> 8) & 0xff;
576 uint64_t ui64Key = 0;
577
578 ui64Key = bytes_to_num(datain, 6);
579
580 // variables
581 uint16_t rtr, i, j, len;
582 uint16_t davg;
583 static uint16_t dmin, dmax;
584 uint8_t uid[10];
585 uint32_t cuid, nt1, nt2, nttmp, nttest, ks1;
586 uint8_t par[1];
587 uint32_t target_nt[2], target_ks[2];
588
589 uint8_t par_array[4];
590 uint16_t ncount = 0;
591 struct Crypto1State mpcs = {0, 0};
592 struct Crypto1State *pcs;
593 pcs = &mpcs;
594 uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];
595
596 uint32_t auth1_time, auth2_time;
597 static uint16_t delta_time;
598
599 // free eventually allocated BigBuf memory
600 BigBuf_free();
601 // clear trace
602 clear_trace();
603 set_tracing(false);
604
605 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
606
607 LED_A_ON();
608 LED_C_OFF();
609
610
611 // statistics on nonce distance
612 if (calibrate) { // for first call only. Otherwise reuse previous calibration
613 LED_B_ON();
614 WDT_HIT();
615
616 davg = dmax = 0;
617 dmin = 2000;
618 delta_time = 0;
619
620 for (rtr = 0; rtr < 17; rtr++) {
621
622 // prepare next select. No need to power down the card.
623 if(mifare_classic_halt(pcs, cuid)) {
624 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Halt error");
625 rtr--;
626 continue;
627 }
628
629 if(!iso14443a_select_card(uid, NULL, &cuid)) {
630 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Can't select card");
631 rtr--;
632 continue;
633 };
634
635 auth1_time = 0;
636 if(mifare_classic_authex(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST, &nt1, &auth1_time)) {
637 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Auth1 error");
638 rtr--;
639 continue;
640 };
641
642 if (delta_time) {
643 auth2_time = auth1_time + delta_time;
644 } else {
645 auth2_time = 0;
646 }
647 if(mifare_classic_authex(pcs, cuid, blockNo, keyType, ui64Key, AUTH_NESTED, &nt2, &auth2_time)) {
648 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Auth2 error");
649 rtr--;
650 continue;
651 };
652
653 nttmp = prng_successor(nt1, 100); //NXP Mifare is typical around 840,but for some unlicensed/compatible mifare card this can be 160
654 for (i = 101; i < 1200; i++) {
655 nttmp = prng_successor(nttmp, 1);
656 if (nttmp == nt2) break;
657 }
658
659 if (i != 1200) {
660 if (rtr != 0) {
661 davg += i;
662 dmin = MIN(dmin, i);
663 dmax = MAX(dmax, i);
664 }
665 else {
666 delta_time = auth2_time - auth1_time + 32; // allow some slack for proper timing
667 }
668 if (MF_DBGLEVEL >= 3) Dbprintf("Nested: calibrating... ntdist=%d", i);
669 }
670 }
671
672 if (rtr <= 1) return;
673
674 davg = (davg + (rtr - 1)/2) / (rtr - 1);
675
676 if (MF_DBGLEVEL >= 3) Dbprintf("min=%d max=%d avg=%d, delta_time=%d", dmin, dmax, davg, delta_time);
677
678 dmin = davg - 2;
679 dmax = davg + 2;
680
681 LED_B_OFF();
682
683 }
684 // -------------------------------------------------------------------------------------------------
685
686 LED_C_ON();
687
688 // get crypted nonces for target sector
689 for(i=0; i < 2; i++) { // look for exactly two different nonces
690
691 target_nt[i] = 0;
692 while(target_nt[i] == 0) { // continue until we have an unambiguous nonce
693
694 // prepare next select. No need to power down the card.
695 if(mifare_classic_halt(pcs, cuid)) {
696 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Halt error");
697 continue;
698 }
699
700 if(!iso14443a_select_card(uid, NULL, &cuid)) {
701 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Can't select card");
702 continue;
703 };
704
705 auth1_time = 0;
706 if(mifare_classic_authex(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST, &nt1, &auth1_time)) {
707 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Auth1 error");
708 continue;
709 };
710
711 // nested authentication
712 auth2_time = auth1_time + delta_time;
713 len = mifare_sendcmd_shortex(pcs, AUTH_NESTED, 0x60 + (targetKeyType & 0x01), targetBlockNo, receivedAnswer, par, &auth2_time);
714 if (len != 4) {
715 if (MF_DBGLEVEL >= 1) Dbprintf("Nested: Auth2 error len=%d", len);
716 continue;
717 };
718
719 nt2 = bytes_to_num(receivedAnswer, 4);
720 if (MF_DBGLEVEL >= 3) Dbprintf("Nonce#%d: Testing nt1=%08x nt2enc=%08x nt2par=%02x", i+1, nt1, nt2, par[0]);
721
722 // Parity validity check
723 for (j = 0; j < 4; j++) {
724 par_array[j] = (oddparity(receivedAnswer[j]) != ((par[0] >> (7-j)) & 0x01));
725 }
726
727 ncount = 0;
728 nttest = prng_successor(nt1, dmin - 1);
729 for (j = dmin; j < dmax + 1; j++) {
730 nttest = prng_successor(nttest, 1);
731 ks1 = nt2 ^ nttest;
732
733 if (valid_nonce(nttest, nt2, ks1, par_array)){
734 if (ncount > 0) { // we are only interested in disambiguous nonces, try again
735 if (MF_DBGLEVEL >= 3) Dbprintf("Nonce#%d: dismissed (ambigous), ntdist=%d", i+1, j);
736 target_nt[i] = 0;
737 break;
738 }
739 target_nt[i] = nttest;
740 target_ks[i] = ks1;
741 ncount++;
742 if (i == 1 && target_nt[1] == target_nt[0]) { // we need two different nonces
743 target_nt[i] = 0;
744 if (MF_DBGLEVEL >= 3) Dbprintf("Nonce#2: dismissed (= nonce#1), ntdist=%d", j);
745 break;
746 }
747 if (MF_DBGLEVEL >= 3) Dbprintf("Nonce#%d: valid, ntdist=%d", i+1, j);
748 }
749 }
750 if (target_nt[i] == 0 && j == dmax+1 && MF_DBGLEVEL >= 3) Dbprintf("Nonce#%d: dismissed (all invalid)", i+1);
751 }
752 }
753
754 LED_C_OFF();
755
756 // ----------------------------- crypto1 destroy
757 crypto1_destroy(pcs);
758
759 byte_t buf[4 + 4 * 4];
760 memcpy(buf, &cuid, 4);
761 memcpy(buf+4, &target_nt[0], 4);
762 memcpy(buf+8, &target_ks[0], 4);
763 memcpy(buf+12, &target_nt[1], 4);
764 memcpy(buf+16, &target_ks[1], 4);
765
766 LED_B_ON();
767 cmd_send(CMD_ACK, 0, 2, targetBlockNo + (targetKeyType * 0x100), buf, sizeof(buf));
768 LED_B_OFF();
769
770 if (MF_DBGLEVEL >= 3) DbpString("NESTED FINISHED");
771
772 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
773 LEDsoff();
774 set_tracing(TRUE);
775 }
776
777 //-----------------------------------------------------------------------------
778 // MIFARE check keys. key count up to 85.
779 //
780 //-----------------------------------------------------------------------------
781 void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
782 {
783 // params
784 uint8_t blockNo = arg0;
785 uint8_t keyType = arg1;
786 uint8_t keyCount = arg2;
787 uint64_t ui64Key = 0;
788
789 // variables
790 int i;
791 byte_t isOK = 0;
792 uint8_t uid[10];
793 uint32_t cuid;
794 struct Crypto1State mpcs = {0, 0};
795 struct Crypto1State *pcs;
796 pcs = &mpcs;
797
798 // clear debug level
799 int OLD_MF_DBGLEVEL = MF_DBGLEVEL;
800 MF_DBGLEVEL = MF_DBG_NONE;
801
802 // clear trace
803 clear_trace();
804 set_tracing(TRUE);
805
806 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
807
808 LED_A_ON();
809 LED_B_OFF();
810 LED_C_OFF();
811
812 for (i = 0; i < keyCount; i++) {
813 if(mifare_classic_halt(pcs, cuid)) {
814 if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Halt error");
815 }
816
817 if(!iso14443a_select_card(uid, NULL, &cuid)) {
818 if (OLD_MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card");
819 break;
820 };
821
822 ui64Key = bytes_to_num(datain + i * 6, 6);
823 if(mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) {
824 continue;
825 };
826
827 isOK = 1;
828 break;
829 }
830
831 // ----------------------------- crypto1 destroy
832 crypto1_destroy(pcs);
833
834 LED_B_ON();
835 cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6);
836 LED_B_OFF();
837
838 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
839 LEDsoff();
840
841 // restore debug level
842 MF_DBGLEVEL = OLD_MF_DBGLEVEL;
843 }
844
845 //-----------------------------------------------------------------------------
846 // MIFARE commands set debug level
847 //
848 //-----------------------------------------------------------------------------
849 void MifareSetDbgLvl(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
850 MF_DBGLEVEL = arg0;
851 Dbprintf("Debug level: %d", MF_DBGLEVEL);
852 }
853
854 //-----------------------------------------------------------------------------
855 // Work with emulator memory
856 //
857 //-----------------------------------------------------------------------------
858 void MifareEMemClr(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
859 emlClearMem();
860 }
861
862 void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
863 emlSetMem(datain, arg0, arg1); // data, block num, blocks count
864 }
865
866 void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
867 byte_t buf[USB_CMD_DATA_SIZE];
868 emlGetMem(buf, arg0, arg1); // data, block num, blocks count (max 4)
869
870 LED_B_ON();
871 cmd_send(CMD_ACK,arg0,arg1,0,buf,USB_CMD_DATA_SIZE);
872 LED_B_OFF();
873 }
874
875 //-----------------------------------------------------------------------------
876 // Load a card into the emulator memory
877 //
878 //-----------------------------------------------------------------------------
879 void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
880 uint8_t numSectors = arg0;
881 uint8_t keyType = arg1;
882 uint64_t ui64Key = 0;
883 uint32_t cuid;
884 struct Crypto1State mpcs = {0, 0};
885 struct Crypto1State *pcs;
886 pcs = &mpcs;
887
888 // variables
889 byte_t dataoutbuf[16];
890 byte_t dataoutbuf2[16];
891 uint8_t uid[10];
892
893 // clear trace
894 clear_trace();
895 set_tracing(false);
896
897 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
898
899 LED_A_ON();
900 LED_B_OFF();
901 LED_C_OFF();
902
903 bool isOK = true;
904
905 if(!iso14443a_select_card(uid, NULL, &cuid)) {
906 isOK = false;
907 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
908 }
909
910 for (uint8_t sectorNo = 0; isOK && sectorNo < numSectors; sectorNo++) {
911 ui64Key = emlGetKey(sectorNo, keyType);
912 if (sectorNo == 0){
913 if(isOK && mifare_classic_auth(pcs, cuid, FirstBlockOfSector(sectorNo), keyType, ui64Key, AUTH_FIRST)) {
914 isOK = false;
915 if (MF_DBGLEVEL >= 1) Dbprintf("Sector[%2d]. Auth error", sectorNo);
916 break;
917 }
918 } else {
919 if(isOK && mifare_classic_auth(pcs, cuid, FirstBlockOfSector(sectorNo), keyType, ui64Key, AUTH_NESTED)) {
920 isOK = false;
921 if (MF_DBGLEVEL >= 1) Dbprintf("Sector[%2d]. Auth nested error", sectorNo);
922 break;
923 }
924 }
925
926 for (uint8_t blockNo = 0; isOK && blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
927 if(isOK && mifare_classic_readblock(pcs, cuid, FirstBlockOfSector(sectorNo) + blockNo, dataoutbuf)) {
928 isOK = false;
929 if (MF_DBGLEVEL >= 1) Dbprintf("Error reading sector %2d block %2d", sectorNo, blockNo);
930 break;
931 };
932 if (isOK) {
933 if (blockNo < NumBlocksPerSector(sectorNo) - 1) {
934 emlSetMem(dataoutbuf, FirstBlockOfSector(sectorNo) + blockNo, 1);
935 } else { // sector trailer, keep the keys, set only the AC
936 emlGetMem(dataoutbuf2, FirstBlockOfSector(sectorNo) + blockNo, 1);
937 memcpy(&dataoutbuf2[6], &dataoutbuf[6], 4);
938 emlSetMem(dataoutbuf2, FirstBlockOfSector(sectorNo) + blockNo, 1);
939 }
940 }
941 }
942
943 }
944
945 if(mifare_classic_halt(pcs, cuid)) {
946 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
947 };
948
949 // ----------------------------- crypto1 destroy
950 crypto1_destroy(pcs);
951
952 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
953 LEDsoff();
954
955 if (MF_DBGLEVEL >= 2) DbpString("EMUL FILL SECTORS FINISHED");
956
957 }
958
959
960 //-----------------------------------------------------------------------------
961 // Work with "magic Chinese" card (email him: ouyangweidaxian@live.cn)
962 //
963 //-----------------------------------------------------------------------------
964 void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
965
966 // params
967 uint8_t needWipe = arg0;
968 // bit 0 - need get UID
969 // bit 1 - need wupC
970 // bit 2 - need HALT after sequence
971 // bit 3 - need init FPGA and field before sequence
972 // bit 4 - need reset FPGA and LED
973 uint8_t workFlags = arg1;
974 uint8_t blockNo = arg2;
975
976 // card commands
977 uint8_t wupC1[] = { 0x40 };
978 uint8_t wupC2[] = { 0x43 };
979 uint8_t wipeC[] = { 0x41 };
980
981 // variables
982 byte_t isOK = 0;
983 uint8_t uid[10] = {0x00};
984 uint8_t d_block[18] = {0x00};
985 uint32_t cuid;
986
987 uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];
988 uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE];
989
990 // reset FPGA and LED
991 if (workFlags & 0x08) {
992 LED_A_ON();
993 LED_B_OFF();
994 LED_C_OFF();
995
996 clear_trace();
997 set_tracing(TRUE);
998 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
999 }
1000
1001 while (true) {
1002
1003 // get UID from chip
1004 if (workFlags & 0x01) {
1005 if(!iso14443a_select_card(uid, NULL, &cuid)) {
1006 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
1007 //break;
1008 };
1009
1010 if(mifare_classic_halt(NULL, cuid)) {
1011 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
1012 //break;
1013 };
1014 };
1015
1016 // reset chip
1017 if (needWipe){
1018 ReaderTransmitBitsPar(wupC1,7,0, NULL);
1019 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1020 if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error");
1021 break;
1022 };
1023
1024 ReaderTransmit(wipeC, sizeof(wipeC), NULL);
1025 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1026 if (MF_DBGLEVEL >= 1) Dbprintf("wipeC error");
1027 break;
1028 };
1029
1030 if(mifare_classic_halt(NULL, cuid)) {
1031 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
1032 break;
1033 };
1034 };
1035
1036 // write block
1037 if (workFlags & 0x02) {
1038 ReaderTransmitBitsPar(wupC1,7,0, NULL);
1039 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1040 if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error");
1041 break;
1042 };
1043
1044 ReaderTransmit(wupC2, sizeof(wupC2), NULL);
1045 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1046 if (MF_DBGLEVEL >= 1) Dbprintf("wupC2 error");
1047 break;
1048 };
1049 }
1050
1051 if ((mifare_sendcmd_short(NULL, 0, 0xA0, blockNo, receivedAnswer, receivedAnswerPar, NULL) != 1) || (receivedAnswer[0] != 0x0a)) {
1052 if (MF_DBGLEVEL >= 1) Dbprintf("write block send command error");
1053 break;
1054 };
1055
1056 memcpy(d_block, datain, 16);
1057 AppendCrc14443a(d_block, 16);
1058
1059 ReaderTransmit(d_block, sizeof(d_block), NULL);
1060 if ((ReaderReceive(receivedAnswer, receivedAnswerPar) != 1) || (receivedAnswer[0] != 0x0a)) {
1061 if (MF_DBGLEVEL >= 1) Dbprintf("write block send data error");
1062 break;
1063 };
1064
1065 if (workFlags & 0x04) {
1066 if (mifare_classic_halt(NULL, cuid)) {
1067 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
1068 break;
1069 };
1070 }
1071
1072 isOK = 1;
1073 break;
1074 }
1075
1076 LED_B_ON();
1077 cmd_send(CMD_ACK,isOK,0,0,uid,4);
1078 LED_B_OFF();
1079
1080 if ((workFlags & 0x10) || (!isOK)) {
1081 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
1082 LEDsoff();
1083 }
1084 }
1085
1086
1087 void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
1088
1089 // params
1090 // bit 1 - need wupC
1091 // bit 2 - need HALT after sequence
1092 // bit 3 - need init FPGA and field before sequence
1093 // bit 4 - need reset FPGA and LED
1094 uint8_t workFlags = arg0;
1095 uint8_t blockNo = arg2;
1096
1097 // card commands
1098 uint8_t wupC1[] = { 0x40 };
1099 uint8_t wupC2[] = { 0x43 };
1100
1101 // variables
1102 byte_t isOK = 0;
1103 uint8_t data[18] = {0x00};
1104 uint32_t cuid = 0;
1105
1106 uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];
1107 uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE];
1108
1109 if (workFlags & 0x08) {
1110 LED_A_ON();
1111 LED_B_OFF();
1112 LED_C_OFF();
1113
1114 clear_trace();
1115 set_tracing(TRUE);
1116 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
1117 }
1118
1119 while (true) {
1120 if (workFlags & 0x02) {
1121 ReaderTransmitBitsPar(wupC1,7,0, NULL);
1122 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1123 if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error");
1124 break;
1125 };
1126
1127 ReaderTransmit(wupC2, sizeof(wupC2), NULL);
1128 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1129 if (MF_DBGLEVEL >= 1) Dbprintf("wupC2 error");
1130 break;
1131 };
1132 }
1133
1134 // read block
1135 if ((mifare_sendcmd_short(NULL, 0, 0x30, blockNo, receivedAnswer, receivedAnswerPar, NULL) != 18)) {
1136 if (MF_DBGLEVEL >= 1) Dbprintf("read block send command error");
1137 break;
1138 };
1139 memcpy(data, receivedAnswer, 18);
1140
1141 if (workFlags & 0x04) {
1142 if (mifare_classic_halt(NULL, cuid)) {
1143 if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
1144 break;
1145 };
1146 }
1147
1148 isOK = 1;
1149 break;
1150 }
1151
1152 LED_B_ON();
1153 cmd_send(CMD_ACK,isOK,0,0,data,18);
1154 LED_B_OFF();
1155
1156 if ((workFlags & 0x10) || (!isOK)) {
1157 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
1158 LEDsoff();
1159 }
1160 }
1161
1162 void MifareCIdent(){
1163
1164 // card commands
1165 uint8_t wupC1[] = { 0x40 };
1166 uint8_t wupC2[] = { 0x43 };
1167
1168 // variables
1169 byte_t isOK = 1;
1170
1171 uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];
1172 uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE];
1173
1174 ReaderTransmitBitsPar(wupC1,7,0, NULL);
1175 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1176 isOK = 0;
1177 };
1178
1179 ReaderTransmit(wupC2, sizeof(wupC2), NULL);
1180 if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {
1181 isOK = 0;
1182 };
1183
1184 if (mifare_classic_halt(NULL, 0)) {
1185 isOK = 0;
1186 };
1187
1188 cmd_send(CMD_ACK,isOK,0,0,0,0);
1189 }
1190
1191 void MifareCollectNonces(uint32_t arg0, uint32_t arg1){
1192
1193 BigBuf_free();
1194
1195 uint32_t iterations = arg0;
1196 uint8_t uid[10] = {0x00};
1197
1198 uint8_t *response = BigBuf_malloc(MAX_MIFARE_FRAME_SIZE);
1199 uint8_t *responsePar = BigBuf_malloc(MAX_MIFARE_PARITY_SIZE);
1200
1201 uint8_t mf_auth[] = { 0x60,0x00,0xf5,0x7b };
1202
1203 // get memory from BigBuf.
1204 uint8_t *nonces = BigBuf_malloc(iterations * 4);
1205
1206 LED_A_ON();
1207 LED_B_OFF();
1208 LED_C_OFF();
1209
1210 clear_trace();
1211 set_tracing(TRUE);
1212 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
1213
1214 for (int i = 0; i < iterations; i++) {
1215
1216 WDT_HIT();
1217
1218 // Test if the action was cancelled
1219 if(BUTTON_PRESS()) break;
1220
1221 // if(mifare_classic_halt(pcs, cuid)) {
1222 // if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
1223 //}
1224
1225 if(!iso14443a_select_card(uid, NULL, NULL)) {
1226 if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
1227 continue;
1228 };
1229
1230 // Transmit MIFARE_CLASSIC_AUTH.
1231 ReaderTransmit(mf_auth, sizeof(mf_auth), NULL);
1232
1233 // Receive the (4 Byte) "random" nonce
1234 if (!ReaderReceive(response, responsePar)) {
1235 if (MF_DBGLEVEL >= 1) Dbprintf("Couldn't receive tag nonce");
1236 continue;
1237 }
1238
1239 nonces[i*4] = bytes_to_num(response, 4);
1240 }
1241
1242 int packLen = iterations * 4;
1243 int packSize = 0;
1244 int packNum = 0;
1245 while (packLen > 0) {
1246 packSize = MIN(USB_CMD_DATA_SIZE, packLen);
1247 LED_B_ON();
1248 cmd_send(CMD_ACK, 77, 0, packSize, nonces - packLen, packSize);
1249 LED_B_OFF();
1250
1251 packLen -= packSize;
1252 packNum++;
1253 }
1254 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
1255 LEDsoff();
1256 }
1257
1258 //
1259 // DESFIRE
1260 //
1261
1262 void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain){
1263
1264 byte_t dataout[11] = {0x00};
1265 uint8_t uid[10] = {0x00};
1266 uint32_t cuid = 0x00;
1267
1268 clear_trace();
1269 iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
1270
1271 int len = iso14443a_select_card(uid, NULL, &cuid);
1272 if(!len) {
1273 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card");
1274 OnError(1);
1275 return;
1276 };
1277
1278 if(mifare_desfire_des_auth1(cuid, dataout)){
1279 if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Authentication part1: Fail.");
1280 OnError(4);
1281 return;
1282 }
1283
1284 if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 1 FINISHED");
1285 cmd_send(CMD_ACK,1,cuid,0,dataout, sizeof(dataout));
1286 }
1287
1288 void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain){
1289
1290 uint32_t cuid = arg0;
1291 uint8_t key[16] = {0x00};
1292 byte_t dataout[12] = {0x00};
1293 byte_t isOK = 0;
1294
1295 memcpy(key, datain, 16);
1296
1297 isOK = mifare_desfire_des_auth2(cuid, key, dataout);
1298
1299 if( isOK) {
1300 if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Authentication part2: Failed");
1301 OnError(4);
1302 return;
1303 }
1304
1305 if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 2 FINISHED");
1306
1307 cmd_send(CMD_ACK, isOK, 0, 0, dataout, sizeof(dataout));
1308 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
1309 LEDsoff();
1310 }
Impressum, Datenschutz