{"action":"created","comment":{"url":"https://api.github.com/repos/GridPlus/safe-card/pulls/comments/324701395","pull_request_review_id":288662756,"id":324701395,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMyNDcwMTM5NQ==","diff_hunk":"@@ -1076,12 +1138,31 @@ private void generateKey(APDU apdu) {\n       ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);\n     }\n \n-    apduBuffer[ISO7816.OFFSET_LC] = BIP39_SEED_SIZE;\n+    // Sanitize P1 input\n+    byte exportability = (byte) MASTERSEED_EMPTY;\n+    switch(apduBuffer[ISO7816.OFFSET_P1]) {\n+      case (byte) 0:\n+        exportability = (byte) MASTERSEED_NOT_EXPORTABLE;\n+        break;\n+      case (byte) 1:\n+        exportability = (byte) MASTERSEED_EXPORTABLE;\n+        break;\n+      default:\n+        ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);\n+        break;\n+    }\n+\n+    // Generate random seed\n     crypto.random.generateData(apduBuffer, ISO7816.OFFSET_CDATA, BIP39_SEED_SIZE);\n \n+    // Load the generated seed\n     loadSeed(apduBuffer);\n     pinlessPathLen = 0;\n-    generateKeyUIDAndRespond(apdu, apduBuffer);\n+\n+    // Save seed exportability (this also indicates the seed as valid)\n+    masterSeedStatus = exportability; // Only save seed exportability after seed successfully loaded\n+\n+    secureChannel.respond(apdu, BIP39_SEED_SIZE, ISO7816.SW_NO_ERROR);","path":"src/main/java/im/status/keycard/KeycardApplet.java","position":235,"original_position":235,"commit_id":"f6541f220d337c59056a5ac479166f98ff451600","original_commit_id":"f6541f220d337c59056a5ac479166f98ff451600","user":{"login":"phreaknik","id":7054814,"node_id":"MDQ6VXNlcjcwNTQ4MTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/7054814?v=4","gravatar_id":"","url":"https://api.github.com/users/phreaknik","html_url":"https://github.com/phreaknik","followers_url":"https://api.github.com/users/phreaknik/followers","following_url":"https://api.github.com/users/phreaknik/following{/other_user}","gists_url":"https://api.github.com/users/phreaknik/gists{/gist_id}","starred_url":"https://api.github.com/users/phreaknik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phreaknik/subscriptions","organizations_url":"https://api.github.com/users/phreaknik/orgs","repos_url":"https://api.github.com/users/phreaknik/repos","events_url":"https://api.github.com/users/phreaknik/events{/privacy}","received_events_url":"https://api.github.com/users/phreaknik/received_events","type":"User","site_admin":false},"body":"Ok, the only other thing I would consider is if we should modify the \"non-exportable\" case so that it doesn't export.\r\n\r\nNot sure if you guys want: \"never exportable ever\"\r\nor just: \"export once at creation, but _never again_ exportable\"","created_at":"2019-09-16T14:18:59Z","updated_at":"2019-09-16T14:18:59Z","html_url":"https://github.com/GridPlus/safe-card/pull/45#discussion_r324701395","pull_request_url":"https://api.github.com/repos/GridPlus/safe-card/pulls/45","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/GridPlus/safe-card/pulls/comments/324701395"},"html":{"href":"https://github.com/GridPlus/safe-card/pull/45#discussion_r324701395"},"pull_request":{"href":"https://api.github.com/repos/GridPlus/safe-card/pulls/45"}},"in_reply_to_id":323954267},"pull_request":{"url":"https://api.github.com/repos/GridPlus/safe-card/pulls/45","id":312810177,"node_id":"MDExOlB1bGxSZXF1ZXN0MzEyODEwMTc3","html_url":"https://github.com/GridPlus/safe-card/pull/45","diff_url":"https://github.com/GridPlus/safe-card/pull/45.diff","patch_url":"https://github.com/GridPlus/safe-card/pull/45.patch","issue_url":"https://api.github.com/repos/GridPlus/safe-card/issues/45","number":45,"state":"open","locked":false,"title":"GridPlus certificate based pairing","user":{"login":"phreaknik","id":7054814,"node_id":"MDQ6VXNlcjcwNTQ4MTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/7054814?v=4","gravatar_id":"","url":"https://api.github.com/users/phreaknik","html_url":"https://github.com/phreaknik","followers_url":"https://api.github.com/users/phreaknik/followers","following_url":"https://api.github.com/users/phreaknik/following{/other_user}","gists_url":"https://api.github.com/users/phreaknik/gists{/gist_id}","starred_url":"https://api.github.com/users/phreaknik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phreaknik/subscriptions","organizations_url":"https://api.github.com/users/phreaknik/orgs","repos_url":"https://api.github.com/users/phreaknik/repos","events_url":"https://api.github.com/users/phreaknik/events{/privacy}","received_events_url":"https://api.github.com/users/phreaknik/received_events","type":"User","site_admin":false},"body":"Refactor pairing process to allow certificate based pairing.\r\n\r\nFunctional tests pass for the following commands:\r\n- [x] `identifyCard()`\r\n- [x] `loadCert()`\r\n- [x] `init()`\r\n- [x] `pairStep1()`\r\n- [x] `pairStep2()`\r\n\r\nOther commands have not been tested, but they were not modified in this PR","created_at":"2019-08-30T16:36:13Z","updated_at":"2019-09-16T14:18:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb8b98b3be55550fb58ec9dee6ce1f103e6381b0","assignee":null,"assignees":[],"requested_reviewers":[{"login":"afkamalipour","id":7102024,"node_id":"MDQ6VXNlcjcxMDIwMjQ=","avatar_url":"https://avatars0.githubusercontent.com/u/7102024?v=4","gravatar_id":"","url":"https://api.github.com/users/afkamalipour","html_url":"https://github.com/afkamalipour","followers_url":"https://api.github.com/users/afkamalipour/followers","following_url":"https://api.github.com/users/afkamalipour/following{/other_user}","gists_url":"https://api.github.com/users/afkamalipour/gists{/gist_id}","starred_url":"https://api.github.com/users/afkamalipour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afkamalipour/subscriptions","organizations_url":"https://api.github.com/users/afkamalipour/orgs","repos_url":"https://api.github.com/users/afkamalipour/repos","events_url":"https://api.github.com/users/afkamalipour/events{/privacy}","received_events_url":"https://api.github.com/users/afkamalipour/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/GridPlus/safe-card/pulls/45/commits","review_comments_url":"https://api.github.com/repos/GridPlus/safe-card/pulls/45/comments","review_comment_url":"https://api.github.com/repos/GridPlus/safe-card/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GridPlus/safe-card/issues/45/comments","statuses_url":"https://api.github.com/repos/GridPlus/safe-card/statuses/f6541f220d337c59056a5ac479166f98ff451600","head":{"label":"GridPlus:safecard-refactor","ref":"safecard-refactor","sha":"f6541f220d337c59056a5ac479166f98ff451600","user":{"login":"GridPlus","id":28931745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTMxNzQ1","avatar_url":"https://avatars3.githubusercontent.com/u/28931745?v=4","gravatar_id":"","url":"https://api.github.com/users/GridPlus","html_url":"https://github.com/GridPlus","followers_url":"https://api.github.com/users/GridPlus/followers","following_url":"https://api.github.com/users/GridPlus/following{/other_user}","gists_url":"https://api.github.com/users/GridPlus/gists{/gist_id}","starred_url":"https://api.github.com/users/GridPlus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GridPlus/subscriptions","organizations_url":"https://api.github.com/users/GridPlus/orgs","repos_url":"https://api.github.com/users/GridPlus/repos","events_url":"https://api.github.com/users/GridPlus/events{/privacy}","received_events_url":"https://api.github.com/users/GridPlus/received_events","type":"Organization","site_admin":false},"repo":{"id":180620370,"node_id":"MDEwOlJlcG9zaXRvcnkxODA2MjAzNzA=","name":"safe-card","full_name":"GridPlus/safe-card","private":false,"owner":{"login":"GridPlus","id":28931745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTMxNzQ1","avatar_url":"https://avatars3.githubusercontent.com/u/28931745?v=4","gravatar_id":"","url":"https://api.github.com/users/GridPlus","html_url":"https://github.com/GridPlus","followers_url":"https://api.github.com/users/GridPlus/followers","following_url":"https://api.github.com/users/GridPlus/following{/other_user}","gists_url":"https://api.github.com/users/GridPlus/gists{/gist_id}","starred_url":"https://api.github.com/users/GridPlus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GridPlus/subscriptions","organizations_url":"https://api.github.com/users/GridPlus/orgs","repos_url":"https://api.github.com/users/GridPlus/repos","events_url":"https://api.github.com/users/GridPlus/events{/privacy}","received_events_url":"https://api.github.com/users/GridPlus/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/GridPlus/safe-card","description":"Javacard applet for storing secrets and spending cryptocurrencies","fork":true,"url":"https://api.github.com/repos/GridPlus/safe-card","forks_url":"https://api.github.com/repos/GridPlus/safe-card/forks","keys_url":"https://api.github.com/repos/GridPlus/safe-card/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GridPlus/safe-card/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GridPlus/safe-card/teams","hooks_url":"https://api.github.com/repos/GridPlus/safe-card/hooks","issue_events_url":"https://api.github.com/repos/GridPlus/safe-card/issues/events{/number}","events_url":"https://api.github.com/repos/GridPlus/safe-card/events","assignees_url":"https://api.github.com/repos/GridPlus/safe-card/assignees{/user}","branches_url":"https://api.github.com/repos/GridPlus/safe-card/branches{/branch}","tags_url":"https://api.github.com/repos/GridPlus/safe-card/tags","blobs_url":"https://api.github.com/repos/GridPlus/safe-card/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GridPlus/safe-card/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GridPlus/safe-card/git/refs{/sha}","trees_url":"https://api.github.com/repos/GridPlus/safe-card/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GridPlus/safe-card/statuses/{sha}","languages_url":"https://api.github.com/repos/GridPlus/safe-card/languages","stargazers_url":"https://api.github.com/repos/GridPlus/safe-card/stargazers","contributors_url":"https://api.github.com/repos/GridPlus/safe-card/contributors","subscribers_url":"https://api.github.com/repos/GridPlus/safe-card/subscribers","subscription_url":"https://api.github.com/repos/GridPlus/safe-card/subscription","commits_url":"https://api.github.com/repos/GridPlus/safe-card/commits{/sha}","git_commits_url":"https://api.github.com/repos/GridPlus/safe-card/git/commits{/sha}","comments_url":"https://api.github.com/repos/GridPlus/safe-card/comments{/number}","issue_comment_url":"https://api.github.com/repos/GridPlus/safe-card/issues/comments{/number}","contents_url":"https://api.github.com/repos/GridPlus/safe-card/contents/{+path}","compare_url":"https://api.github.com/repos/GridPlus/safe-card/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GridPlus/safe-card/merges","archive_url":"https://api.github.com/repos/GridPlus/safe-card/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GridPlus/safe-card/downloads","issues_url":"https://api.github.com/repos/GridPlus/safe-card/issues{/number}","pulls_url":"https://api.github.com/repos/GridPlus/safe-card/pulls{/number}","milestones_url":"https://api.github.com/repos/GridPlus/safe-card/milestones{/number}","notifications_url":"https://api.github.com/repos/GridPlus/safe-card/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GridPlus/safe-card/labels{/name}","releases_url":"https://api.github.com/repos/GridPlus/safe-card/releases{/id}","deployments_url":"https://api.github.com/repos/GridPlus/safe-card/deployments","created_at":"2019-04-10T16:22:42Z","updated_at":"2019-09-06T21:39:05Z","pushed_at":"2019-09-11T17:42:29Z","git_url":"git://github.com/GridPlus/safe-card.git","ssh_url":"git@github.com:GridPlus/safe-card.git","clone_url":"https://github.com/GridPlus/safe-card.git","svn_url":"https://github.com/GridPlus/safe-card","homepage":"","size":688,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":8,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":8,"watchers":3,"default_branch":"master"}},"base":{"label":"GridPlus:master","ref":"master","sha":"684566c30b43d2733409c4a0f67e8547b7c29af2","user":{"login":"GridPlus","id":28931745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTMxNzQ1","avatar_url":"https://avatars3.githubusercontent.com/u/28931745?v=4","gravatar_id":"","url":"https://api.github.com/users/GridPlus","html_url":"https://github.com/GridPlus","followers_url":"https://api.github.com/users/GridPlus/followers","following_url":"https://api.github.com/users/GridPlus/following{/other_user}","gists_url":"https://api.github.com/users/GridPlus/gists{/gist_id}","starred_url":"https://api.github.com/users/GridPlus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GridPlus/subscriptions","organizations_url":"https://api.github.com/users/GridPlus/orgs","repos_url":"https://api.github.com/users/GridPlus/repos","events_url":"https://api.github.com/users/GridPlus/events{/privacy}","received_events_url":"https://api.github.com/users/GridPlus/received_events","type":"Organization","site_admin":false},"repo":{"id":180620370,"node_id":"MDEwOlJlcG9zaXRvcnkxODA2MjAzNzA=","name":"safe-card","full_name":"GridPlus/safe-card","private":false,"owner":{"login":"GridPlus","id":28931745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTMxNzQ1","avatar_url":"https://avatars3.githubusercontent.com/u/28931745?v=4","gravatar_id":"","url":"https://api.github.com/users/GridPlus","html_url":"https://github.com/GridPlus","followers_url":"https://api.github.com/users/GridPlus/followers","following_url":"https://api.github.com/users/GridPlus/following{/other_user}","gists_url":"https://api.github.com/users/GridPlus/gists{/gist_id}","starred_url":"https://api.github.com/users/GridPlus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GridPlus/subscriptions","organizations_url":"https://api.github.com/users/GridPlus/orgs","repos_url":"https://api.github.com/users/GridPlus/repos","events_url":"https://api.github.com/users/GridPlus/events{/privacy}","received_events_url":"https://api.github.com/users/GridPlus/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/GridPlus/safe-card","description":"Javacard applet for storing secrets and spending cryptocurrencies","fork":true,"url":"https://api.github.com/repos/GridPlus/safe-card","forks_url":"https://api.github.com/repos/GridPlus/safe-card/forks","keys_url":"https://api.github.com/repos/GridPlus/safe-card/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GridPlus/safe-card/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GridPlus/safe-card/teams","hooks_url":"https://api.github.com/repos/GridPlus/safe-card/hooks","issue_events_url":"https://api.github.com/repos/GridPlus/safe-card/issues/events{/number}","events_url":"https://api.github.com/repos/GridPlus/safe-card/events","assignees_url":"https://api.github.com/repos/GridPlus/safe-card/assignees{/user}","branches_url":"https://api.github.com/repos/GridPlus/safe-card/branches{/branch}","tags_url":"https://api.github.com/repos/GridPlus/safe-card/tags","blobs_url":"https://api.github.com/repos/GridPlus/safe-card/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GridPlus/safe-card/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GridPlus/safe-card/git/refs{/sha}","trees_url":"https://api.github.com/repos/GridPlus/safe-card/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GridPlus/safe-card/statuses/{sha}","languages_url":"https://api.github.com/repos/GridPlus/safe-card/languages","stargazers_url":"https://api.github.com/repos/GridPlus/safe-card/stargazers","contributors_url":"https://api.github.com/repos/GridPlus/safe-card/contributors","subscribers_url":"https://api.github.com/repos/GridPlus/safe-card/subscribers","subscription_url":"https://api.github.com/repos/GridPlus/safe-card/subscription","commits_url":"https://api.github.com/repos/GridPlus/safe-card/commits{/sha}","git_commits_url":"https://api.github.com/repos/GridPlus/safe-card/git/commits{/sha}","comments_url":"https://api.github.com/repos/GridPlus/safe-card/comments{/number}","issue_comment_url":"https://api.github.com/repos/GridPlus/safe-card/issues/comments{/number}","contents_url":"https://api.github.com/repos/GridPlus/safe-card/contents/{+path}","compare_url":"https://api.github.com/repos/GridPlus/safe-card/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GridPlus/safe-card/merges","archive_url":"https://api.github.com/repos/GridPlus/safe-card/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GridPlus/safe-card/downloads","issues_url":"https://api.github.com/repos/GridPlus/safe-card/issues{/number}","pulls_url":"https://api.github.com/repos/GridPlus/safe-card/pulls{/number}","milestones_url":"https://api.github.com/repos/GridPlus/safe-card/milestones{/number}","notifications_url":"https://api.github.com/repos/GridPlus/safe-card/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GridPlus/safe-card/labels{/name}","releases_url":"https://api.github.com/repos/GridPlus/safe-card/releases{/id}","deployments_url":"https://api.github.com/repos/GridPlus/safe-card/deployments","created_at":"2019-04-10T16:22:42Z","updated_at":"2019-09-06T21:39:05Z","pushed_at":"2019-09-11T17:42:29Z","git_url":"git://github.com/GridPlus/safe-card.git","ssh_url":"git@github.com:GridPlus/safe-card.git","clone_url":"https://github.com/GridPlus/safe-card.git","svn_url":"https://github.com/GridPlus/safe-card","homepage":"","size":688,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":8,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":8,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GridPlus/safe-card/pulls/45"},"html":{"href":"https://github.com/GridPlus/safe-card/pull/45"},"issue":{"href":"https://api.github.com/repos/GridPlus/safe-card/issues/45"},"comments":{"href":"https://api.github.com/repos/GridPlus/safe-card/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/GridPlus/safe-card/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/GridPlus/safe-card/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GridPlus/safe-card/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/GridPlus/safe-card/statuses/f6541f220d337c59056a5ac479166f98ff451600"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"phreaknik"}}