mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
Merge remote-tracking branch 'upstream/master' into hf_mf_sim
This commit is contained in:
commit
2278d3372e
27 changed files with 281 additions and 175 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
volatile unsigned long c;
|
||||
|
||||
// 直接使用循环来延时,一个循环 6 条指令,48M, Delay=1 大概为 200kbps
|
||||
// 直接使用循环来延时,一个循环 6 条指令,48M, Delay=1 大概为 200kbps
|
||||
// timer.
|
||||
// I2CSpinDelayClk(4) = 12.31us
|
||||
// I2CSpinDelayClk(1) = 3.07us
|
||||
|
@ -467,8 +467,7 @@ int16_t I2C_BufferRead(uint8_t *data, uint8_t len, uint8_t device_cmd, uint8_t d
|
|||
*data = (uint8_t)tmp & 0xFF;
|
||||
|
||||
len--;
|
||||
|
||||
// 读取的第一个字节为后续长度
|
||||
// 读取的第一个字节为后续长度
|
||||
// The first byte in response is the message length
|
||||
if (!readcount && (len > *data)) {
|
||||
len = *data;
|
||||
|
|
|
@ -445,11 +445,11 @@ int ManchesterEncode(uint8_t *bits, size_t size) {
|
|||
|
||||
// by marshmellow
|
||||
// to detect a wave that has heavily clipped (clean) samples
|
||||
// loop 512 samples, if 250 of them is deemed maxed out, we assume the wave is clipped.
|
||||
// loop 1024 samples, if 250 of them is deemed maxed out, we assume the wave is clipped.
|
||||
bool DetectCleanAskWave(uint8_t *dest, size_t size, uint8_t high, uint8_t low) {
|
||||
bool allArePeaks = true;
|
||||
uint16_t cntPeaks = 0;
|
||||
size_t loopEnd = 512 + 160;
|
||||
size_t loopEnd = 1024 + 160;
|
||||
|
||||
// sanity check
|
||||
if (loopEnd > size) loopEnd = size;
|
||||
|
@ -463,7 +463,8 @@ bool DetectCleanAskWave(uint8_t *dest, size_t size, uint8_t high, uint8_t low) {
|
|||
}
|
||||
|
||||
if (!allArePeaks) {
|
||||
if (cntPeaks > 250) return true;
|
||||
if (g_debugMode == 2) prnt("DEBUG DetectCleanAskWave: peaks (200) %u", cntPeaks);
|
||||
if (cntPeaks > 200) return true;
|
||||
}
|
||||
return allArePeaks;
|
||||
}
|
||||
|
@ -520,12 +521,12 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
|
|||
|
||||
int foo = getClosestClock(minClk);
|
||||
if (foo > 0) {
|
||||
for (uint8_t i = 0; i < 10; i++) {
|
||||
if (tmpclk[i][0] == foo) {
|
||||
tmpclk[i][1]++;
|
||||
for (uint8_t j = 0; j < 10; j++) {
|
||||
if (tmpclk[j][0] == foo) {
|
||||
tmpclk[j][1]++;
|
||||
|
||||
if (tmpclk[i][2] == 0) {
|
||||
tmpclk[i][2] = shortestWaveIdx;
|
||||
if (tmpclk[j][2] == 0) {
|
||||
tmpclk[j][2] = shortestWaveIdx;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -535,18 +536,18 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
|
|||
|
||||
// find the clock with most hits and it the first index it was encountered.
|
||||
int max = 0;
|
||||
for (uint8_t i = 0; i < 10; i++) {
|
||||
for (uint8_t j = 0; j < 10; j++) {
|
||||
if (g_debugMode == 2) {
|
||||
prnt("DEBUG, ASK, clocks %u | hits %u | idx %u"
|
||||
, tmpclk[i][0]
|
||||
, tmpclk[i][1]
|
||||
, tmpclk[i][2]
|
||||
, tmpclk[j][0]
|
||||
, tmpclk[j][1]
|
||||
, tmpclk[j][2]
|
||||
);
|
||||
}
|
||||
if (max < tmpclk[i][1]) {
|
||||
*clock = tmpclk[i][0];
|
||||
shortestWaveIdx = tmpclk[i][2];
|
||||
max = tmpclk[i][1];
|
||||
if (max < tmpclk[j][1]) {
|
||||
*clock = tmpclk[j][0];
|
||||
shortestWaveIdx = tmpclk[j][2];
|
||||
max = tmpclk[j][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ extern size_t removeParity(uint8_t *bits, size_t startIdx, uint8_t pLen, uint8
|
|||
|
||||
//tag specific
|
||||
extern int detectAWID(uint8_t *dest, size_t *size, int *waveStartIdx);
|
||||
extern int Em410xDecode(uint8_t *dest, size_t *size, size_t *startIdx, uint32_t *hi, uint64_t *lo);
|
||||
extern int Em410xDecode(uint8_t *bits, size_t *size, size_t *start_idx, uint32_t *hi, uint64_t *lo);
|
||||
extern int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo, int *waveStartIdx);
|
||||
extern int detectIdteck(uint8_t *dest, size_t *size);
|
||||
extern int detectIOProx(uint8_t *dest, size_t *size, int *waveStartIdx);
|
||||
|
|
|
@ -72,20 +72,20 @@ size_t removeParity(uint8_t *bits, size_t startIdx, uint8_t pLen, uint8_t pType,
|
|||
// Make sure *dest is long enough to store original sourceLen + #_of_parities_to_be_added
|
||||
/*
|
||||
* @brief addParity
|
||||
* @param bits pointer to the source bitstream of binary values
|
||||
* @param src pointer to the source bitstream of binary values
|
||||
* @param dest pointer to the destination where parities together with bits are added.
|
||||
* @param sourceLen number of
|
||||
* @param pLen length bits to be checked
|
||||
* @param pType EVEN|ODD|2 (always 1's)|3 (always 0's)
|
||||
* @return
|
||||
*/
|
||||
size_t addParity(uint8_t *bits, uint8_t *dest, uint8_t sourceLen, uint8_t pLen, uint8_t pType) {
|
||||
size_t addParity(uint8_t *src, uint8_t *dest, uint8_t sourceLen, uint8_t pLen, uint8_t pType) {
|
||||
uint32_t parityWd = 0;
|
||||
size_t j = 0, bitCnt = 0;
|
||||
for (int word = 0; word < sourceLen; word += pLen - 1) {
|
||||
for (int bit = 0; bit < pLen - 1; ++bit) {
|
||||
parityWd = (parityWd << 1) | bits[word + bit];
|
||||
dest[j++] = (bits[word + bit]);
|
||||
parityWd = (parityWd << 1) | src[word + bit];
|
||||
dest[j++] = (src[word + bit]);
|
||||
}
|
||||
|
||||
// if parity fails then return 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue