The conventional and simple wisdom is to combine head
with /dev/urandom
to create the amount of pseudo-random data that is needed.
But that is slow.
I found a faster method - cryptsetup
FAQ suggests to use its mechanism.
See 2.19 at:
https://gitlab.com/cryptsetup/cryptsetup/-/wikis/FrequentlyAskedQuestions
But the issue with this method is that root privileges are required for the mapping by cryptsetup (dm-crypt).
So, I need a similar method which won't require root privileges.
Some StackExchange posts suggested openssl
encoding with -aes-256-ctr
:
https://serverfault.com/a/415962
https://serverfault.com/a/714412
But I don't know whether CTR is really preferred in this case over CBC.
Won't CTR break the pseudo-randomness of the data?
Another approach was to use openssl rand
- see post:
https://serverfault.com/a/146996
The manual page of openssl rand
is unclear (for me) regarding its method.
See:
The random bytes are generated using the RAND_bytes(3) function, which provides a security level of 256 bits, provided it managed to seed itself successfully from a trusted operating system entropy source. Otherwise, the command will fail with a nonzero error code. For more details, see RAND_bytes(3), RAND(7), and EVP_RAND(7).
Yet man RAND_bytes
is nonexistent.
Among the last ones above, is there a strong preference in terms of the strength of the pseudo-randomness ?
Meaning, either:
- openssl enc -aes-256-ctr
- openssl enc -aes-256-cbc
- openssl rand
- Other?