Verified Commit e1082d01 authored by Bastien Durel's avatar Bastien Durel
Browse files

initialize with /dev/urandom, not /dev/random; test randomness by trying to compress output

parent adb2a1db
Pipeline #978 failed with stages
in 1 minute and 38 seconds
......@@ -12,6 +12,7 @@ build:
# - apt update && apt -y install make
script:
- make
- make test
artifacts:
paths:
- rand
......
CFLAGS=-O3
LDFLAGS=-O3
TESTFILES=test.bin test.gz test.bz test.xz
all: rand
rand: isaac64.o
$(CC) $(LDLAGS) -o $@ $<
isaac64.o: isaac64.c
clean:
rm -f *.o *~
rm -f *.o *~ $(TESTFILES)
fclean: clean
rm -f rand
test: rand
./rand | dd of=/dev/null bs=1M count=1000
./rand | dd of=test.bin bs=1M count=10
@gzip -9 < test.bin > test.gz
./checksize test.bin test.gz
@bzip2 -9 < test.bin > test.bz
./checksize test.bin test.bz
@xz -9 < test.bin > test.xz
./checksize test.bin test.xz
rm -f $(TESTFILES)
......@@ -76,9 +76,9 @@ word flag;
aa=bb=cc=(ub8)0;
a=b=c=d=e=f=g=h=0x9e3779b97f4a7c13LL; /* the golden ratio */
_rand = fopen("/dev/random", "r");
_rand = fopen("/dev/urandom", "r");
if (_rand == NULL) {
perror("Cannot open /dev/random: ");
perror("Cannot open /dev/urandom: ");
exit(1);
}
fread(&a, sizeof(ub8), 1, _rand);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment