Skip to content

Commit 3210384

Browse files
committed
fm11rf08s: fix prev_lfsr
1 parent b00e5d3 commit 3210384

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

tools/mfc/card_only/staticnested_2x1nt_rf08s.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,23 @@ static void init_lfsr16_table(void) {
3131
}
3232

3333
// static uint16_t next_lfsr16(uint16_t nonce) {
34-
// return s_lfsr16[(i_lfsr16[nonce]+1) % 65535];
34+
// uint16_t i = i_lfsr16[nonce];
35+
// if (i == 0xffff) {
36+
// i = 1;
37+
// } else {
38+
// i++;
39+
// }
40+
// return s_lfsr16[i];
3541
// }
3642

3743
static uint16_t prev_lfsr16(uint16_t nonce) {
38-
return s_lfsr16[(i_lfsr16[nonce] - 1) % 65535];
44+
uint16_t i = i_lfsr16[nonce];
45+
if (i == 1) {
46+
i = 0xffff;
47+
} else {
48+
i--;
49+
}
50+
return s_lfsr16[i];
3951
}
4052

4153
static uint16_t compute_seednt16_nt32(uint32_t nt32, uint64_t key) {

tools/mfc/card_only/staticnested_2x1nt_rf08s_1key.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,23 @@ static void init_lfsr16_table(void) {
3333
}
3434

3535
// static uint16_t next_lfsr16(uint16_t nonce) {
36-
// return s_lfsr16[(i_lfsr16[nonce]+1) % 65535];
36+
// uint16_t i = i_lfsr16[nonce];
37+
// if (i == 0xffff) {
38+
// i = 1;
39+
// } else {
40+
// i++;
41+
// }
42+
// return s_lfsr16[i];
3743
// }
3844

3945
static uint16_t prev_lfsr16(uint16_t nonce) {
40-
return s_lfsr16[(i_lfsr16[nonce] - 1) % 65535];
46+
uint16_t i = i_lfsr16[nonce];
47+
if (i == 1) {
48+
i = 0xffff;
49+
} else {
50+
i--;
51+
}
52+
return s_lfsr16[i];
4153
}
4254

4355
static uint16_t compute_seednt16_nt32(uint32_t nt32, uint64_t key) {

0 commit comments

Comments
 (0)