+static int ulc_magic_test(){
+ // Magic Ultralight test
+ // Magic UL-C, by observation,
+ // 1) it seems to have a static nonce response to 0x1A command.
+ // 2) the deskey bytes is not-zero:d out on as datasheet states.
+ // 3) UID - changeable, not only, but pages 0-1-2-3.
+ int returnValue = UL_ERROR;
+ iso14a_card_select_t card;
+ uint8_t nonce1[11] = {0x00};
+ uint8_t nonce2[11] = {0x00};
+ int status = ul_select(&card);
+ if ( status < 1 ){
+ PrintAndLog("Error: couldn't select ulc_magic_test");
+ ul_switch_off_field();
+ return UL_ERROR;
+ }
+ status = ulc_requestAuthentication(0, nonce1, sizeof(nonce1));
+ if ( status > 0 ) {
+ status = ulc_requestAuthentication(0, nonce2, sizeof(nonce2));
+ returnValue = ( !memcmp(nonce1, nonce2, 11) ) ? UL_C_MAGIC : UL_C;
+ } else {
+ returnValue = UL;
+ }
+ ul_switch_off_field();
+ return returnValue;
+}
+
+static int ul_magic_test(){
+
+ // Magic Ultralight test
+ // It takes present UID, and tries to write it back.
+ iso14a_card_select_t card;
+ int status = ul_select(&card);
+ if ( status < 1 ){
+ PrintAndLog("Error: couldn't select ul_magic_test");
+ ul_switch_off_field();
+ return UL_ERROR;
+ }
+ uint8_t page0 = 0;
+ uint8_t data[4] = {card.uid[0], card.uid[1], card.uid[2], 0};
+ data[3] = 0x88 ^ card.uid[0] ^ card.uid[1] ^ card.uid[2];
+
+ status = ul_write( page0, data, sizeof(data));
+ ul_switch_off_field();
+ if ( status == 0)
+ return UL_MAGIC;
+ return UL;
+}
+