Skip to content

Commit 94f288a

Browse files
committed
Simpilify valid_nonce()
1 parent 2a2d056 commit 94f288a

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/mfoc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,9 +1241,9 @@ countKeys *uniqsort(uint64_t *possibleKeys, uint32_t size)
12411241
// Return 1 if the nonce is invalid else return 0
12421242
int valid_nonce(uint32_t Nt, uint32_t NtEnc, uint32_t Ks1, uint8_t *parity)
12431243
{
1244-
return ((odd_parity((Nt >> 24) & 0xFF) == ((parity[0]) ^ odd_parity((NtEnc >> 24) & 0xFF) ^ BIT(Ks1, 16))) & \
1245-
(odd_parity((Nt >> 16) & 0xFF) == ((parity[1]) ^ odd_parity((NtEnc >> 16) & 0xFF) ^ BIT(Ks1, 8))) & \
1246-
(odd_parity((Nt >> 8) & 0xFF) == ((parity[2]) ^ odd_parity((NtEnc >> 8) & 0xFF) ^ BIT(Ks1, 0)))) ? 1 : 0;
1244+
return ((oddparity((Nt >> 24) & 0xFF) == ((parity[0]) ^ oddparity((NtEnc >> 24) & 0xFF) ^ BIT(Ks1, 16))) &&
1245+
(oddparity((Nt >> 16) & 0xFF) == ((parity[1]) ^ oddparity((NtEnc >> 16) & 0xFF) ^ BIT(Ks1, 8))) &&
1246+
(oddparity((Nt >> 8) & 0xFF) == ((parity[2]) ^ oddparity((NtEnc >> 8) & 0xFF) ^ BIT(Ks1, 0)))) ? 1 : 0;
12471247
}
12481248

12491249
void num_to_bytes(uint64_t n, uint32_t len, uint8_t *dest)

src/mfoc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
// Number of sets with 32b keys
3636
#define DEFAULT_SETS_NR 5
3737

38-
#define odd_parity(i) (( (i) ^ (i)>>1 ^ (i)>>2 ^ (i)>>3 ^ (i)>>4 ^ (i)>>5 ^ (i)>>6 ^ (i)>>7 ^ 1) & 0x01)
39-
4038
typedef struct {
4139
uint8_t KeyA[6];
4240
uint8_t KeyB[6];

0 commit comments

Comments
 (0)