X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/d95878f8022707b9e66e7ec7c22403459371d7d4..605ae1892874a438c5c7d72c5a13e78e1ef0ebbe:/common/crapto1/crapto1.c diff --git a/common/crapto1/crapto1.c b/common/crapto1/crapto1.c index 9187460b..fe6eb0f6 100644 --- a/common/crapto1/crapto1.c +++ b/common/crapto1/crapto1.c @@ -99,7 +99,7 @@ static void bucket_sort_intersect(uint32_t* const estart, uint32_t* const estop, /** binsearch * Binary search for the first occurence of *stop's MSB in sorted [start,stop] */ -static inline uint32_t* binsearch(uint32_t *start, uint32_t *stop) +/* static inline uint32_t* binsearch(uint32_t *start, uint32_t *stop) { uint32_t mid, val = *stop & 0xff000000; while(start != stop) @@ -110,7 +110,7 @@ static inline uint32_t* binsearch(uint32_t *start, uint32_t *stop) return start; } - + */ /** update_contribution * helper, calculates the partial linear feedback contributions and puts in MSB */ @@ -425,6 +425,17 @@ int nonce_distance(uint32_t from, uint32_t to) } 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] = {