mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 14:13:42 -07:00
added validate_prng_nonce from iceman1001 fork
This commit is contained in:
parent
9d139870cb
commit
3d81da6d1a
2 changed files with 13 additions and 0 deletions
|
@ -426,6 +426,17 @@ int nonce_distance(uint32_t from, uint32_t to)
|
||||||
return (65535 + dist[to >> 16] - dist[from >> 16]) % 65535;
|
return (65535 + dist[to >> 16] - dist[from >> 16]) % 65535;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** validate_prng_nonce
|
||||||
|
* Determine if nonce is deterministic. ie: Suspectable to Darkside attack.
|
||||||
|
* returns
|
||||||
|
* true = weak prng
|
||||||
|
* false = hardend prng
|
||||||
|
*/
|
||||||
|
bool validate_prng_nonce(uint32_t nonce) {
|
||||||
|
// init prng table:
|
||||||
|
nonce_distance(nonce, nonce);
|
||||||
|
return ((65535 - dist[nonce >> 16] + dist[nonce & 0xffff]) % 65535) == 16;
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t fastfwd[2][8] = {
|
static uint32_t fastfwd[2][8] = {
|
||||||
{ 0, 0x4BC53, 0xECB1, 0x450E2, 0x25E29, 0x6E27A, 0x2B298, 0x60ECB},
|
{ 0, 0x4BC53, 0xECB1, 0x450E2, 0x25E29, 0x6E27A, 0x2B298, 0x60ECB},
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#ifndef CRAPTO1_INCLUDED
|
#ifndef CRAPTO1_INCLUDED
|
||||||
#define CRAPTO1_INCLUDED
|
#define CRAPTO1_INCLUDED
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,6 +49,7 @@ uint8_t lfsr_rollback_bit(struct Crypto1State* s, uint32_t in, int fb);
|
||||||
uint8_t lfsr_rollback_byte(struct Crypto1State* s, uint32_t in, int fb);
|
uint8_t lfsr_rollback_byte(struct Crypto1State* s, uint32_t in, int fb);
|
||||||
uint32_t lfsr_rollback_word(struct Crypto1State* s, uint32_t in, int fb);
|
uint32_t lfsr_rollback_word(struct Crypto1State* s, uint32_t in, int fb);
|
||||||
int nonce_distance(uint32_t from, uint32_t to);
|
int nonce_distance(uint32_t from, uint32_t to);
|
||||||
|
extern bool validate_prng_nonce(uint32_t nonce);
|
||||||
#define FOREACH_VALID_NONCE(N, FILTER, FSIZE)\
|
#define FOREACH_VALID_NONCE(N, FILTER, FSIZE)\
|
||||||
uint32_t __n = 0,__M = 0, N = 0;\
|
uint32_t __n = 0,__M = 0, N = 0;\
|
||||||
int __i;\
|
int __i;\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue