X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/b67f7ec359806293a6da14208bad56b842dedb60..6b659d2406c776790483f2029ee95bdf22b6e659:/common/protocols.c diff --git a/common/protocols.c b/common/protocols.c index bdaff3f1..56a6924f 100644 --- a/common/protocols.c +++ b/common/protocols.c @@ -1,7 +1,13 @@ -#include #include +#include #include #include +#include "protocols.h" +#ifndef ON_DEVICE +#include "ui.h" +#define prnt PrintAndLog +#endif + typedef struct { @@ -25,17 +31,9 @@ typedef struct { }picopass_hdr; -#define FUSE_FPERS 0x80 -#define FUSE_CODING1 0x40 -#define FUSE_CODING0 0x20 -#define FUSE_CRYPT1 0x10 -#define FUSE_CRYPT0 0x08 -#define FUSE_FPROD1 0x04 -#define FUSE_FPROD0 0x02 -#define FUSE_RA 0x01 //#define prnt printf -void prnt(char *fmt,...) +/*void prnt(char *fmt,...) { va_list argptr; va_start(argptr, fmt); @@ -44,7 +42,7 @@ void prnt(char *fmt,...) va_end(argptr); printf("\n"); } - +*/ uint8_t isset(uint8_t val, uint8_t mask) { return (val & mask); @@ -76,25 +74,39 @@ void fuse_config(const picopass_hdr *hdr) if( isset( fuses, FUSE_RA)) prnt(" RA: Read access enabled"); else prnt(" RA: Read access not enabled"); } -void mem_config(const picopass_hdr *hdr) +void mem_app_config(const picopass_hdr *hdr) { uint8_t mem = hdr->conf.mem_config; - if( isset (mem, 0x80)) prnt(" Mem: 16KBits (255 * 8 bytes)"); - else prnt(" Mem: 2 KBits ( 32 * 8 bytes)"); - -} -void applimit_config(const picopass_hdr *hdr) -{ uint8_t applimit = hdr->conf.app_limit; - prnt(" AA1: blocks 6-%d", applimit); - prnt(" AA2: blocks %d-", (applimit+1)); + if (applimit < 6) applimit = 26; + uint8_t kb=2; + uint8_t maxBlk = 32; + if( isset(mem, 0x10) && notset(mem, 0x80)){ + // 2kb default + } else if( isset(mem, 0x80) && notset(mem, 0x10)){ + kb = 16; + maxBlk = 255; //16kb + } else { + kb = 32; + maxBlk = 255; + } + prnt(" Mem: %u KBits ( %u * 8 bytes) [%02X]", kb, maxBlk, mem); + prnt(" AA1: blocks 06-%02X", applimit); + prnt(" AA2: blocks %02X-%02X", (applimit+1), (hdr->conf.mem_config)); } void print_picopass_info(const picopass_hdr *hdr) { fuse_config(hdr); - mem_config(hdr); - applimit_config(hdr); + mem_app_config(hdr); +} +void printIclassDumpInfo(uint8_t* iclass_dump) +{ +// picopass_hdr hdr; +// memcpy(&hdr, iclass_dump, sizeof(picopass_hdr)); + print_picopass_info((picopass_hdr *) iclass_dump); } + +/* void test() { picopass_hdr hdr = {0x27,0xaf,0x48,0x01,0xf9,0xff,0x12,0xe0,0x12,0xff,0xff,0xff,0x7f,0x1f,0xff,0x3c}; @@ -106,3 +118,4 @@ int main(int argc, char *argv[]) test(); return 0; } +*/