I had this problem with wanting to write random data to a hard drive before setting it up with encryption. The problem is that I have 6 TB of disk and /dev/urandom was going around 5.5 MB/s which this will take almost two weeks to finish.
I came up with a solution but I don't know if it's that good, since I have no formal training in cryptography. I wrote my own random number generator which took /dev/urandom as a seed for SHA-256 then incremented the seed and generated a new SHA-256 and so on.
Kinda like this only I wrote SHA-256 in SSE2 (64 bit x86) which gave me over 100 MB/s per core in a Pentium D.
SHA256_CTX ctx;
int seed[16];
FILE *pFile = fopen("/dev/urandom", "rb");
while (1)
{
fread(seed, 4, 16, pFile);
for (int a = 0; a < 1048576; a++)
{
sha256_init(&ctx);
sha256_update(&ctx, seed, 64);
fwrite(&ctx, 4, 8, stdout);
seed[0]++;
}
}
What is a faster way than /dev/urandom that is still cryptographically secure?
Also I'd like to know if my solution is cryptographically secure?