]> git.zerfleddert.de Git - proxmark3-svn/blame - common/protocols.c
Update README.md
[proxmark3-svn] / common / protocols.c
CommitLineData
1defcf60 1#include "protocols.h"
1d0ccbe0 2
3// ATA55xx shared presets & routines
4uint32_t GetT55xxClockBit(uint32_t clock) {
5 switch (clock) {
8ce3e4b4 6 case 128: return T55x7_BITRATE_RF_128;
7 case 100: return T55x7_BITRATE_RF_100;
8 case 64: return T55x7_BITRATE_RF_64;
9 case 50: return T55x7_BITRATE_RF_50;
10 case 40: return T55x7_BITRATE_RF_40;
11 case 32: return T55x7_BITRATE_RF_32;
12 case 16: return T55x7_BITRATE_RF_16;
13 case 8: return T55x7_BITRATE_RF_8;
14 default : return 0;
1d0ccbe0 15 }
16}
17
1defcf60
MHS
18#ifndef ON_DEVICE
19#include "ui.h"
20#define prnt PrintAndLog
b67f7ec3 21
1d0ccbe0 22uint8_t isset(uint8_t val, uint8_t mask) {
b67f7ec3
MHS
23 return (val & mask);
24}
25
26uint8_t notset(uint8_t val, uint8_t mask){
27 return !(val & mask);
28}
29
1d0ccbe0 30void fuse_config(const picopass_hdr *hdr) {
b67f7ec3
MHS
31 uint8_t fuses = hdr->conf.fuses;
32
50282b85 33 if (isset(fuses,FUSE_FPERS))
34 prnt(" Mode: Personalization [Programmable]");
35 else
36 prnt(" Mode: Application [Locked]");
b67f7ec3 37
50282b85 38 if (isset(fuses, FUSE_CODING1)) {
b67f7ec3 39 prnt(" Coding: RFU");
50282b85 40 } else {
41 if( isset( fuses , FUSE_CODING0))
42 prnt(" Coding: ISO 14443-2 B/ISO 15693");
43 else
44 prnt(" Coding: ISO 14443B only");
b67f7ec3
MHS
45 }
46 if( isset (fuses,FUSE_CRYPT1 | FUSE_CRYPT0 )) prnt(" Crypt: Secured page, keys not locked");
47 if( isset (fuses,FUSE_CRYPT1) && notset( fuses, FUSE_CRYPT0 )) prnt(" Crypt: Secured page, keys not locked");
48 if( notset (fuses,FUSE_CRYPT1) && isset( fuses, FUSE_CRYPT0 )) prnt(" Crypt: Non secured page");
49 if( notset (fuses,FUSE_CRYPT1) && notset( fuses, FUSE_CRYPT0 )) prnt(" Crypt: No auth possible. Read only if RA is enabled");
50
50282b85 51 if( isset( fuses, FUSE_RA))
52 prnt(" RA: Read access enabled");
53 else
54 prnt(" RA: Read access not enabled");
b67f7ec3 55}
b67f7ec3 56
e98572a1 57void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *max_blk, uint8_t *app_areas, uint8_t *kb) {
58 // mem-bit 5, mem-bit 7, chip-bit 4: defines chip type
76c74bf9 59 uint8_t k16 = isset(mem_cfg, 0x80);
d3fd5fd6 60 //uint8_t k2 = isset(mem_cfg, 0x08);
76c74bf9 61 uint8_t book = isset(mem_cfg, 0x20);
62
63 if(isset(chip_cfg, 0x10) && !k16 && !book) {
e98572a1 64 *kb = 2;
65 *app_areas = 2;
66 *max_blk = 31;
76c74bf9 67 } else if(isset(chip_cfg, 0x10) && k16 && !book) {
e98572a1 68 *kb = 16;
69 *app_areas = 2;
70 *max_blk = 255; //16kb
76c74bf9 71 } else if(notset(chip_cfg, 0x10) && !k16 && !book) {
e98572a1 72 *kb = 16;
73 *app_areas = 16;
74 *max_blk = 255; //16kb
76c74bf9 75 } else if(isset(chip_cfg, 0x10) && k16 && book) {
e98572a1 76 *kb = 32;
77 *app_areas = 3;
78 *max_blk = 255; //16kb
76c74bf9 79 } else if(notset(chip_cfg, 0x10) && !k16 && book) {
e98572a1 80 *kb = 32;
81 *app_areas = 17;
82 *max_blk = 255; //16kb
83 } else {
84 *kb = 32;
85 *app_areas = 2;
86 *max_blk = 255;
87 }
b67f7ec3 88}
e98572a1 89
1d0ccbe0 90void mem_app_config(const picopass_hdr *hdr) {
e98572a1 91 uint8_t mem = hdr->conf.mem_config;
92 uint8_t chip = hdr->conf.chip_config;
b67f7ec3 93 uint8_t applimit = hdr->conf.app_limit;
e98572a1 94 if (applimit < 6) applimit = 26;
95 uint8_t kb = 2;
96 uint8_t app_areas = 2;
97 uint8_t max_blk = 31;
98 getMemConfig(mem, chip, &max_blk, &app_areas, &kb);
99 prnt(" Mem: %u KBits/%u App Areas (%u * 8 bytes) [%02X]", kb, app_areas, max_blk, mem);
100 prnt(" AA1: blocks 06-%02X", applimit);
101 prnt(" AA2: blocks %02X-%02X", applimit+1, max_blk);
76c74bf9 102
103 prnt("");
104 uint8_t book = isset(mem, 0x20);
105 if (book) {
106 prnt("KeyAccess:");
107 prnt("\tRead A - Kd");
108 prnt("\tRead B - Kc");
109 prnt("\tWrite A - Kd");
110 prnt("\tWrite B - Kc");
111 prnt("\tDebit - Kd or Kc");
112 prnt("\tCredit - Kc");
113 } else{
114 prnt("KeyAccess:");
115 prnt("\tRead A - Kd or Kc");
116 prnt("\tRead B - Kd or Kc");
117 prnt("\tWrite A - Kc");
118 prnt("\tWrite B - Kc");
119 prnt("\tDebit - Kd or Kc");
120 prnt("\tCredit - Kc");
121 }
b67f7ec3 122}
1d0ccbe0 123void print_picopass_info(const picopass_hdr *hdr) {
b67f7ec3 124 fuse_config(hdr);
e98572a1 125 mem_app_config(hdr);
b67f7ec3 126}
1d0ccbe0 127void printIclassDumpInfo(uint8_t* iclass_dump) {
1defcf60
MHS
128 print_picopass_info((picopass_hdr *) iclass_dump);
129}
130
131/*
1d0ccbe0 132void test() {
b67f7ec3
MHS
133 picopass_hdr hdr = {0x27,0xaf,0x48,0x01,0xf9,0xff,0x12,0xe0,0x12,0xff,0xff,0xff,0x7f,0x1f,0xff,0x3c};
134 prnt("Picopass configuration:");
135 print_picopass_info(&hdr);
136}
1d0ccbe0 137int main(int argc, char *argv[]) {
b67f7ec3
MHS
138 test();
139 return 0;
140}
1defcf60 141*/
1d0ccbe0 142
143#endif
144//ON_DEVICE
Impressum, Datenschutz