Question: 2.5 Task 5: 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

2.5 Task 5: 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. 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, we can use a seed to generate as many pseudo random numbers as we want. Let us see the behavior of/dev/urandom. We again use cat to get pseudo random numbers fronm this device. Please run the following command, and the describe whether moving the mouse has any effect on the outcome s cat /dev/urandom hexdump Let us measure the quality of the random number. We can use a tool called ent, which has already beern installed in our VM. According to its manual, "ent applies various tests to sequences of bytes stored in files and reports the results of those tests. The program is useful for evaluating pseudo-random number generators for encryption and statistical sampling applications, compression algorithms, and other applications where the information density of a file is of interest". Let us first generate 1 MB of pseudo random number from /dev/urandom and save them in a file. Then we run ent on the file. Please describe your outcome, and analyze whether the quality of the random numbers is good or not head-c1M /dev/urandom >output.bin s ent output.bin Theoretically speaking, the /dev/random device is more secure, but in practice, there is not much difference, because the "seed" used by/dev/urandom is random and non-predictable (/dev/urandom does re-seed whenever new random data become available). A big problem of the blocking behavior of /dev/random is that blocking can lead to denial of service attacks. Therefore, it is recommended that we use /dev/urandom to get random numbers. To do that in our program, we just need to read directly from this device file. The following code snippet shows how #define LEN 16 // 128 bits unsigned char *key = (unsigned char *) malloc (sizeof (unsigned char) *LEN); FILE* randomfopen ("/dev/urandom", "r") fread (key, sizeof (unsigned char) LEN, 1, random); fclose (random); Please modify the above code snippet to generate a 256-bi encryption key. Please compile and run your code; print out the numbers and include the screenshot in the report. 2.5 Task 5: 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. 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, we can use a seed to generate as many pseudo random numbers as we want. Let us see the behavior of/dev/urandom. We again use cat to get pseudo random numbers fronm this device. Please run the following command, and the describe whether moving the mouse has any effect on the outcome s cat /dev/urandom hexdump Let us measure the quality of the random number. We can use a tool called ent, which has already beern installed in our VM. According to its manual, "ent applies various tests to sequences of bytes stored in files and reports the results of those tests. The program is useful for evaluating pseudo-random number generators for encryption and statistical sampling applications, compression algorithms, and other applications where the information density of a file is of interest". Let us first generate 1 MB of pseudo random number from /dev/urandom and save them in a file. Then we run ent on the file. Please describe your outcome, and analyze whether the quality of the random numbers is good or not head-c1M /dev/urandom >output.bin s ent output.bin Theoretically speaking, the /dev/random device is more secure, but in practice, there is not much difference, because the "seed" used by/dev/urandom is random and non-predictable (/dev/urandom does re-seed whenever new random data become available). A big problem of the blocking behavior of /dev/random is that blocking can lead to denial of service attacks. Therefore, it is recommended that we use /dev/urandom to get random numbers. To do that in our program, we just need to read directly from this device file. The following code snippet shows how #define LEN 16 // 128 bits unsigned char *key = (unsigned char *) malloc (sizeof (unsigned char) *LEN); FILE* randomfopen ("/dev/urandom", "r") fread (key, sizeof (unsigned char) LEN, 1, random); fclose (random); Please modify the above code snippet to generate a 256-bi encryption key. Please compile and run your code; print out the numbers and include the screenshot in the report
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
