mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
CHG: merged the forum user @jason 's fixes to LEGIC. *UNTESTED*
CHG: changed the CRC implementations.
This commit is contained in:
parent
83dad64b91
commit
3e134b4c20
16 changed files with 1368 additions and 163 deletions
|
@ -9,15 +9,13 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "util.h"
|
||||
#include "proxmark3.h"
|
||||
#define MAX_BIN_BREAK_LENGTH (3072+384+1)
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int ukbhit(void)
|
||||
{
|
||||
int ukbhit(void) {
|
||||
int cnt = 0;
|
||||
int error;
|
||||
static struct termios Otty, Ntty;
|
||||
|
@ -553,4 +551,20 @@ uint32_t SwapBits(uint32_t value, int nrbits) {
|
|||
newvalue ^= ((value >> i) & 1) << (nrbits - 1 - i);
|
||||
}
|
||||
return newvalue;
|
||||
}
|
||||
}
|
||||
/*
|
||||
ref http://www.csm.ornl.gov/~dunigan/crc.html
|
||||
Returns the value v with the bottom b [0,32] bits reflected.
|
||||
Example: reflect(0x3e23L,3) == 0x3e26
|
||||
*/
|
||||
uint32_t reflect(uint32_t v, int b) {
|
||||
uint32_t t = v;
|
||||
for ( int i = 0; i < b; ++i) {
|
||||
if (t & 1)
|
||||
v |= BITMASK((b-1)-i);
|
||||
else
|
||||
v &= ~BITMASK((b-1)-i);
|
||||
t>>=1;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue