mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
Faster validate_prng_nonce
This commit is contained in:
parent
30984174db
commit
bd3e8db852
1 changed files with 7 additions and 4 deletions
|
@ -430,10 +430,13 @@ int nonce_distance(uint32_t from, uint32_t to) {
|
|||
* false = hardend prng
|
||||
*/
|
||||
bool validate_prng_nonce(uint32_t nonce) {
|
||||
// init prng table:
|
||||
if (nonce_distance(nonce, nonce) == -1)
|
||||
return false;
|
||||
return ((65535 - dist[nonce >> 16] + dist[nonce & 0xffff]) % 65535) == 16;
|
||||
uint16_t x = nonce >> 16;
|
||||
x = (x & 0xff) << 8 | x >> 8;
|
||||
for (uint8_t i = 0; i<16; i++) {
|
||||
x = x >> 1 | (x ^ x >> 2 ^ x >> 3 ^ x >> 5) << 15;
|
||||
}
|
||||
x = (x & 0xff) << 8 | x >> 8;
|
||||
return x == (nonce & 0xFFFF);
|
||||
}
|
||||
|
||||
static uint32_t fastfwd[2][8] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue