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