]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/util.c
Adds random nonce (r) option to `hf mf sim`.
[proxmark3-svn] / armsrc / util.c
index 1dd8dc7544fe1cb2989548692f8449f19b6ca621..be41bad8aa2a351a8d9ef059aecc1e6104921c2a 100644 (file)
@@ -431,3 +431,19 @@ uint32_t RAMFUNC GetCountSspClk(){
        }
 }
 
+static uint64_t next_random = 1;
+
+/* Generates a (non-cryptographically secure) 32-bit random number.
+ *
+ * We don't have an implementation of the "rand" function or a clock to seed it
+ * with, so we just call GetTickCount the first time to seed ourselves.
+ */
+uint32_t prand() {
+       if (next_random == 1) {
+               next_random = GetTickCount();
+       }
+
+       next_random = next_random * 6364136223846793005 + 1;
+       return (uint32_t)(next_random >> 32) % 0xffffffff;
+}
+
Impressum, Datenschutz