GitHub PullRequestReviewCommentEvent at 2014-06-15 17:24:12
Repository: phpseclib
Actor: terrafrost
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/phpseclib/phpseclib/pulls/comments/13787138","id":13787138,"diff_hunk":"@@ -222,30 +253,56 @@ function crypt_random_string($length)\n             //\n             // http://www.opensource.apple.com/source/OpenSSL/OpenSSL-38/openssl/fips-1.0/rand/fips_rand.c\n             // (do a search for \"ANS X9.31 A.2.4\")\n-            //\n-            // ANSI X9.31 recommends ciphers be used and phpseclib does use them if they're available (see\n-            // later on in the code) but if they're not we'll use sha1\n             $result = '';\n-            while (strlen($result) < $length) { // each loop adds 20 bytes\n-                // microtime() isn't packed as \"densely\" as it could be but then neither is that the idea.\n-                // the idea is simply to ensure that each \"block\" has a unique element to it.\n-                $i = pack('H*', sha1(microtime()));\n-                $r = pack('H*', sha1($i ^ $v));\n-                $v = pack('H*', sha1($r ^ $i));\n+            while (strlen($result) < $length) {\n+                $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21\n+                $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20\n+                $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20\n                 $result.= $r;\n             }\n             return substr($result, 0, $length);\n         }\n \n-        //return $crypto->encrypt(str_repeat(\"\\0\", $length));\n+        $keyStream = &$crypto['keyStream'];\n+        $i = &$crypto['i'];\n+        $j = &$crypto['j'];\n \n         $result = '';\n         while (strlen($result) < $length) {\n-            $i = $crypto->encrypt(microtime());\n-            $r = $crypto->encrypt($i ^ $v);\n-            $v = $crypto->encrypt($r ^ $i);\n+            $i = crypt_random_string_rc4_prga(microtime(), $keyStream, $i, $j);\n+            $r = crypt_random_string_rc4_prga($i ^ $v,     $keyStream, $i, $j);\n+            $v = crypt_random_string_rc4_prga($r ^ $i,     $keyStream, $i, $j);\n             $result.= $r;\n         }\n         return substr($result, 0, $length);\n     }\n+\n+    /**\n+     * RC4's PRGA\n+     *\n+     * A last-resort fallback if no other ciphers are available for available for use.","path":"phpseclib/Crypt/Random.php","position":133,"original_position":133,"commit_id":"5a8a68fd6448db5d50f6f1c84461548f3b017c78","original_commit_id":"5a8a68fd6448db5d50f6f1c84461548f3b017c78","user":{"login":"terrafrost","id":214474,"avatar_url":"https://avatars.githubusercontent.com/u/214474?","gravatar_id":"80a10f454dd9b3cb5a69af1af38d0920","url":"https://api.github.com/users/terrafrost","html_url":"https://github.com/terrafrost","followers_url":"https://api.github.com/users/terrafrost/followers","following_url":"https://api.github.com/users/terrafrost/following{/other_user}","gists_url":"https://api.github.com/users/terrafrost/gists{/gist_id}","starred_url":"https://api.github.com/users/terrafrost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrafrost/subscriptions","organizations_url":"https://api.github.com/users/terrafrost/orgs","repos_url":"https://api.github.com/users/terrafrost/repos","events_url":"https://api.github.com/users/terrafrost/events{/privacy}","received_events_url":"https://api.github.com/users/terrafrost/received_events","type":"User","site_admin":false},"body":"Good catch!","created_at":"2014-06-15T17:24:12Z","updated_at":"2014-06-15T17:24:12Z","html_url":"https://github.com/phpseclib/phpseclib/pull/372#discussion_r13787138","pull_request_url":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372","_links":{"self":{"href":"https://api.github.com/repos/phpseclib/phpseclib/pulls/comments/13787138"},"html":{"href":"https://github.com/phpseclib/phpseclib/pull/372#discussion_r13787138"},"pull_request":{"href":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372"}}},"pull_request":{"url":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372","id":17144984,"html_url":"https://github.com/phpseclib/phpseclib/pull/372","diff_url":"https://github.com/phpseclib/phpseclib/pull/372.diff","patch_url":"https://github.com/phpseclib/phpseclib/pull/372.patch","issue_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/372","number":372,"state":"open","title":"changes to Crypt_Random","user":{"login":"terrafrost","id":214474,"avatar_url":"https://avatars.githubusercontent.com/u/214474?","gravatar_id":"80a10f454dd9b3cb5a69af1af38d0920","url":"https://api.github.com/users/terrafrost","html_url":"https://github.com/terrafrost","followers_url":"https://api.github.com/users/terrafrost/followers","following_url":"https://api.github.com/users/terrafrost/following{/other_user}","gists_url":"https://api.github.com/users/terrafrost/gists{/gist_id}","starred_url":"https://api.github.com/users/terrafrost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrafrost/subscriptions","organizations_url":"https://api.github.com/users/terrafrost/orgs","repos_url":"https://api.github.com/users/terrafrost/repos","events_url":"https://api.github.com/users/terrafrost/events{/privacy}","received_events_url":"https://api.github.com/users/terrafrost/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-06-14T16:55:38Z","updated_at":"2014-06-15T17:24:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"066454844f6e1ff483e7e87111bfa1336dee524e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372/commits","review_comments_url":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372/comments","review_comment_url":"https://api.github.com/repos/phpseclib/phpseclib/pulls/comments/{number}","comments_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/372/comments","statuses_url":"https://api.github.com/repos/phpseclib/phpseclib/statuses/5a8a68fd6448db5d50f6f1c84461548f3b017c78","head":{"label":"terrafrost:random-improvements","ref":"random-improvements","sha":"5a8a68fd6448db5d50f6f1c84461548f3b017c78","user":{"login":"terrafrost","id":214474,"avatar_url":"https://avatars.githubusercontent.com/u/214474?","gravatar_id":"80a10f454dd9b3cb5a69af1af38d0920","url":"https://api.github.com/users/terrafrost","html_url":"https://github.com/terrafrost","followers_url":"https://api.github.com/users/terrafrost/followers","following_url":"https://api.github.com/users/terrafrost/following{/other_user}","gists_url":"https://api.github.com/users/terrafrost/gists{/gist_id}","starred_url":"https://api.github.com/users/terrafrost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrafrost/subscriptions","organizations_url":"https://api.github.com/users/terrafrost/orgs","repos_url":"https://api.github.com/users/terrafrost/repos","events_url":"https://api.github.com/users/terrafrost/events{/privacy}","received_events_url":"https://api.github.com/users/terrafrost/received_events","type":"User","site_admin":false},"repo":{"id":4767988,"name":"phpseclib","full_name":"terrafrost/phpseclib","owner":{"login":"terrafrost","id":214474,"avatar_url":"https://avatars.githubusercontent.com/u/214474?","gravatar_id":"80a10f454dd9b3cb5a69af1af38d0920","url":"https://api.github.com/users/terrafrost","html_url":"https://github.com/terrafrost","followers_url":"https://api.github.com/users/terrafrost/followers","following_url":"https://api.github.com/users/terrafrost/following{/other_user}","gists_url":"https://api.github.com/users/terrafrost/gists{/gist_id}","starred_url":"https://api.github.com/users/terrafrost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terrafrost/subscriptions","organizations_url":"https://api.github.com/users/terrafrost/orgs","repos_url":"https://api.github.com/users/terrafrost/repos","events_url":"https://api.github.com/users/terrafrost/events{/privacy}","received_events_url":"https://api.github.com/users/terrafrost/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/terrafrost/phpseclib","description":"PHP Secure Communications Library","fork":true,"url":"https://api.github.com/repos/terrafrost/phpseclib","forks_url":"https://api.github.com/repos/terrafrost/phpseclib/forks","keys_url":"https://api.github.com/repos/terrafrost/phpseclib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/terrafrost/phpseclib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/terrafrost/phpseclib/teams","hooks_url":"https://api.github.com/repos/terrafrost/phpseclib/hooks","issue_events_url":"https://api.github.com/repos/terrafrost/phpseclib/issues/events{/number}","events_url":"https://api.github.com/repos/terrafrost/phpseclib/events","assignees_url":"https://api.github.com/repos/terrafrost/phpseclib/assignees{/user}","branches_url":"https://api.github.com/repos/terrafrost/phpseclib/branches{/branch}","tags_url":"https://api.github.com/repos/terrafrost/phpseclib/tags","blobs_url":"https://api.github.com/repos/terrafrost/phpseclib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/terrafrost/phpseclib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/terrafrost/phpseclib/git/refs{/sha}","trees_url":"https://api.github.com/repos/terrafrost/phpseclib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/terrafrost/phpseclib/statuses/{sha}","languages_url":"https://api.github.com/repos/terrafrost/phpseclib/languages","stargazers_url":"https://api.github.com/repos/terrafrost/phpseclib/stargazers","contributors_url":"https://api.github.com/repos/terrafrost/phpseclib/contributors","subscribers_url":"https://api.github.com/repos/terrafrost/phpseclib/subscribers","subscription_url":"https://api.github.com/repos/terrafrost/phpseclib/subscription","commits_url":"https://api.github.com/repos/terrafrost/phpseclib/commits{/sha}","git_commits_url":"https://api.github.com/repos/terrafrost/phpseclib/git/commits{/sha}","comments_url":"https://api.github.com/repos/terrafrost/phpseclib/comments{/number}","issue_comment_url":"https://api.github.com/repos/terrafrost/phpseclib/issues/comments/{number}","contents_url":"https://api.github.com/repos/terrafrost/phpseclib/contents/{+path}","compare_url":"https://api.github.com/repos/terrafrost/phpseclib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/terrafrost/phpseclib/merges","archive_url":"https://api.github.com/repos/terrafrost/phpseclib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/terrafrost/phpseclib/downloads","issues_url":"https://api.github.com/repos/terrafrost/phpseclib/issues{/number}","pulls_url":"https://api.github.com/repos/terrafrost/phpseclib/pulls{/number}","milestones_url":"https://api.github.com/repos/terrafrost/phpseclib/milestones{/number}","notifications_url":"https://api.github.com/repos/terrafrost/phpseclib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/terrafrost/phpseclib/labels{/name}","releases_url":"https://api.github.com/repos/terrafrost/phpseclib/releases{/id}","created_at":"2012-06-23T22:07:05Z","updated_at":"2014-06-15T17:14:15Z","pushed_at":"2014-06-15T17:14:16Z","git_url":"git://github.com/terrafrost/phpseclib.git","ssh_url":"git@github.com:terrafrost/phpseclib.git","clone_url":"https://github.com/terrafrost/phpseclib.git","svn_url":"https://github.com/terrafrost/phpseclib","homepage":null,"size":4693,"stargazers_count":3,"watchers_count":3,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"phpseclib:master","ref":"master","sha":"8e07ebfd51339ac0f3b90a327d5dc3132089bd4c","user":{"login":"phpseclib","id":1820952,"avatar_url":"https://avatars.githubusercontent.com/u/1820952?","gravatar_id":"9cf3e9b05eb22f80d5be4b7c380fcf44","url":"https://api.github.com/users/phpseclib","html_url":"https://github.com/phpseclib","followers_url":"https://api.github.com/users/phpseclib/followers","following_url":"https://api.github.com/users/phpseclib/following{/other_user}","gists_url":"https://api.github.com/users/phpseclib/gists{/gist_id}","starred_url":"https://api.github.com/users/phpseclib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phpseclib/subscriptions","organizations_url":"https://api.github.com/users/phpseclib/orgs","repos_url":"https://api.github.com/users/phpseclib/repos","events_url":"https://api.github.com/users/phpseclib/events{/privacy}","received_events_url":"https://api.github.com/users/phpseclib/received_events","type":"Organization","site_admin":false},"repo":{"id":4565995,"name":"phpseclib","full_name":"phpseclib/phpseclib","owner":{"login":"phpseclib","id":1820952,"avatar_url":"https://avatars.githubusercontent.com/u/1820952?","gravatar_id":"9cf3e9b05eb22f80d5be4b7c380fcf44","url":"https://api.github.com/users/phpseclib","html_url":"https://github.com/phpseclib","followers_url":"https://api.github.com/users/phpseclib/followers","following_url":"https://api.github.com/users/phpseclib/following{/other_user}","gists_url":"https://api.github.com/users/phpseclib/gists{/gist_id}","starred_url":"https://api.github.com/users/phpseclib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phpseclib/subscriptions","organizations_url":"https://api.github.com/users/phpseclib/orgs","repos_url":"https://api.github.com/users/phpseclib/repos","events_url":"https://api.github.com/users/phpseclib/events{/privacy}","received_events_url":"https://api.github.com/users/phpseclib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phpseclib/phpseclib","description":"PHP Secure Communications Library","fork":false,"url":"https://api.github.com/repos/phpseclib/phpseclib","forks_url":"https://api.github.com/repos/phpseclib/phpseclib/forks","keys_url":"https://api.github.com/repos/phpseclib/phpseclib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phpseclib/phpseclib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phpseclib/phpseclib/teams","hooks_url":"https://api.github.com/repos/phpseclib/phpseclib/hooks","issue_events_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/events{/number}","events_url":"https://api.github.com/repos/phpseclib/phpseclib/events","assignees_url":"https://api.github.com/repos/phpseclib/phpseclib/assignees{/user}","branches_url":"https://api.github.com/repos/phpseclib/phpseclib/branches{/branch}","tags_url":"https://api.github.com/repos/phpseclib/phpseclib/tags","blobs_url":"https://api.github.com/repos/phpseclib/phpseclib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phpseclib/phpseclib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phpseclib/phpseclib/git/refs{/sha}","trees_url":"https://api.github.com/repos/phpseclib/phpseclib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phpseclib/phpseclib/statuses/{sha}","languages_url":"https://api.github.com/repos/phpseclib/phpseclib/languages","stargazers_url":"https://api.github.com/repos/phpseclib/phpseclib/stargazers","contributors_url":"https://api.github.com/repos/phpseclib/phpseclib/contributors","subscribers_url":"https://api.github.com/repos/phpseclib/phpseclib/subscribers","subscription_url":"https://api.github.com/repos/phpseclib/phpseclib/subscription","commits_url":"https://api.github.com/repos/phpseclib/phpseclib/commits{/sha}","git_commits_url":"https://api.github.com/repos/phpseclib/phpseclib/git/commits{/sha}","comments_url":"https://api.github.com/repos/phpseclib/phpseclib/comments{/number}","issue_comment_url":"https://api.github.com/repos/phpseclib/phpseclib/issues/comments/{number}","contents_url":"https://api.github.com/repos/phpseclib/phpseclib/contents/{+path}","compare_url":"https://api.github.com/repos/phpseclib/phpseclib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phpseclib/phpseclib/merges","archive_url":"https://api.github.com/repos/phpseclib/phpseclib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phpseclib/phpseclib/downloads","issues_url":"https://api.github.com/repos/phpseclib/phpseclib/issues{/number}","pulls_url":"https://api.github.com/repos/phpseclib/phpseclib/pulls{/number}","milestones_url":"https://api.github.com/repos/phpseclib/phpseclib/milestones{/number}","notifications_url":"https://api.github.com/repos/phpseclib/phpseclib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phpseclib/phpseclib/labels{/name}","releases_url":"https://api.github.com/repos/phpseclib/phpseclib/releases{/id}","created_at":"2012-06-05T21:55:28Z","updated_at":"2014-06-13T21:55:31Z","pushed_at":"2014-06-13T21:50:29Z","git_url":"git://github.com/phpseclib/phpseclib.git","ssh_url":"git@github.com:phpseclib/phpseclib.git","clone_url":"https://github.com/phpseclib/phpseclib.git","svn_url":"https://github.com/phpseclib/phpseclib","homepage":"http://phpseclib.sourceforge.net","size":7411,"stargazers_count":427,"watchers_count":427,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":142,"mirror_url":null,"open_issues_count":41,"forks":142,"open_issues":41,"watchers":427,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372"},"html":{"href":"https://github.com/phpseclib/phpseclib/pull/372"},"issue":{"href":"https://api.github.com/repos/phpseclib/phpseclib/issues/372"},"comments":{"href":"https://api.github.com/repos/phpseclib/phpseclib/issues/372/comments"},"review_comments":{"href":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372/comments"},"review_comment":{"href":"https://api.github.com/repos/phpseclib/phpseclib/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/phpseclib/phpseclib/pulls/372/commits"},"statuses":{"href":"https://api.github.com/repos/phpseclib/phpseclib/statuses/5a8a68fd6448db5d50f6f1c84461548f3b017c78"}}}}