+static int ulev1_print_counters(){
+ PrintAndLog("--- UL-EV1 Counters");
+ uint8_t tear[1] = {0};
+ uint8_t counter[3] = {0,0,0};
+ for ( uint8_t i = 0; i<3; ++i) {
+ ulev1_readTearing(i,tear,sizeof(tear));
+ ulev1_readCounter(i,counter, sizeof(counter) );
+ PrintAndLog(" [%0d] : %s", i, sprint_hex(counter,3));
+ PrintAndLog(" - %02X tearing %s", tear[0], ( tear[0]==0xBD)?"Ok":"failure");
+ }
+ return 0;
+}
+
+static int ulev1_print_signature( uint8_t *data, uint8_t len){
+ PrintAndLog("\n--- UL-EV1 Signature");
+ PrintAndLog("IC signature public key name : NXP NTAG21x 2013");
+ PrintAndLog("IC signature public key value : 04494e1a386d3d3cfe3dc10e5de68a499b1c202db5b132393e89ed19fe5be8bc61");
+ PrintAndLog(" Elliptic curve parameters : secp128r1");
+ PrintAndLog(" Tag ECC Signature : %s", sprint_hex(data, len));
+ //to do: verify if signature is valid
+ //PrintAndLog("IC signature status: %s valid", (iseccvalid() )?"":"not");
+ return 0;
+}
+
+static int ulev1_print_version(uint8_t *data){
+ PrintAndLog("\n--- UL-EV1 / NTAG Version");
+ PrintAndLog(" Raw bytes : %s", sprint_hex(data, 8) );
+ PrintAndLog(" Vendor ID : %02X, Manufacturer: %s", data[1], getTagInfo(data[1]));
+ PrintAndLog(" Product type : %s" , getProductTypeStr(data[2]));
+ PrintAndLog(" Product subtype : %02X, %s" , data[3], (data[3]==1) ?"17 pF":"50pF");
+ PrintAndLog(" Major version : %02X" , data[4]);
+ PrintAndLog(" Minor version : %02X" , data[5]);
+ PrintAndLog(" Size : %s", getUlev1CardSizeStr(data[6]));
+ PrintAndLog(" Protocol type : %02X" , data[7]);
+ return 0;
+}
+
+/*
+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.
+ // 4) use the ul_magic_test ! magic tags answers specially!
+ 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(nonce1, sizeof(nonce1));
+ if ( status > 0 ) {
+ status = ulc_requestAuthentication(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 tests
+ // 1) take present UID, and try to write it back. OBSOLETE
+ // 2) make a wrong length write to page0, and see if tag answers with ACK/NACK:
+ iso14a_card_select_t card;
+ int status = ul_select(&card);
+ if ( status < 1 ){
+ PrintAndLog("iso14443a card select failed");
+ ul_switch_off_field();
+ return UL_ERROR;
+ }
+ status = ul_comp_write(0, NULL, 0);
+ ul_switch_off_field();
+ if ( status == 0 )
+ return UL_MAGIC;
+ return UL;
+}
+