{"action":"created","issue":{"url":"https://api.github.com/repos/jitsi/libjitsi/issues/113","repository_url":"https://api.github.com/repos/jitsi/libjitsi","labels_url":"https://api.github.com/repos/jitsi/libjitsi/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/jitsi/libjitsi/issues/113/comments","events_url":"https://api.github.com/repos/jitsi/libjitsi/issues/113/events","html_url":"https://github.com/jitsi/libjitsi/pull/113","id":142285359,"number":113,"title":"Use SecureRandom instead of ZrtpFortuna","user":{"login":"champtar","id":3536755,"avatar_url":"https://avatars.githubusercontent.com/u/3536755?v=3","gravatar_id":"","url":"https://api.github.com/users/champtar","html_url":"https://github.com/champtar","followers_url":"https://api.github.com/users/champtar/followers","following_url":"https://api.github.com/users/champtar/following{/other_user}","gists_url":"https://api.github.com/users/champtar/gists{/gist_id}","starred_url":"https://api.github.com/users/champtar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/champtar/subscriptions","organizations_url":"https://api.github.com/users/champtar/orgs","repos_url":"https://api.github.com/users/champtar/repos","events_url":"https://api.github.com/users/champtar/events{/privacy}","received_events_url":"https://api.github.com/users/champtar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2016-03-21T08:35:44Z","updated_at":"2016-04-03T16:54:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jitsi/libjitsi/pulls/113","html_url":"https://github.com/jitsi/libjitsi/pull/113","diff_url":"https://github.com/jitsi/libjitsi/pull/113.diff","patch_url":"https://github.com/jitsi/libjitsi/pull/113.patch"},"body":"Drop createSecureRandom()\r\n\r\nOn linux, new SecureRandom() uses /dev/urandom for nextBytes() calls\r\nand /dev/random for generateSeed().\r\nI've found no call to generateSeed, so no blocking calls.\r\nI've also double checked with \"strace -e trace=read -y -f <jvb command>\"\r\nand i only see /dev/urandom reads (no /dev/random)\r\nand only for connections initialisation\r\n\r\nWe are not sure of ZrtpFortuna safety at 100%:\r\non my desktop dev machine ZrtpFortunaEntropyGatherer.setEntropy()\r\nreturn false (audioCaptureDevice == null) which mean that no reseeding take place\r\nInitial seeding is made with SecureRandom since\r\nhttps://github.com/jitsi/zrtp4j/commit/1bd0743d9cdd1750def56ff60951a99d44db2a87\r\n\r\nProfiling show no performance impact, so better use a know good CSPRNG\r\n\r\nP.S:\r\nsome discussion already took place in #108 and #98"},"comment":{"url":"https://api.github.com/repos/jitsi/libjitsi/issues/comments/205009210","html_url":"https://github.com/jitsi/libjitsi/pull/113#issuecomment-205009210","issue_url":"https://api.github.com/repos/jitsi/libjitsi/issues/113","id":205009210,"user":{"login":"ibauersachs","id":949783,"avatar_url":"https://avatars.githubusercontent.com/u/949783?v=3","gravatar_id":"","url":"https://api.github.com/users/ibauersachs","html_url":"https://github.com/ibauersachs","followers_url":"https://api.github.com/users/ibauersachs/followers","following_url":"https://api.github.com/users/ibauersachs/following{/other_user}","gists_url":"https://api.github.com/users/ibauersachs/gists{/gist_id}","starred_url":"https://api.github.com/users/ibauersachs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibauersachs/subscriptions","organizations_url":"https://api.github.com/users/ibauersachs/orgs","repos_url":"https://api.github.com/users/ibauersachs/repos","events_url":"https://api.github.com/users/ibauersachs/events{/privacy}","received_events_url":"https://api.github.com/users/ibauersachs/received_events","type":"User","site_admin":false},"created_at":"2016-04-03T16:54:49Z","updated_at":"2016-04-03T16:54:49Z","body":"So, finally went through the sources of Java to understand what's going on.\r\n\r\nJava 6, 7:\r\nnativeAvail = exists(/dev/random) && exists(/dev/urandom)\r\nif (nativeAvail && securerandom.source==file:/dev/urandom) -> new SecureRandom() == NativePRNG\r\n\r\nJava 8:\r\nnativeAvail = canread(/dev/random) && canread(/dev/urandom)\r\nrandSource = (securerandom.source==file:/dev/urandom || securerandom.source==file:/dev/random)\r\nif (nativAvail && ) -> new SecureRandom() == NativePRNG\r\n\r\n(On Windows ::CryptGenRandom() is used).\r\n\r\n/dev/random is used to seed, then /dev/urandom for nextBytes(...). If /dev/random is drained while seeding 20 bytes, `new SecureRandom()` can block. Based on this, can you please extend this PR with:\r\n- Drop org.jitsi.impl.neomedia.transform.zrtp.ZrtpFortunaEntropyGatherer completely\r\n- Replace contents MediaServiceImpl.postInitializeOnce with\r\n```\r\n        logger.info(\"Seeding SecureRandom...\");\r\n        SecureRandom rnd = new SecureRandom();\r\n        byte[] b = new byte[20];\r\n        rnd.nextBytes(b);\r\n        logger.info(\"SecureRandom seeding finished. Bytes read: \" + b.length);\r\n```\r\n\r\nIf /dev/random is drained, we block during startup. But it will guarantee us that we won't block while the application (JVB, Jitsi) is running."}}