ass1-ex1 done
authorMart Lubbers <mart@martlubbers.net>
Sun, 8 Feb 2015 17:30:16 +0000 (18:30 +0100)
committerMart Lubbers <mart@martlubbers.net>
Sun, 8 Feb 2015 17:30:16 +0000 (18:30 +0100)
ass2/assignment2.pdf [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/Makefile [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1a.txt [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1b.c [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1c [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1d.c [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1d.txt [new file with mode: 0644]
ass2/mart/sws1-s4109503-s4202015/exercise1e.txt [new file with mode: 0644]

diff --git a/ass2/assignment2.pdf b/ass2/assignment2.pdf
new file mode 100644 (file)
index 0000000..b4db285
Binary files /dev/null and b/ass2/assignment2.pdf differ
diff --git a/ass2/mart/sws1-s4109503-s4202015/Makefile b/ass2/mart/sws1-s4109503-s4202015/Makefile
new file mode 100644 (file)
index 0000000..cacd2e7
--- /dev/null
@@ -0,0 +1,9 @@
+CC=gcc
+CFLAGS=-std=c99 -Wall -Wextra
+
+all: exercise1b.c exercise1d.c
+       $(CC) $(CFLAGS) exercise1b.c -o exercise1b
+       $(CC) $(CFLAGS) exercise1d.c -o exercise1d
+
+clean:
+       $(RM) exercise1b exercise1d
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1a.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1a.txt
new file mode 100644 (file)
index 0000000..ff19321
--- /dev/null
@@ -0,0 +1,6 @@
+/dev/random generates random bytes from a 4096 bits entropy pool and will only
+use fresh entropy.
+
+/dev/urandom generates random bytes from a 4096 bits entropy pool too but it
+reuses entropy while the entropy pool is filled. Because of the reuse
+/dev/urandom is much faster then /dev/random
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1b.c b/ass2/mart/sws1-s4109503-s4202015/exercise1b.c
new file mode 100644 (file)
index 0000000..9cbaa94
--- /dev/null
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+       FILE *f = fopen("/dev/urandom", "r");
+       char c;
+       do {
+               c = fgetc(f);
+               printf("%i %u %x\n", c, c, c);
+       } while(c != 42);
+       if(f != stdin)
+               fclose(f);
+       return 0;
+}
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1c b/ass2/mart/sws1-s4109503-s4202015/exercise1c
new file mode 100644 (file)
index 0000000..5dc9dbd
--- /dev/null
@@ -0,0 +1,16 @@
+-82 4294967214 ffffffae
+91 91 5b
+-63 4294967233 ffffffc1
+-41 4294967255 ffffffd7
+-22 4294967274 ffffffea
+103 103 67
+-33 4294967263 ffffffdf
+-115 4294967181 ffffff8d
+-90 4294967206 ffffffa6
+108 108 6c
+60 60 3c
+-42 4294967254 ffffffd6
+-55 4294967241 ffffffc9
+-26 4294967270 ffffffe6
+25 25 19
+42 42 2a
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1d.c b/ass2/mart/sws1-s4109503-s4202015/exercise1d.c
new file mode 100644 (file)
index 0000000..4b6e9c7
--- /dev/null
@@ -0,0 +1,16 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+       FILE *f = fopen("/dev/urandom", "r");
+       uint16_t c;
+       do {
+               c = fgetc(f)+fgetc(f)*256;
+               printf("%04x\n", c);
+       } while(c != 42);
+       if(f != stdin)
+               fclose(f);
+       return 0;
+}
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1d.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1d.txt
new file mode 100644 (file)
index 0000000..651c337
--- /dev/null
@@ -0,0 +1,10 @@
+271325
+40516
+65532
+23964
+41888
+95550
+234585
+50847
+85879
+87536
diff --git a/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt b/ass2/mart/sws1-s4109503-s4202015/exercise1e.txt
new file mode 100644 (file)
index 0000000..6c4b271
--- /dev/null
@@ -0,0 +1 @@
+{ for ((i=0;i<10;i++)); do ./exercise1d | wc -l; done; } > exercise1d.txt