X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/910ad5470d913baeaf9d882a22fc1b853318a5da..f9c1dcd9f6e68a8c07cffed697a9c4c8caed6015:/armsrc/util.c diff --git a/armsrc/util.c b/armsrc/util.c index 1dd8dc75..be41bad8 100644 --- a/armsrc/util.c +++ b/armsrc/util.c @@ -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; +} +