]> cvs.zerfleddert.de Git - proxmark3-svn/blame_incremental - common/protocols.c
CHG: spelling mistakes. (
[proxmark3-svn] / common / protocols.c
... / ...
CommitLineData
1#include <string.h>
2#include <stdint.h>
3#include <stdarg.h>
4#include "protocols.h"
5
6// ATA55xx shared presets & routines
7uint32_t GetT55xxClockBit(uint32_t clock) {
8 switch (clock) {
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;
18 }
19}
20
21#ifndef ON_DEVICE
22#include "ui.h"
23#define prnt PrintAndLog
24
25uint8_t isset(uint8_t val, uint8_t mask) {
26 return (val & mask);
27}
28
29uint8_t notset(uint8_t val, uint8_t mask){
30 return !(val & mask);
31}
32
33void fuse_config(const picopass_hdr *hdr) {
34 uint8_t fuses = hdr->conf.fuses;
35
36 if (isset(fuses,FUSE_FPERS))
37 prnt(" Mode: Personalization [Programmable]");
38 else
39 prnt(" Mode: Application [Locked]");
40
41 if (isset(fuses, FUSE_CODING1)) {
42 prnt(" Coding: RFU");
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");
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
54 if( isset( fuses, FUSE_RA))
55 prnt(" RA: Read access enabled");
56 else
57 prnt(" RA: Read access not enabled");
58}
59
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
62 uint8_t k16 = isset(mem_cfg, 0x80);
63 //uint8_t k2 = isset(mem_cfg, 0x08);
64 uint8_t book = isset(mem_cfg, 0x20);
65
66 if(isset(chip_cfg, 0x10) && !k16 && !book) {
67 *kb = 2;
68 *app_areas = 2;
69 *max_blk = 31;
70 } else if(isset(chip_cfg, 0x10) && k16 && !book) {
71 *kb = 16;
72 *app_areas = 2;
73 *max_blk = 255; //16kb
74 } else if(notset(chip_cfg, 0x10) && !k16 && !book) {
75 *kb = 16;
76 *app_areas = 16;
77 *max_blk = 255; //16kb
78 } else if(isset(chip_cfg, 0x10) && k16 && book) {
79 *kb = 32;
80 *app_areas = 3;
81 *max_blk = 255; //16kb
82 } else if(notset(chip_cfg, 0x10) && !k16 && book) {
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 }
91}
92
93void mem_app_config(const picopass_hdr *hdr) {
94 uint8_t mem = hdr->conf.mem_config;
95 uint8_t chip = hdr->conf.chip_config;
96 uint8_t applimit = hdr->conf.app_limit;
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);
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 }
125}
126void print_picopass_info(const picopass_hdr *hdr) {
127 fuse_config(hdr);
128 mem_app_config(hdr);
129}
130void printIclassDumpInfo(uint8_t* iclass_dump) {
131 print_picopass_info((picopass_hdr *) iclass_dump);
132}
133
134/*
135void test() {
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}
140int main(int argc, char *argv[]) {
141 test();
142 return 0;
143}
144*/
145
146#endif
147//ON_DEVICE
Impressum, Datenschutz