fixes: removal of TRUE/FALSE defines into bools

This commit is contained in:
iceman1001 2017-07-14 16:20:34 +02:00
commit ec16d16d05
15 changed files with 128 additions and 121 deletions

View file

@ -1280,13 +1280,14 @@ static command_t CommandTable[] = {
{"nedap", CmdLFNedap, 1, "{ Nedap RFIDs... }"},
{"nexwatch", CmdLFNexWatch, 1, "{ NexWatch RFIDs... }"},
{"noralsy", CmdLFNoralsy, 1, "{ Noralsy RFIDs... }"},
{"pac", CmdLFPac, 1, "{ PAC/Stanley RFIDs...}"},
{"pac", CmdLFPac, 1, "{ PAC/Stanley RFIDs... }"},
{"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 RFIDs... }"},
{"presco", CmdLFPresco, 1, "{ Presco RFIDs... }"},
{"pyramid", CmdLFPyramid, 1, "{ Farpointe/Pyramid RFIDs... }"},
{"securakey", CmdLFSecurakey, 1, "{ Securakey RFIDs... }"},
{"ti", CmdLFTI, 1, "{ TI RFIDs... }"},
{"t55xx", CmdLFT55XX, 1, "{ T55xx RFIDs... }"},
{"securakey", CmdLFSecurakey, 1, "{ Securakey RFIDs... }"},
{"viking", CmdLFViking, 1, "{ Viking RFIDs... }"},
{"visa2000", CmdLFVisa2k, 1, "{ Visa2000 RFIDs... }"},
{"config", CmdLFSetConfig, 0, "Set config for LF sampling, bit/sample, decimation, frequency"},

View file

@ -58,14 +58,13 @@ int CmdEM410xRead(const char *Cmd)
}
// emulate an EM410X tag
int CmdEM410xSim(const char *Cmd)
{
int i, n, j, binary[4], parity[4];
uint8_t uid[5] = {0x00};
int CmdEM410xSim(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0);
if (cmdp == 'h' || cmdp == 'H') return usage_lf_em410x_sim();
int i, n, j, binary[4], parity[4];
uint8_t uid[5] = {0x00};
/* clock is 64 in EM410x tags */
uint8_t clock = 64;
@ -132,6 +131,8 @@ int CmdEM410xSim(const char *Cmd)
* rate gets lower, then grow the number of samples
* Changed by martin, 4000 x 4 = 16000,
* see http://www.proxmark.org/forum/viewtopic.php?pid=7235#p7235
*
* EDIT -- capture enough to get 2 complete preambles at the slowest data rate known to be used (rf/64) (64*64*2+9 = 8201) marshmellow
*/
int CmdEM410xWatch(const char *Cmd) {
do {
@ -224,9 +225,9 @@ bool EM_EndParityTest(uint8_t *BitStream, size_t size, uint8_t rows, uint8_t col
for (uint8_t rowNum = 0; rowNum < rows; rowNum++) {
colP ^= BitStream[(rowNum*cols)+colNum];
}
if (colP != pType) return FALSE;
if (colP != pType) return false;
}
return TRUE;
return true;
}
bool EM_ByteParityTest(uint8_t *BitStream, size_t size, uint8_t rows, uint8_t cols, uint8_t pType)
@ -238,9 +239,9 @@ bool EM_ByteParityTest(uint8_t *BitStream, size_t size, uint8_t rows, uint8_t co
for (uint8_t colNum = 0; colNum < cols; colNum++) {
rowP ^= BitStream[(rowNum*cols)+colNum];
}
if (rowP != pType) return FALSE;
if (rowP != pType) return false;
}
return TRUE;
return true;
}
// EM word parity test.
@ -256,12 +257,12 @@ bool EM_ByteParityTest(uint8_t *BitStream, size_t size, uint8_t rows, uint8_t co
bool EMwordparitytest(uint8_t *bits){
// last row/col parity must be 0
if (bits[44] != 0 ) return FALSE;
if (bits[44] != 0 ) return false;
// col parity check
uint8_t c1 = bytebits_to_byte(bits, 8) ^ bytebits_to_byte(bits+9, 8) ^ bytebits_to_byte(bits+18, 8) ^ bytebits_to_byte(bits+27, 8);
uint8_t c2 = bytebits_to_byte(bits+36, 8);
if ( c1 != c2 ) return FALSE;
if ( c1 != c2 ) return false;
// row parity check
uint8_t rowP = 0;
@ -271,13 +272,13 @@ bool EMwordparitytest(uint8_t *bits){
if ( i>0 && (i % 9) == 0) {
if ( rowP != EVEN )
return FALSE;
return false;
rowP = 0;
}
}
// all checks ok.
return TRUE;
return true;
}
@ -355,7 +356,6 @@ uint32_t OutputEM4x50_Block(uint8_t *BitStream, size_t size, bool verbose, bool
return code;
}
/* Read the transmitted data of an EM4x50 tag from the graphbuffer
* Format:
*
@ -593,10 +593,10 @@ bool downloadSamplesEM(){
GetFromBigBuf(got, sizeof(got), 0);
if ( !WaitForResponseTimeout(CMD_ACK, NULL, 2500) ) {
PrintAndLog("command execution time out");
return FALSE;
return false;
}
setGraphBuf(got, sizeof(got));
return TRUE;
return true;
}
// em_demod
@ -605,7 +605,7 @@ bool doPreambleSearch(size_t *startIdx){
// sanity check
if ( DemodBufferLen < EM_PREAMBLE_LEN) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 demodbuffer too small");
return FALSE;
return false;
}
// set size to 20 to only test first 14 positions for the preamble
@ -614,73 +614,73 @@ bool doPreambleSearch(size_t *startIdx){
// skip first two 0 bits as they might have been missed in the demod
uint8_t preamble[EM_PREAMBLE_LEN] = {0,0,1,0,1,0};
if ( !preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, startIdx, TRUE)) {
if ( !preambleSearchEx(DemodBuffer, preamble, EM_PREAMBLE_LEN, &size, startIdx, true)) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 preamble not found :: %d", *startIdx);
return FALSE;
return false;
}
return TRUE;
return true;
}
bool detectFSK(){
// detect fsk clock
if (!GetFskClock("", FALSE, FALSE)) {
if (!GetFskClock("", false, false)) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: FSK clock failed");
return FALSE;
return false;
}
// demod
int ans = FSKrawDemod("0 0", FALSE);
int ans = FSKrawDemod("0 0", false);
if (!ans) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: FSK Demod failed");
return FALSE;
return false;
}
return TRUE;
return true;
}
// PSK clocks should be easy to detect ( but difficult to demod a non-repeating pattern... )
bool detectPSK(){
int ans = GetPskClock("", FALSE, FALSE);
int ans = GetPskClock("", false, false);
if (ans <= 0) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: PSK clock failed");
return FALSE;
return false;
}
//demod
//try psk1 -- 0 0 6 (six errors?!?)
ans = PSKDemod("0 0 6", FALSE);
ans = PSKDemod("0 0 6", false);
if (!ans) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: PSK1 Demod failed");
//try psk1 inverted
ans = PSKDemod("0 1 6", FALSE);
ans = PSKDemod("0 1 6", false);
if (!ans) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: PSK1 inverted Demod failed");
return FALSE;
return false;
}
}
// either PSK1 or PSK1 inverted is ok from here.
// lets check PSK2 later.
return TRUE;
return true;
}
// try manchester - NOTE: ST only applies to T55x7 tags.
bool detectASK_MAN(){
bool stcheck = FALSE;
int ans = ASKDemod_ext("0 0 0", FALSE, FALSE, 1, &stcheck);
bool stcheck = false;
int ans = ASKDemod_ext("0 0 0", false, false, 1, &stcheck);
if (!ans) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: ASK/Manchester Demod failed");
return FALSE;
return false;
}
return TRUE;
return true;
}
bool detectASK_BI(){
int ans = ASKbiphaseDemod("0 0 1", FALSE);
int ans = ASKbiphaseDemod("0 0 1", false);
if (!ans) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: ASK/biphase normal demod failed");
ans = ASKbiphaseDemod("0 1 1", FALSE);
ans = ASKbiphaseDemod("0 1 1", false);
if (!ans) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM: ASK/biphase inverted demod failed");
return FALSE;
return false;
}
}
return TRUE;
return true;
}
// param: idx - start index in demoded data.
@ -691,17 +691,17 @@ bool setDemodBufferEM(uint32_t *word, size_t idx){
memcpy( parity, DemodBuffer, 45);
if (!EMwordparitytest(parity) ){
PrintAndLog("DEBUG: Error - EM Parity tests failed");
return FALSE;
return false;
}
// test for even parity bits and remove them. (leave out the end row of parities so 36 bits)
if (!removeParity(DemodBuffer, idx + EM_PREAMBLE_LEN, 9, 0, 36)) {
if (g_debugMode) PrintAndLog("DEBUG: Error - EM, failed removing parity");
return FALSE;
return false;
}
setDemodBuf(DemodBuffer, 32, 0);
*word = bytebits_to_byteLSBF(DemodBuffer, 32);
return TRUE;
return true;
}
// FSK, PSK, ASK/MANCHESTER, ASK/BIPHASE, ASK/DIPHASE
@ -727,7 +727,7 @@ bool demodEM4x05resp(uint32_t *word) {
if (doPreambleSearch( &idx ))
return setDemodBufferEM(word, idx);
}
return FALSE;
return false;
}
//////////////// 4205 / 4305 commands
@ -1011,7 +1011,7 @@ void printEM4x05ProtectionBits(uint32_t word) {
//quick test for EM4x05/EM4x69 tag
bool EM4x05IsBlock0(uint32_t *word) {
return EM4x05ReadWord_ext(0, 0, FALSE, word);
return EM4x05ReadWord_ext(0, 0, false, word);
}
int CmdEM4x05Info(const char *Cmd) {

View file

@ -12,6 +12,7 @@
#define CMDLFEM4X_H__
#include <stdio.h>
#include <stdbool.h> // for bool
#include <string.h>
#include <inttypes.h>
#include "proxmark3.h"
@ -25,17 +26,17 @@
#include "cmdlf.h"
#include "lfdemod.h"
int CmdEMdemodASK(const char *Cmd);
int CmdEM410xRead(const char *Cmd);
int CmdEM410xSim(const char *Cmd);
int CmdEM410xWatch(const char *Cmd);
int CmdEM410xWatchnSpoof(const char *Cmd);
int CmdEM410xWrite(const char *Cmd);
int CmdEM4x50Read(const char *Cmd);
int CmdLFEM4X(const char *Cmd);
int CmdReadWord(const char *Cmd);
int CmdWriteWord(const char *Cmd);
int EM4x50Read(const char *Cmd, bool verbose);
extern int CmdEMdemodASK(const char *Cmd);
extern int CmdEM410xRead(const char *Cmd);
extern int CmdEM410xSim(const char *Cmd);
extern int CmdEM410xWatch(const char *Cmd);
extern int CmdEM410xWatchnSpoof(const char *Cmd);
extern int CmdEM410xWrite(const char *Cmd);
extern int CmdEM4x50Read(const char *Cmd);
extern int CmdLFEM4X(const char *Cmd);
extern int CmdReadWord(const char *Cmd);
extern int CmdWriteWord(const char *Cmd);
extern int EM4x50Read(const char *Cmd, bool verbose);
bool EM4x05IsBlock0(uint32_t *word);

View file

@ -128,7 +128,7 @@ int CmdFdxDemod(const char *Cmd) {
//Differential Biphase / di-phase (inverted biphase)
//get binary from ask wave
if (!ASKbiphaseDemod("0 32 1 0", FALSE)) {
if (!ASKbiphaseDemod("0 32 1 0", false)) {
if (g_debugMode) PrintAndLog("DEBUG: Error - FDX-B ASKbiphaseDemod failed");
return 0;
}

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency fdx-b tag commands
//-----------------------------------------------------------------------------
#ifndef CMDLFFDX_H__
#define CMDLFFDX_H__
@ -19,11 +19,12 @@
#include "protocols.h" // for T55xx config register definitions
#include "lfdemod.h" // parityTest
int CmdLFFdx(const char *Cmd);
int CmdFdxClone(const char *Cmd);
int CmdFdxSim(const char *Cmd);
int CmdFdxRead(const char *Cmd);
int CmdFdxDemod(const char *Cmd);
extern int CmdLFFdx(const char *Cmd);
extern int CmdFdxClone(const char *Cmd);
extern int CmdFdxSim(const char *Cmd);
extern int CmdFdxRead(const char *Cmd);
extern int CmdFdxDemod(const char *Cmd);
int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits);
int usage_lf_fdx_clone(void);
int usage_lf_fdx_sim(void);

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency Jablotron tag commands
//-----------------------------------------------------------------------------
#ifndef CMDLFJABLOTRON_H__
#define CMDLFJABLOTRON_H__

View file

@ -60,7 +60,7 @@ int CmdPSKNexWatch(const char *Cmd)
//output
PrintAndLog("NexWatch ID: %d", ID);
if (invert){
PrintAndLog("Had to Invert - probably NexKey");
PrintAndLog("DEBUG: Error - NexWatch had to Invert - probably NexKey");
for (uint8_t idx=0; idx<size; idx++)
DemodBuffer[idx] ^= 1;
}

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency Noralsy tag commands
//-----------------------------------------------------------------------------
#ifndef CMDLFNORALSY_H__
#define CMDLFNORALSY_H__
@ -21,11 +21,12 @@
#include "cmdlf.h"
#include "protocols.h" // for T55xx config register definitions
#include "lfdemod.h" // parityTest
int CmdLFNoralsy(const char *Cmd);
int CmdNoralsyClone(const char *Cmd);
int CmdNoralsySim(const char *Cmd);
int CmdNoralsyRead(const char *Cmd);
int CmdNoralsyDemod(const char *Cmd);
extern int CmdLFNoralsy(const char *Cmd);
extern int CmdNoralsyClone(const char *Cmd);
extern int CmdNoralsySim(const char *Cmd);
extern int CmdNoralsyRead(const char *Cmd);
extern int CmdNoralsyDemod(const char *Cmd);
int getnoralsyBits(uint32_t id, uint16_t year, uint8_t *bits);

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency Presco tag commands
//-----------------------------------------------------------------------------
#ifndef CMDLFPRESCO_H__
#define CMDLFPRESCO_H__
@ -18,11 +18,12 @@
#include "cmdlf.h"
#include "protocols.h" // for T55xx config register definitions
#include "lfdemod.h" // parityTest
int CmdLFPresco(const char *Cmd);
int CmdPrescoClone(const char *Cmd);
int CmdPrescoSim(const char *Cmd);
int CmdPrescoRead(const char *Cmd);
int CmdPrescoDemod(const char *Cmd);
extern int CmdLFPresco(const char *Cmd);
extern int CmdPrescoClone(const char *Cmd);
extern int CmdPrescoSim(const char *Cmd);
extern int CmdPrescoRead(const char *Cmd);
extern int CmdPrescoDemod(const char *Cmd);
int GetWiegandFromPresco(const char *id, uint32_t *sitecode, uint32_t *usercode, uint32_t *fullcode, bool *Q5);

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency Farpoint / Pyramid commands
//-----------------------------------------------------------------------------
#ifndef CMDLFPYRAMID_H__
#define CMDLFPYRAMID_H__

View file

@ -55,7 +55,7 @@ int usage_t55xx_read(){
return 0;
}
int usage_t55xx_write(){
PrintAndLog("Usage: lf t55xx wr [b <block>] [d <data>] [p <password>] [1]");
PrintAndLog("Usage: lf t55xx write [b <block>] [d <data>] [p <password>] [1]");
PrintAndLog("Options:");
PrintAndLog(" b <block> - block number to write. Between 0-7");
PrintAndLog(" d <data> - 4 bytes of data to write (8 hex characters)");

View file

@ -4,7 +4,8 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency Viking tag commands
// Low frequency Viking tag commands (AKA FDI Matalec Transit)
// ASK/Manchester, RF/32, 64 bits (complete)
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
@ -60,7 +61,7 @@ int CmdVikingRead(const char *Cmd) {
// read lf silently
CmdLFRead("s");
// get samples silently
getSamples("12000", TRUE);
getSamples("12000", true);
// demod and output viking ID
return CmdVikingDemod(Cmd);
}

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency viking tag commands
//-----------------------------------------------------------------------------
#ifndef CMDLFVIKING_H__
#define CMDLFVIKING_H__

View file

@ -4,7 +4,9 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency Presco tag commands
// Low frequency visa 2000 tag commands
// by iceman
// ASK/Manchester, RF/64, STT, 96 bits (complete)
//-----------------------------------------------------------------------------
#include "cmdlfvisa2000.h"
@ -54,14 +56,14 @@ static uint8_t visa_parity( uint32_t id) {
,0,1,1,0
};
uint8_t par = 0;
par |= par_lut[ NIBBLE_HIGH( (id >> 24) & 0xFF) ] << 7;
par |= par_lut[ NIBBLE_LOW( (id >> 24) & 0xFF) ] << 6;
par |= par_lut[ NIBBLE_HIGH( (id >> 16) & 0xFF) ] << 5;
par |= par_lut[ NIBBLE_LOW( (id >> 16) & 0xFF) ] << 4;
par |= par_lut[ NIBBLE_HIGH( (id >> 8) & 0xFF) ] << 3;
par |= par_lut[ NIBBLE_LOW( (id >> 8) & 0xFF) ] << 2;
par |= par_lut[ NIBBLE_HIGH( id & 0xFF ) ] << 1;
par |= par_lut[ NIBBLE_LOW( id & 0xFF) ];
par |= par_lut[ (id >> 28) & 0xF ] << 7;
par |= par_lut[ (id >> 24) & 0xF ] << 6;
par |= par_lut[ (id >> 20) & 0xF ] << 5;
par |= par_lut[ (id >> 16) & 0xF ] << 4;
par |= par_lut[ (id >> 12) & 0xF ] << 3;
par |= par_lut[ (id >> 8) & 0xF ] << 2;
par |= par_lut[ (id >> 4) & 0xF ] << 1;
par |= par_lut[ (id & 0xF) ];
return par;
}
@ -69,12 +71,12 @@ static uint8_t visa_parity( uint32_t id) {
/**
*
* 56495332 00096ebd 00000077 > tag id 618173
* aaaaaaaa iiiiiiii -----..c
* aaaaaaaa iiiiiiii -----ppc
*
* a = fixed value ascii 'VIS2'
* i = card id
* p = even parity bit for each nibble in card id.
* c = checksum (xor of card id)
* . = unknown
*
**/
//see ASKDemod for what args are accepted
@ -86,8 +88,8 @@ int CmdVisa2kDemod(const char *Cmd) {
//sCmdAskEdgeDetect("");
//ASK / Manchester
bool st = TRUE;
if (!ASKDemod_ext("64 0 0", FALSE, FALSE, 1, &st)) {
bool st = true;
if (!ASKDemod_ext("64 0 0", false, false, 1, &st)) {
if (g_debugMode) PrintAndLog("DEBUG: Error - Visa2k: ASK/Manchester Demod failed");
save_restoreGB(0);
return 0;
@ -142,7 +144,7 @@ int CmdVisa2kDemod(const char *Cmd) {
// 64*96*2=12288 samples just in case we just missed the first preamble we can still catch 2 of them
int CmdVisa2kRead(const char *Cmd) {
CmdLFRead("s");
getSamples("12500",TRUE);
getSamples("12500",true);
return CmdVisa2kDemod(Cmd);
}
@ -162,7 +164,6 @@ int CmdVisa2kClone(const char *Cmd) {
blocks[0] = T5555_MODULATION_MANCHESTER | ((64-2)>>1) << T5555_BITRATE_SHIFT | T5555_ST_TERMINATOR | 3 << T5555_MAXBLOCK_SHIFT;
}
//
blocks[2] = id;
blocks[3] = (visa_parity(id) << 4) | visa_chksum(id);

View file

@ -4,7 +4,7 @@
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// Low frequency T55xx commands
// Low frequency visa 2000 commands
//-----------------------------------------------------------------------------
#ifndef CMDLFVISA2000_H__
#define CMDLFVISA2000_H__
@ -21,11 +21,11 @@
#include "cmdlf.h"
#include "protocols.h" // for T55xx config register definitions
#include "lfdemod.h" // parityTest
int CmdLFVisa2k(const char *Cmd);
int CmdVisa2kClone(const char *Cmd);
int CmdVisa2kSim(const char *Cmd);
int CmdVisa2kRead(const char *Cmd);
int CmdVisa2kDemod(const char *Cmd);
extern int CmdLFVisa2k(const char *Cmd);
extern int CmdVisa2kClone(const char *Cmd);
extern int CmdVisa2kSim(const char *Cmd);
extern int CmdVisa2kRead(const char *Cmd);
extern int CmdVisa2kDemod(const char *Cmd);
int getvisa2kBits(uint64_t fullcode, uint8_t *bits);