Wednesday, April 17, 2019

What are /dev/random and /dev/urandom files?

/dev/random will block after the entropy pool is exhausted. It will remain blocked until additional data has been collected from the sources of entropy that are available. This can slow down random data generation. Randomness is critical to the security of cryptography in your application – one-time pads, key generation.

[root@localhost ~]# dd if=/dev/random of=random.txt bs=2048 count=2048
dd: warning: partial read (82 bytes); suggest iflag=fullblock
0+2048 records in
0+2048 records out
150665 bytes (151 kB) copied, 21.6704 s, 7.0 kB/s


/dev/urandom will not block. Instead it will reuse the internal pool to produce more pseudo-random bits. It's best when we have to a large file with random data. Also if you are using "dd" command to wipe data of a disk by replacing it with random data.

[root@localhost ~]# dd if=/dev/urandom of=urandom.txt bs=2048 count=2048
2048+0 records in
2048+0 records out
4194304 bytes (4.2 MB) copied, 0.0361976 s, 116 MB/s

No comments:

Post a Comment