tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NetBSD openjdk SecureRandom /dev/random "Resource temporarily unavailable" issue

On Thu, Apr 28, 2016 at 10:29:56AM +0100, David Brownlee wrote:
> With the default openjdk8 settings the following code
> private static final int SALT_LENGTH = 32;
> private static final String RANDOM_FACTORY = "SHA1PRNG";
> byte[] saltBytes =
> SecureRandom.getInstance(RANDOM_FACTORY).generateSeed(SALT_LENGTH);
> Fails with an exception:
> register: Error registering subscriber: Resource
> temporarily unavailable
>         at Method)
>         at
>         at$URLSeedGenerator.getSeedBytes(
>         at
>         at
>         at
> Adjusting lib/security/ to switch securerandom.source
> from file:/dev/random to file:/dev/urandom works around the issue.
> Does anyone know if NetBSD's /dev/random behaving differently to other
> platforms here?
> David

It's possible this behaviour does not exist with NetBSD /dev/random and
is expected by Java (from linux RANDOM(4)):

If open(2) is called for /dev/random with the flag O_NONBLOCK, a
subsequent read(2) will not block if the requested number of bytes
is not available. Instead, the available bytes are returned.  If no
byte is available, read(2) will  return  -1  and errno will be set

Home | Main Index | Thread Index | Old Index