2008-12-03 05:40:16 +00:00
|
|
|
/**
|
|
|
|
* \author Daniel Otte
|
|
|
|
* \date 2008-08-24
|
|
|
|
* \license GPLv3 or later
|
|
|
|
* \brief random number generator based on noekeon running in CFB-mode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
2011-03-01 16:17:58 +00:00
|
|
|
#include "noekeon.h"
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
uint8_t random_state[16];
|
|
|
|
uint8_t random_key[16];
|
|
|
|
|
|
|
|
uint8_t random8(void){
|
|
|
|
static uint8_t sr[16];
|
|
|
|
static uint8_t i=0;
|
|
|
|
|
|
|
|
if(i==0){
|
|
|
|
noekeon_enc(random_state, random_key);
|
|
|
|
memcpy(sr, random_state, 16);
|
|
|
|
i=15;
|
|
|
|
return sr[15];
|
|
|
|
}
|
|
|
|
--i;
|
|
|
|
return sr[i];
|
|
|
|
}
|