mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-11 01:55:38 +08:00
Reorder & simplify code
This commit is contained in:
parent
03347fcfea
commit
73465e5167
1 changed files with 9 additions and 11 deletions
|
@ -212,24 +212,22 @@ static void createBlocks(uint32_t *blocks, uint8_t rc, uint16_t fc, uint32_t cn,
|
|||
// more obfuscation
|
||||
scramble(arr, ARRAYLEN(arr));
|
||||
|
||||
// every byte is followed by a bit which is the inverse of the last bit
|
||||
uint8_t bonus_bit[8] = {0};
|
||||
for (int i = 0; i < ARRAYLEN(bonus_bit); i++) {
|
||||
bonus_bit[i] = !(arr[i] & 0x1);
|
||||
}
|
||||
|
||||
// calculate checksum
|
||||
uint8_t crc = CRC8Cardx(arr, ARRAYLEN(arr));
|
||||
|
||||
blocks[0] = blocks[1] = blocks[2] = 0;
|
||||
uint8_t pos = 0;
|
||||
|
||||
// magic prefix, then the bytes with their extra bit, then the CRC
|
||||
// magic prefix
|
||||
setBitsInBlocks(blocks, &pos, 0x7fea, 16);
|
||||
|
||||
for (int i = 0; i < ARRAYLEN(arr); i++) {
|
||||
// data byte
|
||||
setBitsInBlocks(blocks, &pos, arr[i], 8);
|
||||
setBitsInBlocks(blocks, &pos, bonus_bit[i], 1);
|
||||
|
||||
// every byte is followed by a bit which is the inverse of the last bit
|
||||
setBitsInBlocks(blocks, &pos, !(arr[i] & 0x1), 1);
|
||||
}
|
||||
|
||||
// checksum
|
||||
uint8_t crc = CRC8Cardx(arr, ARRAYLEN(arr));
|
||||
setBitsInBlocks(blocks, &pos, crc, 8);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue