[jitsi-dev] SecureRandom, /dev/random, ZrtpFortuna


#1

Hello, Ingo!

Could you please share your opinion whether the following looks OK?

I stumbled across a hang of SecureRandom on Linux in its default
implementation of generateSeed(int). As far as I understand from
reports on the Internet, it is very likely related to /dev/random.

That's why I plan to replace it (in the DTLS-related functionality)
with the source code bellow.

new SecureRandom()
            {
                /**
                 * {@inheritDoc}

···

*
                 * Employs <tt>ZrtpFortuna</tt> as is common in neomedia. Most
                 * importantly though, works around a possible hang on Linux
                 * when reading from <tt>/dev/random</tt>.
                 */
                @Override
                public byte[] generateSeed(int numBytes)
                {
                    byte[] seed = new byte[numBytes];

                    ZrtpFortuna.getInstance().nextBytes(seed);
                    return seed;
                }

                /**
                 * {@inheritDoc}
                 *
                 * Employs <tt>ZrtpFortuna</tt> as is common in neomedia.
                 */
                @Override
                public void nextBytes(byte[] bytes)
                {
                    ZrtpFortuna.getInstance().nextBytes(bytes);
                }
            };

Best regards,
Lyubomir Marinov


#2

Hey

I guess that is code for the videobridge?

I'm not sure if your snippet would help there at all. Fortuna needs to be seeded, and we currently do that by
noise xor SecureRandom.nextBytes()
beacause noise is not always available (noise suppression, no audio on the server).

If I remember correctly, you could use a JVM parameter to tell Java which random source to use and override the default of /dev/urandom to effectively use /dev/random - which should be fast even on a VM. As Java checks for /dev/random and ignores it, you have to specify /dev/./random

So even if you use Fortuna (which is fine to do), you need to overcome the limitation of a slow SecureRandom.

Freundliche Grüsse,
Ingo Bauersachs

-- sent from my mobile

···

Le 30.07.2014 à 01:47, "Lyubomir Marinov" <lyubomir.marinov@jitsi.org> a écrit :

Hello, Ingo!

Could you please share your opinion whether the following looks OK?

I stumbled across a hang of SecureRandom on Linux in its default
implementation of generateSeed(int). As far as I understand from
reports on the Internet, it is very likely related to /dev/random.

That's why I plan to replace it (in the DTLS-related functionality)
with the source code bellow.

new SecureRandom()
           {
               /**
                * {@inheritDoc}
                *
                * Employs <tt>ZrtpFortuna</tt> as is common in neomedia. Most
                * importantly though, works around a possible hang on Linux
                * when reading from <tt>/dev/random</tt>.
                */
               @Override
               public byte[] generateSeed(int numBytes)
               {
                   byte[] seed = new byte[numBytes];

                   ZrtpFortuna.getInstance().nextBytes(seed);
                   return seed;
               }

               /**
                * {@inheritDoc}
                *
                * Employs <tt>ZrtpFortuna</tt> as is common in neomedia.
                */
               @Override
               public void nextBytes(byte[] bytes)
               {
                   ZrtpFortuna.getInstance().nextBytes(bytes);
               }
           };

Best regards,
Lyubomir Marinov

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev


#3

Thank you very much, Ingo!

На 30.07.2014 в 05:30, Ingo Bauersachs написа:

I guess that is code for the videobridge?

Technically, it's in libjitsi and, consequently, both Videobridge and Jitsi may utilize DTLS SRTP. Practically though, DTLS SRTP is not enabled by default in Jitsi and, thus, it is unlikely that it will be used. Anyway, I saw the hang in Videobridge.

I'm not sure if your snippet would help there at all. Fortuna needs to be seeded, and we currently do that by
noise xor SecureRandom.nextBytes()
beacause noise is not always available (noise suppression, no audio on the server).

I see.

(It's a different subject and not one that you're personally responsible for so I'm just mentioning it that my audio capture device on Ubuntu 14.04 always starts muted so it is unlikely to provide any noise to Jitsi either.)

If I remember correctly, you could use a JVM parameter to tell Java which random source to use and override the default of /dev/urandom to effectively use /dev/random - which should be fast even on a VM. As Java checks for /dev/random and ignores it, you have to specify /dev/./random

Yes. The only ways I found on the Internet though were talking about modifying a JRE .properties file.

So even if you use Fortuna (which is fine to do), you need to overcome the limitation of a slow SecureRandom.

Thank you very much! You've been very helpful.


#4

There is definitely a -something parameter for the JVM to supply /dev/./random, so no need to edit a properties file. We were even able to do that from the Webstart launcher.

And you're always welcome :slight_smile:

Freundliche Grüsse,
Ingo Bauersachs

-- sent from my mobile

···

Le 30.07.2014 à 15:42, "Lyubomir Marinov" <lyubomir.marinov@jitsi.org> a écrit :

Thank you very much, Ingo!

На 30.07.2014 в 05:30, Ingo Bauersachs написа:

I guess that is code for the videobridge?

Technically, it's in libjitsi and, consequently, both Videobridge and Jitsi may utilize DTLS SRTP. Practically though, DTLS SRTP is not enabled by default in Jitsi and, thus, it is unlikely that it will be used. Anyway, I saw the hang in Videobridge.

I'm not sure if your snippet would help there at all. Fortuna needs to be seeded, and we currently do that by
noise xor SecureRandom.nextBytes()
beacause noise is not always available (noise suppression, no audio on the server).

I see.

(It's a different subject and not one that you're personally responsible for so I'm just mentioning it that my audio capture device on Ubuntu 14.04 always starts muted so it is unlikely to provide any noise to Jitsi either.)

If I remember correctly, you could use a JVM parameter to tell Java which random source to use and override the default of /dev/urandom to effectively use /dev/random - which should be fast even on a VM. As Java checks for /dev/random and ignores it, you have to specify /dev/./random

Yes. The only ways I found on the Internet though were talking about modifying a JRE .properties file.

So even if you use Fortuna (which is fine to do), you need to overcome the limitation of a slow SecureRandom.

Thank you very much! You've been very helpful.

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev