{"action":"created","comment":{"url":"https://api.github.com/repos/georgestephanis/two-factor/pulls/comments/37561069","id":37561069,"diff_hunk":"@@ -0,0 +1,427 @@\n+<?php\n+\n+ /* Copyright (c) 2014 Yubico AB\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are\n+ * met:\n+ *\n+ *   * Redistributions of source code must retain the above copyright\n+ *     notice, this list of conditions and the following disclaimer.\n+ *\n+ *   * Redistributions in binary form must reproduce the above\n+ *     copyright notice, this list of conditions and the following\n+ *     disclaimer in the documentation and/or other materials provided\n+ *     with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+namespace u2flib_server;\n+\n+/** Constant for the version of the u2f protocol */\n+const U2F_VERSION = \"U2F_V2\";\n+\n+/** Error for the authentication message not matching any outstanding\n+ * authentication request */\n+const ERR_NO_MATCHING_REQUEST = 1;\n+/** Error for the authentication message not matching any registration */\n+const ERR_NO_MATCHING_REGISTRATION = 2;\n+/** Error for the signature on the authentication message not verifying with\n+ * the correct key */\n+const ERR_AUTHENTICATION_FAILURE = 3;\n+/** Error for the challenge in the registration message not matching the\n+ * registration challenge */\n+const ERR_UNMATCHED_CHALLENGE = 4;\n+/** Error for the attestation signature on the registration message not\n+ * verifying */\n+const ERR_ATTESTATION_SIGNATURE = 5;\n+/** Error for the attestation verification not verifying */\n+const ERR_ATTESTATION_VERIFICATION = 6;\n+/** Error for not getting good random from the system */\n+const ERR_BAD_RANDOM = 7;\n+/** Error when the counter is lower than expected */\n+const ERR_COUNTER_TOO_LOW = 8;\n+/** Error decoding public key */\n+const ERR_PUBKEY_DECODE = 9;\n+/** Error user-agent returned error */\n+const ERR_BAD_UA_RETURNING = 10;\n+/** Error old OpenSSL version */\n+const ERR_OLD_OPENSSL = 11;\n+\n+/** @internal */\n+const PUBKEY_LEN = 65;\n+\n+class U2F {\n+  private $appId;\n+  private $attestDir;\n+\n+  /** @internal */\n+  private static $FIXCERTS = array(\n+    '349bca1031f8c82c4ceca38b9cebf1a69df9fb3b94eed99eb3fb9aa3822d26e8',\n+    'dd574527df608e47ae45fbba75a2afdd5c20fd94a02419381813cd55a2a3398f',\n+    '1d8764f0f7cd1352df6150045c8f638e517270e8b5dda1c63ade9c2280240cae',\n+    'd0edc9a91a1677435a953390865d208c55b3183c6759c9b5a7ff494c322558eb',\n+    '6073c436dcd064a48127ddbf6032ac1a66fd59a0c24434f070d4e564c124c897',\n+    'ca993121846c464d666096d35f13bf44c1b05af205f9b4a1e00cf6cc10c5e511');","path":"includes/Yubico/U2F.php","position":77,"original_position":77,"commit_id":"e88aeab2332053808c35407983435a8dc59d13d6","original_commit_id":"e88aeab2332053808c35407983435a8dc59d13d6","user":{"login":"georgestephanis","id":941023,"avatar_url":"https://avatars.githubusercontent.com/u/941023?v=3","gravatar_id":"","url":"https://api.github.com/users/georgestephanis","html_url":"https://github.com/georgestephanis","followers_url":"https://api.github.com/users/georgestephanis/followers","following_url":"https://api.github.com/users/georgestephanis/following{/other_user}","gists_url":"https://api.github.com/users/georgestephanis/gists{/gist_id}","starred_url":"https://api.github.com/users/georgestephanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgestephanis/subscriptions","organizations_url":"https://api.github.com/users/georgestephanis/orgs","repos_url":"https://api.github.com/users/georgestephanis/repos","events_url":"https://api.github.com/users/georgestephanis/events{/privacy}","received_events_url":"https://api.github.com/users/georgestephanis/received_events","type":"User","site_admin":false},"body":"Are these salts that would be better stored elsewhere, and not hardcoded in a library?","created_at":"2015-08-20T18:03:03Z","updated_at":"2015-08-20T18:03:03Z","html_url":"https://github.com/georgestephanis/two-factor/pull/22#discussion_r37561069","pull_request_url":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/georgestephanis/two-factor/pulls/comments/37561069"},"html":{"href":"https://github.com/georgestephanis/two-factor/pull/22#discussion_r37561069"},"pull_request":{"href":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22","id":42955614,"html_url":"https://github.com/georgestephanis/two-factor/pull/22","diff_url":"https://github.com/georgestephanis/two-factor/pull/22.diff","patch_url":"https://github.com/georgestephanis/two-factor/pull/22.patch","issue_url":"https://api.github.com/repos/georgestephanis/two-factor/issues/22","number":22,"state":"open","locked":false,"title":"Add FIDO U2F as a provider","user":{"login":"shield-9","id":3660715,"avatar_url":"https://avatars.githubusercontent.com/u/3660715?v=3","gravatar_id":"","url":"https://api.github.com/users/shield-9","html_url":"https://github.com/shield-9","followers_url":"https://api.github.com/users/shield-9/followers","following_url":"https://api.github.com/users/shield-9/following{/other_user}","gists_url":"https://api.github.com/users/shield-9/gists{/gist_id}","starred_url":"https://api.github.com/users/shield-9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shield-9/subscriptions","organizations_url":"https://api.github.com/users/shield-9/orgs","repos_url":"https://api.github.com/users/shield-9/repos","events_url":"https://api.github.com/users/shield-9/events{/privacy}","received_events_url":"https://api.github.com/users/shield-9/received_events","type":"User","site_admin":false},"body":"Tested with:\r\n* YubiKey NEO\r\n* YubiKey Edge\r\n* FIDO U2F Security Key (Yubico)\r\n* FIDO U2F Security Key (Plug-up)","created_at":"2015-08-20T17:26:50Z","updated_at":"2015-08-20T18:03:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d5371101977c090313fdb4a5ec0fe7a2a243cc50","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22/commits","review_comments_url":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22/comments","review_comment_url":"https://api.github.com/repos/georgestephanis/two-factor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/georgestephanis/two-factor/issues/22/comments","statuses_url":"https://api.github.com/repos/georgestephanis/two-factor/statuses/e88aeab2332053808c35407983435a8dc59d13d6","head":{"label":"shield-9:fido_u2f","ref":"fido_u2f","sha":"e88aeab2332053808c35407983435a8dc59d13d6","user":{"login":"shield-9","id":3660715,"avatar_url":"https://avatars.githubusercontent.com/u/3660715?v=3","gravatar_id":"","url":"https://api.github.com/users/shield-9","html_url":"https://github.com/shield-9","followers_url":"https://api.github.com/users/shield-9/followers","following_url":"https://api.github.com/users/shield-9/following{/other_user}","gists_url":"https://api.github.com/users/shield-9/gists{/gist_id}","starred_url":"https://api.github.com/users/shield-9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shield-9/subscriptions","organizations_url":"https://api.github.com/users/shield-9/orgs","repos_url":"https://api.github.com/users/shield-9/repos","events_url":"https://api.github.com/users/shield-9/events{/privacy}","received_events_url":"https://api.github.com/users/shield-9/received_events","type":"User","site_admin":false},"repo":{"id":39570953,"name":"two-factor","full_name":"shield-9/two-factor","owner":{"login":"shield-9","id":3660715,"avatar_url":"https://avatars.githubusercontent.com/u/3660715?v=3","gravatar_id":"","url":"https://api.github.com/users/shield-9","html_url":"https://github.com/shield-9","followers_url":"https://api.github.com/users/shield-9/followers","following_url":"https://api.github.com/users/shield-9/following{/other_user}","gists_url":"https://api.github.com/users/shield-9/gists{/gist_id}","starred_url":"https://api.github.com/users/shield-9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shield-9/subscriptions","organizations_url":"https://api.github.com/users/shield-9/orgs","repos_url":"https://api.github.com/users/shield-9/repos","events_url":"https://api.github.com/users/shield-9/events{/privacy}","received_events_url":"https://api.github.com/users/shield-9/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shield-9/two-factor","description":"Two-Factor Authentication for WordPress.","fork":true,"url":"https://api.github.com/repos/shield-9/two-factor","forks_url":"https://api.github.com/repos/shield-9/two-factor/forks","keys_url":"https://api.github.com/repos/shield-9/two-factor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shield-9/two-factor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shield-9/two-factor/teams","hooks_url":"https://api.github.com/repos/shield-9/two-factor/hooks","issue_events_url":"https://api.github.com/repos/shield-9/two-factor/issues/events{/number}","events_url":"https://api.github.com/repos/shield-9/two-factor/events","assignees_url":"https://api.github.com/repos/shield-9/two-factor/assignees{/user}","branches_url":"https://api.github.com/repos/shield-9/two-factor/branches{/branch}","tags_url":"https://api.github.com/repos/shield-9/two-factor/tags","blobs_url":"https://api.github.com/repos/shield-9/two-factor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shield-9/two-factor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shield-9/two-factor/git/refs{/sha}","trees_url":"https://api.github.com/repos/shield-9/two-factor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shield-9/two-factor/statuses/{sha}","languages_url":"https://api.github.com/repos/shield-9/two-factor/languages","stargazers_url":"https://api.github.com/repos/shield-9/two-factor/stargazers","contributors_url":"https://api.github.com/repos/shield-9/two-factor/contributors","subscribers_url":"https://api.github.com/repos/shield-9/two-factor/subscribers","subscription_url":"https://api.github.com/repos/shield-9/two-factor/subscription","commits_url":"https://api.github.com/repos/shield-9/two-factor/commits{/sha}","git_commits_url":"https://api.github.com/repos/shield-9/two-factor/git/commits{/sha}","comments_url":"https://api.github.com/repos/shield-9/two-factor/comments{/number}","issue_comment_url":"https://api.github.com/repos/shield-9/two-factor/issues/comments{/number}","contents_url":"https://api.github.com/repos/shield-9/two-factor/contents/{+path}","compare_url":"https://api.github.com/repos/shield-9/two-factor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shield-9/two-factor/merges","archive_url":"https://api.github.com/repos/shield-9/two-factor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shield-9/two-factor/downloads","issues_url":"https://api.github.com/repos/shield-9/two-factor/issues{/number}","pulls_url":"https://api.github.com/repos/shield-9/two-factor/pulls{/number}","milestones_url":"https://api.github.com/repos/shield-9/two-factor/milestones{/number}","notifications_url":"https://api.github.com/repos/shield-9/two-factor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shield-9/two-factor/labels{/name}","releases_url":"https://api.github.com/repos/shield-9/two-factor/releases{/id}","created_at":"2015-07-23T14:09:42Z","updated_at":"2015-07-23T14:09:43Z","pushed_at":"2015-08-20T17:16:19Z","git_url":"git://github.com/shield-9/two-factor.git","ssh_url":"git@github.com:shield-9/two-factor.git","clone_url":"https://github.com/shield-9/two-factor.git","svn_url":"https://github.com/shield-9/two-factor","homepage":"https://github.com/georgestephanis/two-factor","size":244,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"georgestephanis:master","ref":"master","sha":"d2bfdfc66e0d5f266e2d6e4d41974292278f7e8e","user":{"login":"georgestephanis","id":941023,"avatar_url":"https://avatars.githubusercontent.com/u/941023?v=3","gravatar_id":"","url":"https://api.github.com/users/georgestephanis","html_url":"https://github.com/georgestephanis","followers_url":"https://api.github.com/users/georgestephanis/followers","following_url":"https://api.github.com/users/georgestephanis/following{/other_user}","gists_url":"https://api.github.com/users/georgestephanis/gists{/gist_id}","starred_url":"https://api.github.com/users/georgestephanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgestephanis/subscriptions","organizations_url":"https://api.github.com/users/georgestephanis/orgs","repos_url":"https://api.github.com/users/georgestephanis/repos","events_url":"https://api.github.com/users/georgestephanis/events{/privacy}","received_events_url":"https://api.github.com/users/georgestephanis/received_events","type":"User","site_admin":false},"repo":{"id":25655458,"name":"two-factor","full_name":"georgestephanis/two-factor","owner":{"login":"georgestephanis","id":941023,"avatar_url":"https://avatars.githubusercontent.com/u/941023?v=3","gravatar_id":"","url":"https://api.github.com/users/georgestephanis","html_url":"https://github.com/georgestephanis","followers_url":"https://api.github.com/users/georgestephanis/followers","following_url":"https://api.github.com/users/georgestephanis/following{/other_user}","gists_url":"https://api.github.com/users/georgestephanis/gists{/gist_id}","starred_url":"https://api.github.com/users/georgestephanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgestephanis/subscriptions","organizations_url":"https://api.github.com/users/georgestephanis/orgs","repos_url":"https://api.github.com/users/georgestephanis/repos","events_url":"https://api.github.com/users/georgestephanis/events{/privacy}","received_events_url":"https://api.github.com/users/georgestephanis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/georgestephanis/two-factor","description":"Two-Factor Authentication for WordPress.","fork":false,"url":"https://api.github.com/repos/georgestephanis/two-factor","forks_url":"https://api.github.com/repos/georgestephanis/two-factor/forks","keys_url":"https://api.github.com/repos/georgestephanis/two-factor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/georgestephanis/two-factor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/georgestephanis/two-factor/teams","hooks_url":"https://api.github.com/repos/georgestephanis/two-factor/hooks","issue_events_url":"https://api.github.com/repos/georgestephanis/two-factor/issues/events{/number}","events_url":"https://api.github.com/repos/georgestephanis/two-factor/events","assignees_url":"https://api.github.com/repos/georgestephanis/two-factor/assignees{/user}","branches_url":"https://api.github.com/repos/georgestephanis/two-factor/branches{/branch}","tags_url":"https://api.github.com/repos/georgestephanis/two-factor/tags","blobs_url":"https://api.github.com/repos/georgestephanis/two-factor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/georgestephanis/two-factor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/georgestephanis/two-factor/git/refs{/sha}","trees_url":"https://api.github.com/repos/georgestephanis/two-factor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/georgestephanis/two-factor/statuses/{sha}","languages_url":"https://api.github.com/repos/georgestephanis/two-factor/languages","stargazers_url":"https://api.github.com/repos/georgestephanis/two-factor/stargazers","contributors_url":"https://api.github.com/repos/georgestephanis/two-factor/contributors","subscribers_url":"https://api.github.com/repos/georgestephanis/two-factor/subscribers","subscription_url":"https://api.github.com/repos/georgestephanis/two-factor/subscription","commits_url":"https://api.github.com/repos/georgestephanis/two-factor/commits{/sha}","git_commits_url":"https://api.github.com/repos/georgestephanis/two-factor/git/commits{/sha}","comments_url":"https://api.github.com/repos/georgestephanis/two-factor/comments{/number}","issue_comment_url":"https://api.github.com/repos/georgestephanis/two-factor/issues/comments{/number}","contents_url":"https://api.github.com/repos/georgestephanis/two-factor/contents/{+path}","compare_url":"https://api.github.com/repos/georgestephanis/two-factor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/georgestephanis/two-factor/merges","archive_url":"https://api.github.com/repos/georgestephanis/two-factor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/georgestephanis/two-factor/downloads","issues_url":"https://api.github.com/repos/georgestephanis/two-factor/issues{/number}","pulls_url":"https://api.github.com/repos/georgestephanis/two-factor/pulls{/number}","milestones_url":"https://api.github.com/repos/georgestephanis/two-factor/milestones{/number}","notifications_url":"https://api.github.com/repos/georgestephanis/two-factor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/georgestephanis/two-factor/labels{/name}","releases_url":"https://api.github.com/repos/georgestephanis/two-factor/releases{/id}","created_at":"2014-10-23T20:03:04Z","updated_at":"2015-08-20T15:44:13Z","pushed_at":"2015-08-20T17:52:13Z","git_url":"git://github.com/georgestephanis/two-factor.git","ssh_url":"git@github.com:georgestephanis/two-factor.git","clone_url":"https://github.com/georgestephanis/two-factor.git","svn_url":"https://github.com/georgestephanis/two-factor","homepage":"https://github.com/georgestephanis/two-factor","size":746,"stargazers_count":45,"watchers_count":45,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":12,"forks":13,"open_issues":12,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22"},"html":{"href":"https://github.com/georgestephanis/two-factor/pull/22"},"issue":{"href":"https://api.github.com/repos/georgestephanis/two-factor/issues/22"},"comments":{"href":"https://api.github.com/repos/georgestephanis/two-factor/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/georgestephanis/two-factor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/georgestephanis/two-factor/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/georgestephanis/two-factor/statuses/e88aeab2332053808c35407983435a8dc59d13d6"}}}}