mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
CHG: the mifare Auth command can make use of a random nonce aswell.
CHG: since sim commands are timing critical, I'm testing a smaller prand prng function from Intel
This commit is contained in:
parent
76c0ec0ba8
commit
e99acd00cc
5 changed files with 81 additions and 64 deletions
|
@ -1,6 +1,6 @@
|
|||
#include "random.h"
|
||||
|
||||
uint64_t next_random = 1;
|
||||
static uint32_t g_nextrandom;
|
||||
|
||||
/* Generates a (non-cryptographically secure) 32-bit random number.
|
||||
*
|
||||
|
@ -8,14 +8,23 @@
|
|||
* method of seeding with the time it took to call "autoseed" from first run.
|
||||
*
|
||||
* https://github.com/Proxmark/proxmark3/pull/209/commits/f9c1dcd9f6e68a8c07cffed697a9c4c8caed6015
|
||||
*
|
||||
* Iceman, rand needs to be fast.
|
||||
* https://software.intel.com/en-us/articles/fast-random-number-generator-on-the-intel-pentiumr-4-processor/
|
||||
*/
|
||||
|
||||
inline void fast_prand(){
|
||||
fast_prandEx(GetTickCount());
|
||||
}
|
||||
inline void fast_prandEx(uint32_t seed) {
|
||||
g_nextrandom = seed;
|
||||
}
|
||||
|
||||
uint32_t prand() {
|
||||
if (next_random == 1)
|
||||
next_random = GetTickCount();
|
||||
|
||||
next_random *= 6364136223846793005;
|
||||
next_random += 1;
|
||||
|
||||
return (uint32_t)(next_random >> 32) % 0xffffffff;
|
||||
// g_nextrandom *= 6364136223846793005;
|
||||
// g_nextrandom += 1;
|
||||
//return (uint32_t)(g_nextrandom >> 32) % 0xffffffff;
|
||||
g_nextrandom = (214013 * g_nextrandom + 2531011);
|
||||
return (g_nextrandom>>16) & 0xFFFF;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "ticks.h"
|
||||
|
||||
void fast_prand();
|
||||
void fast_prandEx(uint32_t seed);
|
||||
uint32_t prand();
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue