int ledcontrol = 1;
int n=0, i=0;
uint8_t clk = (arg1 >> 8) & 0xFF;
- uint8_t encoding = arg1 & 1;
+ uint8_t encoding = arg1 & 0xFF;
uint8_t separator = arg2 & 1;
uint8_t invert = (arg2 >> 8) & 1;
uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
uint8_t g_debugMode;
-int DemodBufferLen;
+size_t DemodBufferLen;
static int CmdHelp(const char *Cmd);
//set the demod buffer with given array of binary (one bit per byte)
return 0;
}
uint8_t invert=0;
- ans = indala26decode(DemodBuffer,(size_t *) &DemodBufferLen, &invert);
+ ans = indala26decode(DemodBuffer, &DemodBufferLen, &invert);
if (ans < 1) {
if (g_debugMode==1)
PrintAndLog("Error2: %d",ans);
#define MAX_DEMOD_BUF_LEN (1024*128)
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
-extern int DemodBufferLen;
+extern size_t DemodBufferLen;
extern uint8_t g_debugMode;
#define BIGBUF_SIZE 40000
PrintAndLog(" deskey1 [45/0x2D]: %s [%.4s]", sprint_hex(data+4 ,4),data+4);
PrintAndLog(" deskey2 [46/0x2E]: %s [%.4s]", sprint_hex(data+8 ,4),data+8);
PrintAndLog(" deskey2 [47/0x2F]: %s [%.4s]", sprint_hex(data+12,4),data+12);
- PrintAndLog("\n 3des key : %s", sprint_hex(SwapEndian64(data, 16), 16));
+ PrintAndLog("\n 3des key : %s", sprint_hex(SwapEndian64(data, 16, 8), 16));
return 0;
}
key = default_3des_keys[i];
if (try3DesAuthentication(key) == 1){
PrintAndLog("Found default 3des key: "); //%s", sprint_hex(key,16));
- ulc_print_3deskey(SwapEndian64(key,16));
+ uint8_t keySwap[16];
+ memcpy(keySwap, SwapEndian64(key,16,8), 16);
+ ulc_print_3deskey(keySwap);
return 1;
}
}
if(errors) return usage_hf_mfu_dump();
if (swapEndian)
- keyPtr = SwapEndian64(data, 16);
+ keyPtr = SwapEndian64(data, 16, 8);
TagTypeUL_t tagtype = GetHF14AMfU_Type();
if (tagtype == UL_ERROR) return -1;
hasPwd = TRUE;
}
}
- //uint8_t *key2 = SwapEndian64(key, 16);
+ //uint8_t *key2 = SwapEndian64(key, 16, 8);
//Read Block
UsbCommand c = {CMD_MIFAREU_READBL, {blockNo}};
// to
// hh,gg,ff,ee,dd,cc,bb,aa, pp,oo,nn,mm,ll,kk,jj,ii
// up to 64 bytes or 512 bits
-uint8_t *SwapEndian64(uint8_t *src, size_t len){
- static uint8_t temp[64]={0};
- for (uint8_t block=0; block < (uint8_t)len/8; block++){
- for (size_t i = 0; i < 8; i++){
- temp[i+(8*block)] = src[(7-i)+(8*block)];
+uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize){
+ static uint8_t buf[64];
+ memset(buf, 0x00, 64);
+ uint8_t *tmp = buf;
+ for (uint8_t block=0; block < (uint8_t)(len/blockSize); block++){
+ for (size_t i = 0; i < blockSize; i++){
+ tmp[i+(blockSize*block)] = src[(blockSize-1-i)+(blockSize*block)];
}
}
- return temp;
+ return tmp;
}
//assumes little endian
void num_to_bytes(uint64_t n, size_t len, uint8_t* dest);
uint64_t bytes_to_num(uint8_t* src, size_t len);
char * printBits(size_t const size, void const * const ptr);
-uint8_t *SwapEndian64(uint8_t *src, size_t len);
+uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize);
char param_getchar(const char *line, int paramnum);
uint8_t param_get8(const char *line, int paramnum);