mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
style
This commit is contained in:
parent
bc5c07e550
commit
962e58b475
1 changed files with 5 additions and 5 deletions
|
@ -36,22 +36,22 @@ uint8_t checkParity(uint32_t bits, uint8_t len, uint8_t type);
|
||||||
// by marshmellow
|
// by marshmellow
|
||||||
// takes a array of binary values, start position, length of bits per parity (includes parity bit),
|
// takes a array of binary values, start position, length of bits per parity (includes parity bit),
|
||||||
// Parity Type (1 for odd; 0 for even; 2 for Always 1's; 3 for Always 0's), and binary Length (length to run)
|
// Parity Type (1 for odd; 0 for even; 2 for Always 1's; 3 for Always 0's), and binary Length (length to run)
|
||||||
size_t removeParity(uint8_t *bitstream, size_t startIdx, uint8_t pLen, uint8_t pType, size_t bLen) {
|
size_t removeParity(uint8_t *bits, size_t startIdx, uint8_t pLen, uint8_t pType, size_t bLen) {
|
||||||
uint32_t parityWd = 0;
|
uint32_t parityWd = 0;
|
||||||
size_t j = 0, bitcount = 0;
|
size_t j = 0, bitcount = 0;
|
||||||
for (int word = 0; word < (bLen); word += pLen) {
|
for (int word = 0; word < (bLen); word += pLen) {
|
||||||
for (int bit = 0; bit < pLen; ++bit) {
|
for (int bit = 0; bit < pLen; ++bit) {
|
||||||
parityWd = (parityWd << 1) | bitstream[startIdx + word + bit];
|
parityWd = (parityWd << 1) | bits[startIdx + word + bit];
|
||||||
bitstream[j++] = (bitstream[startIdx + word + bit]);
|
bits[j++] = (bits[startIdx + word + bit]);
|
||||||
}
|
}
|
||||||
j--; // overwrite parity with next data
|
j--; // overwrite parity with next data
|
||||||
// if parity fails then return 0
|
// if parity fails then return 0
|
||||||
switch (pType) {
|
switch (pType) {
|
||||||
case 3:
|
case 3:
|
||||||
if (bitstream[j] == 1) return 0;
|
if (bits[j] == 1) return 0;
|
||||||
break; //should be 0 spacer bit
|
break; //should be 0 spacer bit
|
||||||
case 2:
|
case 2:
|
||||||
if (bitstream[j] == 0) return 0;
|
if (bits[j] == 0) return 0;
|
||||||
break; //should be 1 spacer bit
|
break; //should be 1 spacer bit
|
||||||
default: //test parity
|
default: //test parity
|
||||||
if (parityTest(parityWd, pLen, pType) == 0) return 0;
|
if (parityTest(parityWd, pLen, pType) == 0) return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue