+#define MAX_LENGTH 1024
+
+int usage_legic_calccrc(void){
+ PrintAndLog("Calculates the legic crc8/crc16 on the input hexbytes.");
+ PrintAndLog("There must be an even number of hexsymbols as input.");
+ PrintAndLog("Usage: hf legic crc [h] b <hexbytes> u <uidcrc> c <crc type>");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" b <hexbytes> : hex bytes");
+ PrintAndLog(" u <uidcrc> : MCC hexbyte");
+ PrintAndLog(" c <crc type> : 8|16 bit crc size");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic crc b deadbeef1122");
+ PrintAndLog(" hf legic crc b deadbeef1122 u 9A c 16");
+ return 0;
+}
+int usage_legic_load(void){
+ PrintAndLog("It loads datasamples from the file `filename` to device memory");
+ PrintAndLog("Usage: hf legic load [h] <file name>");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" <filename> : Name of file to load");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic load filename");
+ return 0;
+}
+int usage_legic_rdmem(void){
+ PrintAndLog("Read data from a legic tag.");
+ PrintAndLog("Usage: hf legic rdmem [h] <offset> <length> <IV>");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" <offset> : offset in data array to start download from (hex)");
+ PrintAndLog(" <length> : number of bytes to read (hex)");
+ PrintAndLog(" <IV> : (optional) Initialization vector to use (hex, odd and 7bits)");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic rdmem 0 21 - reads from byte[0] 21 bytes(system header)");
+ PrintAndLog(" hf legic rdmem 0 4 55 - reads from byte[0] 4 bytes with IV 0x55");
+ PrintAndLog(" hf legic rdmem 0 100 55 - reads 256bytes with IV 0x55");
+ return 0;
+}
+int usage_legic_sim(void){
+ PrintAndLog("Missing help text.");
+ return 0;
+}
+int usage_legic_write(void){
+ PrintAndLog(" Write sample buffer to a legic tag. (use after load or read)");
+ PrintAndLog("Usage: hf legic write [h] <offset> <length> <IV>");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" <offset> : offset in data array to start writing from (hex)");
+ PrintAndLog(" <length> : number of bytes to write (hex)");
+ PrintAndLog(" <IV> : (optional) Initialization vector to use (ODD and 7bits)");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic write 10 4 - writes 0x4 to byte[0x10]");
+ return 0;
+}
+int usage_legic_reader(void){
+ PrintAndLog("Read UID and type information from a legic tag.");
+ PrintAndLog("Usage: hf legic reader [h]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic reader");
+ return 0;
+}
+int usage_legic_info(void){
+ PrintAndLog("Reads information from a legic prime tag.");
+ PrintAndLog("Shows systemarea, user areas etc");
+ PrintAndLog("Usage: hf legic info [h]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic info");
+ return 0;
+}
+int usage_legic_dump(void){
+ PrintAndLog("Reads all pages from LEGIC MIM22, MIM256, MIM1024");
+ PrintAndLog("and saves binary dump into the file `filename.bin` or `cardUID.bin`");
+ PrintAndLog("It autodetects card type.\n");
+ PrintAndLog("Usage: hf legic dump [h] o <filename w/o .bin>");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" n <FN> : filename w/o .bin to save the dump as");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic dump");
+ PrintAndLog(" hf legic dump o myfile");
+ return 0;
+}
+int usage_legic_eload(void){
+ PrintAndLog("It loads binary dump from the file `filename.bin`");
+ PrintAndLog("Usage: hf legic eload [h] [card memory] <file name w/o `.bin`>");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" [card memory] : 0 = MIM22");
+ PrintAndLog(" : 1 = MIM256 (default)");
+ PrintAndLog(" : 2 = MIM1024");
+ PrintAndLog(" <filename> : filename w/o .bin to load");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic eload filename");
+ PrintAndLog(" hf legic eload 2 filename");
+ return 0;
+}
+int usage_legic_esave(void){
+ PrintAndLog("It saves binary dump into the file `filename.bin` or `cardID.bin`");
+ PrintAndLog(" Usage: hf legic esave [h] [card memory] [file name w/o `.bin`]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h : this help");
+ PrintAndLog(" [card memory] : 0 = MIM22");
+ PrintAndLog(" : 1 = MIM256 (default)");
+ PrintAndLog(" : 2 = MIM1024");
+ PrintAndLog(" <filename> : filename w/o .bin to load");
+ PrintAndLog("");
+ PrintAndLog("Samples:");
+ PrintAndLog(" hf legic esave ");
+ PrintAndLog(" hf legic esave 2");
+ PrintAndLog(" hf legic esave 2 filename");
+ return 0;
+}
+