-// get SRx chip model (from UID) // from ST Microelectronics
-char *get_ST_Chip_Model(uint8_t data){
- static char model[20];
- char *retStr = model;
- memset(model,0, sizeof(model));
-
- switch (data) {
- case 0x0: sprintf(retStr, "SRIX4K (Special)"); break;
- case 0x2: sprintf(retStr, "SR176"); break;
- case 0x3: sprintf(retStr, "SRIX4K"); break;
- case 0x4: sprintf(retStr, "SRIX512"); break;
- case 0x6: sprintf(retStr, "SRI512"); break;
- case 0x7: sprintf(retStr, "SRI4K"); break;
- case 0xC: sprintf(retStr, "SRT512"); break;
- default : sprintf(retStr, "Unknown"); break;
+
+int print_ST_Lock_info(uint8_t model) {
+ //assume connection open and tag selected...
+ uint8_t data[16] = {0x00};
+ uint8_t datalen = 2;
+ bool crc = true;
+ uint8_t resplen;
+ uint8_t blk1;
+ data[0] = 0x08;
+
+ if (model == 0x02) { //SR176 has special command:
+ data[1] = 0x0f;
+ resplen = 4;
+ } else {
+ data[1] = 0xff;
+ resplen = 6;
+ }
+
+ //std read cmd
+ if (HF14BCmdRaw(true, &crc, true, data, &datalen, false) == 0) return switch_off_field_14b();
+
+ if (datalen != resplen || !crc) return switch_off_field_14b();
+
+ PrintAndLog("Chip Write Protection Bits:");
+ // now interpret the data
+ switch (model){
+ case 0x0: //fall through (SRIX4K special)
+ case 0x3: //fall through (SRIx4K)
+ case 0x7: // (SRI4K)
+ //only need data[3]
+ blk1 = 9;
+ PrintAndLog(" raw: %s",printBits(1,data+3));
+ PrintAndLog(" 07/08:%slocked", (data[3] & 1) ? " not " : " " );
+ for (uint8_t i = 1; i < 8; i++){
+ PrintAndLog(" %02u:%slocked", blk1, (data[3] & (1 << i)) ? " not " : " " );
+ blk1++;
+ }
+ break;
+ case 0x4: //fall through (SRIX512)
+ case 0x6: //fall through (SRI512)
+ case 0xC: // (SRT512)
+ //need data[2] and data[3]
+ blk1 = 0;
+ PrintAndLog(" raw: %s", printBits(2,data+2));
+ for (uint8_t b = 2; b < 4; b++) {
+ for (uint8_t i = 0; i < 8; i++) {
+ PrintAndLog(" %02u:%slocked", blk1, (data[b] & (1 << i)) ? " not " : " " );
+ blk1++;
+ }
+ }
+ break;
+ case 0x2: // (SR176)
+ //need data[2]
+ blk1 = 0;
+ PrintAndLog(" raw: %s",printBits(1, data+2));
+ for (uint8_t i = 0; i < 8; i++){
+ PrintAndLog(" %02u/%02u:%slocked", blk1, blk1+1, (data[2] & (1 << i)) ? " " : " not " );
+ blk1 += 2;
+ }
+ break;
+ default:
+ return switch_off_field_14b();