Running macOS High Sierra 10.13.5 and Java 1.8.0u171.
I have something like the following code:
SecureRandom random = SecureRandom.getInstance("NativePRNGNonBlocking");
random.setSeed(bla byte array);
I encounter the following exception whenever this is run, I have redacted some of the stack trace that contains some sensitive bits:
java.security.ProviderException: setSeed() failed
at sun.security.provider.NativePRNG$RandomIO.implSetSeed(NativePRNG.java:472)
at sun.security.provider.NativePRNG$RandomIO.access$300(NativePRNG.java:331)
at sun.security.provider.NativePRNG$NonBlocking.engineSetSeed(NativePRNG.java:312)
at java.security.SecureRandom.setSeed(SecureRandom.java:427)
--redacted--
Caused by: java.io.IOException: Operation not permitted
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:313)
at sun.security.provider.NativePRNG$RandomIO.implSetSeed(NativePRNG.java:470)
at sun.security.provider.NativePRNG$RandomIO.access$300(NativePRNG.java:331)
at sun.security.provider.NativePRNG$NonBlocking.engineSetSeed(NativePRNG.java:312)
at java.security.SecureRandom.setSeed(SecureRandom.java:427)
--redacted--
It appears that it is trying to write something, but I don't know what, or where. There is code in the area that mentions /dev/random, so I figured I would check the perms of that, but I don't know what to make of that either.
x@y:~ $ ls -ld /dev/null
crw-rw-rw- 1 root wheel 3, 2 Jun 11 15:25 /dev/null
x@y:~ $ ls -ld /dev/urandom
crw-rw-rw- 1 root wheel 14, 1 Jun 11 15:02 /dev/urandom
x@y:~ $ ls -ld /dev/random
crw-rw-rw- 1 root wheel 14, 0 Jun 7 08:15 /dev/random
Any ideas what the issue is, and what I can do to remedy it?
EDIT: I found that it appears that NativePRNGNonBlocking
appears to try and access /dev/urandom
which OSX apparently doesn't allow writing to. Is there a way I can enable writing to it, or another method of avoiding this while still maintaining non-blocking behavior?