mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Merge remote-tracking branch 'upstream/master' into hf_mf_sim
This commit is contained in:
commit
c2c4aac7ff
192 changed files with 2630 additions and 2969 deletions
|
@ -21,4 +21,4 @@ typedef struct bucket_info {
|
|||
void bucket_sort_intersect(uint32_t *const estart, uint32_t *const estop,
|
||||
uint32_t *const ostart, uint32_t *const ostop,
|
||||
bucket_info_t *bucket_info, bucket_array_t bucket);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -61,4 +61,4 @@ uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void
|
|||
#endif
|
||||
|
||||
return sendlen;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,4 +123,4 @@ uint32_t CRC8Legic(uint8_t *buff, size_t size) {
|
|||
for (int i = 0; i < size; ++i)
|
||||
crc_update2(&crc, buff[i], 8);
|
||||
return reflect8(crc_finish(&crc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,4 +67,4 @@ void reset_table(void);
|
|||
void generate_table(uint16_t polynomial, bool refin);
|
||||
uint16_t crc16_fast(uint8_t const *d, size_t n, uint16_t initval, bool refin, bool refout);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -29,4 +29,4 @@ void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc) {
|
|||
|
||||
void crc32_append(uint8_t *data, const size_t len) {
|
||||
crc32_ex(data, len, data + len);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,4 +80,4 @@ void crc64(const uint8_t *data, const size_t len, uint64_t *crc) {
|
|||
}
|
||||
}
|
||||
|
||||
//suint8_t x = (c & 0xFF00000000000000 ) >> 56;
|
||||
//suint8_t x = (c & 0xFF00000000000000 ) >> 56;
|
||||
|
|
|
@ -48,4 +48,4 @@ void SmartCardUpgrade(uint64_t arg0);
|
|||
void SmartCardSetBaud(uint64_t arg0);
|
||||
void SmartCardSetClock(uint64_t arg0);
|
||||
void I2C_print_status(void);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
// return: ptr to string
|
||||
char *Iso15693sprintUID(char *target, uint8_t *uid) {
|
||||
|
||||
static char tempbuf[2 * 8 + 1] = {0};
|
||||
static char tempbuf[3 * 8 + 1] = {0};
|
||||
if (target == NULL)
|
||||
target = tempbuf;
|
||||
|
||||
sprintf(target, "%02X %02X %02X %02X %02X %02X %02X %02X",
|
||||
uid[7], uid[6], uid[5], uid[4],
|
||||
uid[3], uid[2], uid[1], uid[0]
|
||||
);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,4 +123,4 @@ static const int Iso15693FrameEOF[] = {
|
|||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -62,4 +62,4 @@ uint32_t legic_prng_get_bits(uint8_t len) {
|
|||
legic_prng_forward(1);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1357,6 +1357,7 @@ int BiphaseRawDecode(uint8_t *bits, size_t *size, int *offset, int invert) {
|
|||
//by marshmellow
|
||||
//take 10 and 01 and manchester decode
|
||||
//run through 2 times and take least errCnt
|
||||
// "7" indicates 00 or 11 wrong bit
|
||||
int manrawdecode(uint8_t *bits, size_t *size, uint8_t invert, uint8_t *alignPos) {
|
||||
|
||||
// sanity check
|
||||
|
@ -1368,7 +1369,7 @@ int manrawdecode(uint8_t *bits, size_t *size, uint8_t invert, uint8_t *alignPos)
|
|||
|
||||
//find correct start position [alignment]
|
||||
for (k = 0; k < 2; ++k) {
|
||||
for (i = k; i < *size - 3; i += 2) {
|
||||
for (i = k; i < *size - 1; i += 2) {
|
||||
if (bits[i] == bits[i + 1])
|
||||
errCnt++;
|
||||
}
|
||||
|
@ -1380,7 +1381,7 @@ int manrawdecode(uint8_t *bits, size_t *size, uint8_t invert, uint8_t *alignPos)
|
|||
}
|
||||
*alignPos = bestRun;
|
||||
//decode
|
||||
for (i = bestRun; i < *size - 3; i += 2) {
|
||||
for (i = bestRun; i < *size - 1; i += 2) {
|
||||
if (bits[i] == 1 && (bits[i + 1] == 0)) {
|
||||
bits[bitnum++] = invert;
|
||||
} else if ((bits[i] == 0) && bits[i + 1] == 1) {
|
||||
|
@ -1472,16 +1473,21 @@ int askdemod_ext(uint8_t *bits, size_t *size, int *clk, int *invert, int maxErr,
|
|||
|
||||
if (*size == 0) return -1;
|
||||
|
||||
if (signalprop.isnoise) {
|
||||
if (g_debugMode == 2) prnt("DEBUG (askdemod_ext) just noise detected - aborting");
|
||||
return -2;
|
||||
}
|
||||
|
||||
int start = DetectASKClock(bits, *size, clk, maxErr);
|
||||
if (*clk == 0 || start < 0) return -3;
|
||||
|
||||
|
||||
if (*invert != 1) *invert = 0;
|
||||
|
||||
// amplify signal data.
|
||||
// ICEMAN todo,
|
||||
if (amp == 1) askAmp(bits, *size);
|
||||
|
||||
if (g_debugMode == 2) prnt("DEBUG ASK: clk %d, beststart %d, amp %d", *clk, start, amp);
|
||||
if (g_debugMode == 2) prnt("DEBUG (askdemod_ext) clk %d, beststart %d, amp %d", *clk, start, amp);
|
||||
|
||||
//start pos from detect ask clock is 1/2 clock offset
|
||||
// NOTE: can be negative (demod assumes rest of wave was there)
|
||||
|
@ -1489,12 +1495,6 @@ int askdemod_ext(uint8_t *bits, size_t *size, int *clk, int *invert, int maxErr,
|
|||
uint16_t initLoopMax = 1024;
|
||||
if (initLoopMax > *size) initLoopMax = *size;
|
||||
|
||||
// just noise - no super good detection. good enough
|
||||
if (signalprop.isnoise) {
|
||||
if (g_debugMode == 2) prnt("DEBUG askdemod_ext: just noise detected - aborting");
|
||||
return -2;
|
||||
}
|
||||
|
||||
// Detect high and lows
|
||||
//25% clip in case highs and lows aren't clipped [marshmellow]
|
||||
int high, low;
|
||||
|
@ -1538,7 +1538,7 @@ int askdemod_ext(uint8_t *bits, size_t *size, int *clk, int *invert, int maxErr,
|
|||
bits[bitnum++] = *invert ^ 1;
|
||||
} else if (i - lastBit >= *clk + tol) {
|
||||
if (bitnum > 0) {
|
||||
if (g_debugMode == 2) prnt("DEBUG: (askdemod_ext) Modulation Error at: %u", i);
|
||||
// if (g_debugMode == 2) prnt("DEBUG: (askdemod_ext) Modulation Error at: %u", i);
|
||||
bits[bitnum++] = 7;
|
||||
errCnt++;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "util.h" // for ARRAYLEN
|
||||
|
||||
//might not be high enough for noisy environments
|
||||
#define NOISE_AMPLITUDE_THRESHOLD 10
|
||||
#define NOISE_AMPLITUDE_THRESHOLD 15
|
||||
//ignore buffer with less than x samples
|
||||
#define SIGNAL_MIN_SAMPLES 100
|
||||
//ignore first x samples of the buffer
|
||||
|
|
|
@ -21,4 +21,4 @@ void burtle_init_mod(prng_ctx *x, uint32_t seed);
|
|||
void burtle_init(prng_ctx *x, uint32_t seed);
|
||||
|
||||
uint32_t GetSimplePrng(uint32_t seed);
|
||||
#endif /* __PRNG_H */
|
||||
#endif /* __PRNG_H */
|
||||
|
|
|
@ -277,6 +277,7 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
|
|||
#define ISO_15693 7
|
||||
#define FELICA 8
|
||||
#define PROTO_MIFARE 9
|
||||
#define PROTO_HITAG 10
|
||||
|
||||
//-- Picopass fuses
|
||||
#define FUSE_FPERS 0x80
|
||||
|
|
|
@ -96,4 +96,4 @@ uint64_t *radixSort(uint64_t *array, uint32_t size) {
|
|||
}
|
||||
free(cpy);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,4 +20,4 @@ typedef union {
|
|||
} rscounts_t;
|
||||
|
||||
uint64_t *radixSort(uint64_t *array, uint32_t size);
|
||||
#endif // RADIXSORT_H__
|
||||
#endif // RADIXSORT_H__
|
||||
|
|
|
@ -18,4 +18,4 @@
|
|||
void fast_prand();
|
||||
void fast_prandEx(uint32_t seed);
|
||||
uint32_t prand();
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -15,4 +15,4 @@
|
|||
#include <stddef.h>
|
||||
void tea_encrypt(uint8_t *v, uint8_t *key);
|
||||
void tea_decrypt(uint8_t *v, uint8_t *key);
|
||||
#endif /* __TEA_H */
|
||||
#endif /* __TEA_H */
|
||||
|
|
|
@ -140,4 +140,4 @@ void usart_init(void) {
|
|||
|
||||
// re-enable receiver / transmitter
|
||||
pUS1->US_CR = (AT91C_US_RXEN | AT91C_US_TXEN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -686,7 +686,7 @@ uint32_t usb_write(const byte_t *data, const size_t len) {
|
|||
}
|
||||
|
||||
UDP_CLEAR_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXCOMP);
|
||||
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP);
|
||||
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {};
|
||||
UDP_SET_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXPKTRDY);
|
||||
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ uint32_t usb_write(const byte_t *data, const size_t len) {
|
|||
}
|
||||
|
||||
UDP_CLEAR_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXCOMP);
|
||||
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP);
|
||||
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {};
|
||||
|
||||
return length;
|
||||
}
|
||||
|
@ -749,9 +749,9 @@ void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) {
|
|||
//*----------------------------------------------------------------------------
|
||||
void AT91F_USB_SendZlp(AT91PS_UDP pUdp) {
|
||||
UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXPKTRDY);
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP));
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP)) {};
|
||||
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_TXCOMP);
|
||||
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP);
|
||||
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_TXCOMP) {};
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
|
@ -760,9 +760,9 @@ void AT91F_USB_SendZlp(AT91PS_UDP pUdp) {
|
|||
//*----------------------------------------------------------------------------
|
||||
void AT91F_USB_SendStall(AT91PS_UDP pUdp) {
|
||||
UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_FORCESTALL);
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_ISOERROR));
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_ISOERROR)) {};
|
||||
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR));
|
||||
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR));
|
||||
while (pUdp->UDP_CSR[AT91C_EP_CONTROL] & (AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR)) {};
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
|
@ -790,10 +790,10 @@ void AT91F_CDC_Enumerate() {
|
|||
|
||||
if (bmRequestType & 0x80) { // Data Phase Transfer Direction Device to Host
|
||||
UDP_SET_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_DIR);
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_DIR));
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_DIR)) {};
|
||||
}
|
||||
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_RXSETUP);
|
||||
while ((pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_RXSETUP));
|
||||
while ((pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_RXSETUP)) {};
|
||||
|
||||
/*
|
||||
if ( bRequest == MS_VENDOR_CODE) {
|
||||
|
@ -933,7 +933,7 @@ void AT91F_CDC_Enumerate() {
|
|||
((uint8_t*)&line)[i] = pUdp->UDP_FDR[AT91C_EP_CONTROL];
|
||||
} */
|
||||
// ignore SET_LINE_CODING...
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_RX_DATA_BK0));
|
||||
while (!(pUdp->UDP_CSR[AT91C_EP_CONTROL] & AT91C_UDP_RX_DATA_BK0)) {};
|
||||
UDP_CLEAR_EP_FLAGS(AT91C_EP_CONTROL, AT91C_UDP_RX_DATA_BK0);
|
||||
AT91F_USB_SendZlp(pUdp);
|
||||
break;
|
||||
|
@ -949,4 +949,4 @@ void AT91F_CDC_Enumerate() {
|
|||
AT91F_USB_SendStall(pUdp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,4 +236,4 @@ void num_to_wiegand_bits(uint64_t oem, uint64_t fc, uint64_t cn, uint8_t *dest,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue