Updates
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
all: infnoise infnoise-v1
|
||||
all: infnoise infnoise-v1 passgen
|
||||
|
||||
infnoise: infnoise.c infnoise.h healthcheck.c writeentropy.c Keccak/KeccakF-1600-reference.c Keccak/brg_endian.h
|
||||
gcc -Wall -std=c99 -O3 -I Keccak -o infnoise infnoise.c healthcheck.c writeentropy.c Keccak/KeccakF-1600-reference.c -lftdi -lm -lrt
|
||||
@@ -6,5 +6,8 @@ infnoise: infnoise.c infnoise.h healthcheck.c writeentropy.c Keccak/KeccakF-1600
|
||||
infnoise-v1: infnoise.c infnoise.h healthcheck.c writeentropy.c Keccak/KeccakF-1600-reference.c Keccak/brg_endian.h
|
||||
gcc -Wall -std=c99 -O3 -DVERSION1 -I Keccak -o infnoise-v1 infnoise.c healthcheck.c writeentropy.c Keccak/KeccakF-1600-reference.c -lftdi -lm -lrt
|
||||
|
||||
passgen: passgen.c
|
||||
gcc -Wall -std=c99 -O3 -o passgen passgen.c -lm
|
||||
|
||||
clean:
|
||||
rm -f infnoise infnoise-v1
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define MAX_MICROSEC_FOR_SAMPLES 5000
|
||||
|
||||
// This is the gain of each of the two op-amp stages in the INM
|
||||
#define DESIGN_K 1.82
|
||||
#define DESIGN_K 1.84
|
||||
|
||||
// This defines which pins on the FT240X are used
|
||||
#ifdef VERSION1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
all: healthcheck findlongest entcheck hex2bin bin2hex flipbits genbits
|
||||
all: healthcheck findlongest entcheck hex2bin bin2hex flipbits dice
|
||||
|
||||
healthcheck: ../healthcheck.c
|
||||
gcc -Wall -std=c99 -O3 -D TEST_HEALTHCHECK -o healthcheck ../healthcheck.c -lm -lrt
|
||||
@@ -18,8 +18,8 @@ bin2hex: bin2hex.c
|
||||
flipbits: flipbits.c
|
||||
gcc -Wall -std=c99 -O3 -o flipbits flipbits.c
|
||||
|
||||
genbits: genbits.c
|
||||
gcc -Wall -std=c99 -O3 -o genbits genbits.c
|
||||
dice: dice.c
|
||||
gcc -Wall -std=c99 -O3 -o dice dice.c
|
||||
|
||||
clean:
|
||||
rm -f healthcheck findlongest entcheck hex2bin bin2hex flipbits
|
||||
rm -f healthcheck findlongest entcheck hex2bin bin2hex flipbits dice
|
||||
|
||||
43
software/tools/dice.c
Normal file
43
software/tools/dice.c
Normal file
@@ -0,0 +1,43 @@
|
||||
// This is a simple program to read from a binary file of random bits and generate
|
||||
// dice rolls.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Role a single die.
|
||||
static void rollDie(uint32_t sides, FILE *file) {
|
||||
uint32_t randVal;
|
||||
do {
|
||||
uint32_t numBytes = 0;
|
||||
randVal = 0;
|
||||
while (1 << (8*numBytes) <= sides) {
|
||||
numBytes++;
|
||||
int c = getc(file);
|
||||
if (c == EOF) {
|
||||
printf("Ran out of random data\n");
|
||||
exit(1);
|
||||
}
|
||||
randVal = (randVal << 8) | getc(file);
|
||||
}
|
||||
} while(randVal >= sides);
|
||||
printf(" %u", randVal + 1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc != 4) {
|
||||
printf("Usage: dice randFile numDice numSides\n");
|
||||
return 1;
|
||||
}
|
||||
FILE *file = fopen(argv[1], "r");
|
||||
uint32_t dice = atoi(argv[2]);
|
||||
uint32_t sides = atoi(argv[3]);
|
||||
uint32_t i;
|
||||
printf("Rolling %u %u-sided dice:", dice, sides);
|
||||
for (i = 0; i < dice; i++) {
|
||||
rollDie(sides, file);
|
||||
}
|
||||
printf("\n");
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user