]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Update crapto1.c
authorIceman <iceman@iuse.se>
Mon, 26 Jun 2017 19:49:21 +0000 (21:49 +0200)
committerGitHub <noreply@github.com>
Mon, 26 Jun 2017 19:49:21 +0000 (21:49 +0200)
Add nonce validation

common/crapto1/crapto1.c

index 9398a1f34938638886f846d2956402da7dc5f291..fe6eb0f6d00722210716d3f0b8ef8a21c3958882 100644 (file)
@@ -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] = {
Impressum, Datenschutz