pcb and initial code from https://github.com/das-labor/borgware-2d.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
757 B
42 lines
757 B
16 years ago
|
/**
|
||
|
* \author Daniel Otte
|
||
|
* \date 2008-08-24
|
||
|
* \license GPLv3 or later
|
||
|
* \brief random number generator based on noekeon running in CFB-mode
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef PRNG_H_
|
||
|
#define PRNG_H_
|
||
|
|
||
|
#include <stdint.h>
|
||
14 years ago
|
#include "string.h"
|
||
|
#include "noekeon.h"
|
||
|
#include "memxor.h"
|
||
|
|
||
|
extern uint8_t random_state[16];
|
||
|
extern uint8_t random_key[16];
|
||
16 years ago
|
|
||
|
uint8_t random8(void);
|
||
14 years ago
|
|
||
|
inline static void random_block(void* dest){
|
||
|
noekeon_enc(random_state, random_key);
|
||
|
memcpy(dest, random_state, 16);
|
||
|
}
|
||
|
|
||
|
inline static void srandom32(uint32_t seed){
|
||
|
memcpy(random_key, &seed, 4);
|
||
|
}
|
||
|
|
||
|
inline static void random_seed(const void* buffer){
|
||
|
memcpy(random_key, buffer, 16);
|
||
|
}
|
||
|
|
||
|
inline static void random_add(const void* buffer){
|
||
|
memxor(random_key, buffer, 16);
|
||
|
}
|
||
16 years ago
|
|
||
|
#endif /* PRNG_H_*/
|
||
|
|
||
|
|