From 258332894b6e65a39b7e5e2d69ba95c3a7d90b19 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 9 Apr 2019 17:49:02 +0200 Subject: [PATCH] hardnested: get rid of shift by negative value --- client/cmdhfmfhard.c | 5 +++-- client/hardnested/hardnested_tables.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/cmdhfmfhard.c b/client/cmdhfmfhard.c index 99afc6b01..787a8f8c8 100644 --- a/client/cmdhfmfhard.c +++ b/client/cmdhfmfhard.c @@ -367,9 +367,10 @@ static uint16_t PartialSumProperty(uint32_t state, odd_even_t odd_even) { uint32_t st = state; uint16_t part_sum = 0; if (odd_even == ODD_STATE) { - for (uint16_t i = 0; i < 5; i++) { - part_sum ^= filter(st); + part_sum ^= filter(st); + for (uint16_t i = 0; i < 4; i++) { st = (st << 1) | ((j >> (3 - i)) & 0x01) ; + part_sum ^= filter(st); } part_sum ^= 1; // XOR 1 cancelled out for the other 8 bits } else { diff --git a/client/hardnested/hardnested_tables.c b/client/hardnested/hardnested_tables.c index e1bc68549..c2602bdb7 100644 --- a/client/hardnested/hardnested_tables.c +++ b/client/hardnested/hardnested_tables.c @@ -44,9 +44,10 @@ static uint16_t PartialSumProperty(uint32_t state, odd_even_t odd_even) { uint32_t st = state; uint16_t part_sum = 0; if (odd_even == ODD_STATE) { + part_sum ^= filter(st); for (uint16_t i = 0; i < 4; i++) { - part_sum ^= filter(st); st = (st << 1) | ((j >> (3 - i)) & 0x01) ; + part_sum ^= filter(st); } part_sum ^= 1; // XOR 1 cancelled out for the other 8 bits } else {