mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
ADD: @micolous random nonce, adjusted to fit in. Icemanfork only uses Moebius attack, so no need for an extra parameter in client.
ref: https://github.com/Proxmark/proxmark3/pull/209
This commit is contained in:
parent
6c3795a315
commit
bf5d7992ce
8 changed files with 90 additions and 28 deletions
19
common/random.c
Normal file
19
common/random.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "random.h"
|
||||
|
||||
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. Instead we use a
|
||||
* method of seeding with the time it took to call "autoseed" from first run.
|
||||
*
|
||||
* https://github.com/Proxmark/proxmark3/pull/209/commits/f9c1dcd9f6e68a8c07cffed697a9c4c8caed6015
|
||||
*/
|
||||
uint32_t prand() {
|
||||
if (next_random == 1)
|
||||
next_random = GetTickCount();
|
||||
|
||||
next_random = next_random * 6364136223846793005 + 1;
|
||||
return (uint32_t)(next_random >> 32) % 0xffffffff;
|
||||
}
|
||||
|
21
common/random.h
Normal file
21
common/random.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Micolous Jan 2017
|
||||
// Iceman Jan 2017
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// pseudo rng generator. To be used when PM3 simulates Mifare tag.
|
||||
// i.e. 'hf mf sim'
|
||||
// 'hf 14a sim'
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __RANDOM_H
|
||||
#define __RANDOM_H
|
||||
|
||||
#include "common.h"
|
||||
#include "ticks.h"
|
||||
|
||||
uint32_t prand();
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue