Question: Task 1.B: Get Pseudo Random Numbers from /dev/random Linux stores the random data collected from the physical resources into a random pool, and then uses

Task 1.B: Get Pseudo Random Numbers from /dev/random Linux stores the random data collected from the physical resources into a random pool, and then uses two devices to turn the randomness into pseudo random numbers. These two devices have different behaviors. In this subtask, we study the /dev/random device. You can use the following command to get 16 bytes of pseudo random numbers from /dev/random. We pipe the data to hexdump to print them out. % head -c 16 /dev/random | hexdump Please run the above command several times, and you will find out that at some point, the program will not print out anything, and instead, it will be waiting. Basically, every time a random number is given out by /dev/random, the entropy of the randomness pool will be decreased. When the entropy reaches zero, /dev/random will block, until it gains enough randomness. Please show us how you can get /dev/random to unblock and to print out random data.

Task 1.C: Get Random Numbers from /dev/urandom Linux provides another way to access the random pool via the /dev/urandom device, except that this device will not block, even if the entropy of the pool runs low. You can use the following command to get 1600 bytes of pseudo random numbers from /dev/urandom. You should run it several times, and report whether it will block or not. % head -c 1600 /dev/urandom | hexdump Both /dev/random and /dev/urandom use the random data from the pool to generate pseudo random numbers. When the entropy is not sufficient, /dev/random will pause, while /dev/urandom will keep generating new numbers. Think of the data in the pool as the seed, and as we know, you can use a seed to generate as many pseudo random numbers as you want. Theoretically speaking, the /dev/random device is more secure, but in practice, there is not much difference, because the seed is random and nonpredictable. /dev/urandom does re-seed whenever new random data become available. The fact that /dev/random blocks may lead to denial of service attacks. It is recommended that you use /dev/urandom to get random numbers. To do that in your program, you just need to read directly from this file. The following code snippet shows you how. #define LEN 16 // 128 bits

SEED Labs 3 unsigned char *key = (unsigned char *) malloc(sizeof(unsigned char)*LEN); FILE* random = fopen("/dev/urandom", "r"); fread(key, sizeof(unsigned char)*LEN, 1, random); fclose(random);

3 Submission You need to submit a detailed lab report to describe what you have done and what you have observed; you also need to provide explanation to the observations that are interesting or surprising. In your report, you need to answer all the questions listed in this lab.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!