payload: {"action":"created","comment":{"url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/comments/267545101","pull_request_review_id":216980411,"id":267545101,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI2NzU0NTEwMQ==","diff_hunk":"@@ -0,0 +1,71 @@\n+#include \"apdu_hmac.h\"\n+\n+#include \"globals.h\"\n+#include \"keys.h\"\n+#include \"protocol.h\"\n+\n+\n+#define G global.u.hmac\n+\n+static inline size_t hmac(\n+    uint8_t *const out, size_t const out_size,\n+    apdu_hmac_state_t *const state,\n+    uint8_t const *const in, size_t const in_size\n+) {\n+    check_null(out);\n+    check_null(state);\n+    check_null(in);\n+    if (out_size < CX_SHA256_SIZE) THROW(EXC_WRONG_LENGTH);\n+\n+    // Pick a static, arbitrary SHA256 value based on a quote of Jesus.\n+    static uint8_t const key_sha256[] = {\n+        0x6c, 0x4e, 0x7e, 0x70, 0x6c, 0x54, 0xd3, 0x67,\n+        0xc8, 0x7a, 0x8d, 0x89, 0xc1, 0x6a, 0xdf, 0xe0,\n+        0x6c, 0xb5, 0x68, 0x0c, 0xb7, 0xd1, 0x8e, 0x62,\n+        0x5a, 0x90, 0x47, 0x5e, 0xc0, 0xdb, 0xdb, 0x9f };\n+\n+    // Deterministically sign the SHA256 value to get something directly tied to the secret key.\n+    size_t const signed_hmac_key_size = sign(\n+        state->signed_hmac_key, sizeof(state->signed_hmac_key),\n+        &state->key,\n+        key_sha256, sizeof(key_sha256));\n+\n+    // Hash the signed value with SHA512 to get a 64-byte key for HMAC.\n+    cx_hash_sha512(\n+        state->signed_hmac_key, signed_hmac_key_size,\n+        state->hashed_signed_hmac_key, sizeof(state->hashed_signed_hmac_key));\n+\n+    return cx_hmac_sha256(\n+         state->hashed_signed_hmac_key, sizeof(state->hashed_signed_hmac_key),\n+         in, in_size,\n+         out, out_size);\n+}\n+\n+size_t handle_apdu_hmac(__attribute__((unused)) uint8_t instruction) {\n+    if (READ_UNALIGNED_BIG_ENDIAN(uint8_t, &G_io_apdu_buffer[OFFSET_P1]) != 0) THROW(EXC_WRONG_PARAM);\n+\n+    uint8_t const *const buff = &G_io_apdu_buffer[OFFSET_CDATA];\n+    uint8_t const buff_size = READ_UNALIGNED_BIG_ENDIAN(uint8_t, &G_io_apdu_buffer[OFFSET_LC]);\n+    if (buff_size > MAX_APDU_SIZE) THROW(EXC_WRONG_LENGTH_FOR_INS);\n+\n+    memset(&G, 0, sizeof(__typeof__(G)));","path":"src/apdu_hmac.c","position":51,"original_position":51,"commit_id":"32210dc2549fd41a5cc82e2f8bf68a926337b0f2","original_commit_id":"32210dc2549fd41a5cc82e2f8bf68a926337b0f2","user":{"login":"3noch","id":882455,"node_id":"MDQ6VXNlcjg4MjQ1NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/882455?v=4","gravatar_id":"","url":"https://api.github.com/users/3noch","html_url":"https://github.com/3noch","followers_url":"https://api.github.com/users/3noch/followers","following_url":"https://api.github.com/users/3noch/following{/other_user}","gists_url":"https://api.github.com/users/3noch/gists{/gist_id}","starred_url":"https://api.github.com/users/3noch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3noch/subscriptions","organizations_url":"https://api.github.com/users/3noch/orgs","repos_url":"https://api.github.com/users/3noch/repos","events_url":"https://api.github.com/users/3noch/events{/privacy}","received_events_url":"https://api.github.com/users/3noch/received_events","type":"User","site_admin":false},"body":"This seems like something we should do for all APDU handlers...","created_at":"2019-03-20T21:03:12Z","updated_at":"2019-03-20T21:03:17Z","html_url":"https://github.com/obsidiansystems/ledger-app-tezos/pull/65#discussion_r267545101","pull_request_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/comments/267545101"},"html":{"href":"https://github.com/obsidiansystems/ledger-app-tezos/pull/65#discussion_r267545101"},"pull_request":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65"}}},"pull_request":{"url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65","id":262252900,"node_id":"MDExOlB1bGxSZXF1ZXN0MjYyMjUyOTAw","html_url":"https://github.com/obsidiansystems/ledger-app-tezos/pull/65","diff_url":"https://github.com/obsidiansystems/ledger-app-tezos/pull/65.diff","patch_url":"https://github.com/obsidiansystems/ledger-app-tezos/pull/65.patch","issue_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/65","number":65,"state":"open","locked":false,"title":"HMAC","user":{"login":"3noch","id":882455,"node_id":"MDQ6VXNlcjg4MjQ1NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/882455?v=4","gravatar_id":"","url":"https://api.github.com/users/3noch","html_url":"https://github.com/3noch","followers_url":"https://api.github.com/users/3noch/followers","following_url":"https://api.github.com/users/3noch/following{/other_user}","gists_url":"https://api.github.com/users/3noch/gists{/gist_id}","starred_url":"https://api.github.com/users/3noch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3noch/subscriptions","organizations_url":"https://api.github.com/users/3noch/orgs","repos_url":"https://api.github.com/users/3noch/repos","events_url":"https://api.github.com/users/3noch/events{/privacy}","received_events_url":"https://api.github.com/users/3noch/received_events","type":"User","site_admin":false},"body":"Based on #63 ","created_at":"2019-03-18T22:44:23Z","updated_at":"2019-03-20T21:03:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e90b37b459363292648b06fd480d5f88f39aa6c6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jhartzell42","id":465386,"node_id":"MDQ6VXNlcjQ2NTM4Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/465386?v=4","gravatar_id":"","url":"https://api.github.com/users/jhartzell42","html_url":"https://github.com/jhartzell42","followers_url":"https://api.github.com/users/jhartzell42/followers","following_url":"https://api.github.com/users/jhartzell42/following{/other_user}","gists_url":"https://api.github.com/users/jhartzell42/gists{/gist_id}","starred_url":"https://api.github.com/users/jhartzell42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhartzell42/subscriptions","organizations_url":"https://api.github.com/users/jhartzell42/orgs","repos_url":"https://api.github.com/users/jhartzell42/repos","events_url":"https://api.github.com/users/jhartzell42/events{/privacy}","received_events_url":"https://api.github.com/users/jhartzell42/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65/commits","review_comments_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65/comments","review_comment_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/65/comments","statuses_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/statuses/32210dc2549fd41a5cc82e2f8bf68a926337b0f2","head":{"label":"obsidiansystems:eac-hmac","ref":"eac-hmac","sha":"32210dc2549fd41a5cc82e2f8bf68a926337b0f2","user":{"login":"obsidiansystems","id":11916262,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE2MjYy","avatar_url":"https://avatars1.githubusercontent.com/u/11916262?v=4","gravatar_id":"","url":"https://api.github.com/users/obsidiansystems","html_url":"https://github.com/obsidiansystems","followers_url":"https://api.github.com/users/obsidiansystems/followers","following_url":"https://api.github.com/users/obsidiansystems/following{/other_user}","gists_url":"https://api.github.com/users/obsidiansystems/gists{/gist_id}","starred_url":"https://api.github.com/users/obsidiansystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obsidiansystems/subscriptions","organizations_url":"https://api.github.com/users/obsidiansystems/orgs","repos_url":"https://api.github.com/users/obsidiansystems/repos","events_url":"https://api.github.com/users/obsidiansystems/events{/privacy}","received_events_url":"https://api.github.com/users/obsidiansystems/received_events","type":"Organization","site_admin":false},"repo":{"id":135602726,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU2MDI3MjY=","name":"ledger-app-tezos","full_name":"obsidiansystems/ledger-app-tezos","private":false,"owner":{"login":"obsidiansystems","id":11916262,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE2MjYy","avatar_url":"https://avatars1.githubusercontent.com/u/11916262?v=4","gravatar_id":"","url":"https://api.github.com/users/obsidiansystems","html_url":"https://github.com/obsidiansystems","followers_url":"https://api.github.com/users/obsidiansystems/followers","following_url":"https://api.github.com/users/obsidiansystems/following{/other_user}","gists_url":"https://api.github.com/users/obsidiansystems/gists{/gist_id}","starred_url":"https://api.github.com/users/obsidiansystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obsidiansystems/subscriptions","organizations_url":"https://api.github.com/users/obsidiansystems/orgs","repos_url":"https://api.github.com/users/obsidiansystems/repos","events_url":"https://api.github.com/users/obsidiansystems/events{/privacy}","received_events_url":"https://api.github.com/users/obsidiansystems/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/obsidiansystems/ledger-app-tezos","description":"Ledger app for Tezos","fork":false,"url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos","forks_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/forks","keys_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/teams","hooks_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/hooks","issue_events_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/events{/number}","events_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/events","assignees_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/assignees{/user}","branches_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/branches{/branch}","tags_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/tags","blobs_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/refs{/sha}","trees_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/statuses/{sha}","languages_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/languages","stargazers_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/stargazers","contributors_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/contributors","subscribers_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/subscribers","subscription_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/subscription","commits_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/commits{/sha}","git_commits_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/commits{/sha}","comments_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/comments{/number}","issue_comment_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/comments{/number}","contents_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/contents/{+path}","compare_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/merges","archive_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/downloads","issues_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues{/number}","pulls_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls{/number}","milestones_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/milestones{/number}","notifications_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/labels{/name}","releases_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/releases{/id}","deployments_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/deployments","created_at":"2018-05-31T15:32:34Z","updated_at":"2019-03-12T15:38:44Z","pushed_at":"2019-03-20T20:56:23Z","git_url":"git://github.com/obsidiansystems/ledger-app-tezos.git","ssh_url":"git@github.com:obsidiansystems/ledger-app-tezos.git","clone_url":"https://github.com/obsidiansystems/ledger-app-tezos.git","svn_url":"https://github.com/obsidiansystems/ledger-app-tezos","homepage":null,"size":718,"stargazers_count":58,"watchers_count":58,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":12,"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":19,"open_issues":12,"watchers":58,"default_branch":"master"}},"base":{"label":"obsidiansystems:develop","ref":"develop","sha":"3352933a33fce5a9cba8feccb24613a3c130d86d","user":{"login":"obsidiansystems","id":11916262,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE2MjYy","avatar_url":"https://avatars1.githubusercontent.com/u/11916262?v=4","gravatar_id":"","url":"https://api.github.com/users/obsidiansystems","html_url":"https://github.com/obsidiansystems","followers_url":"https://api.github.com/users/obsidiansystems/followers","following_url":"https://api.github.com/users/obsidiansystems/following{/other_user}","gists_url":"https://api.github.com/users/obsidiansystems/gists{/gist_id}","starred_url":"https://api.github.com/users/obsidiansystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obsidiansystems/subscriptions","organizations_url":"https://api.github.com/users/obsidiansystems/orgs","repos_url":"https://api.github.com/users/obsidiansystems/repos","events_url":"https://api.github.com/users/obsidiansystems/events{/privacy}","received_events_url":"https://api.github.com/users/obsidiansystems/received_events","type":"Organization","site_admin":false},"repo":{"id":135602726,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU2MDI3MjY=","name":"ledger-app-tezos","full_name":"obsidiansystems/ledger-app-tezos","private":false,"owner":{"login":"obsidiansystems","id":11916262,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExOTE2MjYy","avatar_url":"https://avatars1.githubusercontent.com/u/11916262?v=4","gravatar_id":"","url":"https://api.github.com/users/obsidiansystems","html_url":"https://github.com/obsidiansystems","followers_url":"https://api.github.com/users/obsidiansystems/followers","following_url":"https://api.github.com/users/obsidiansystems/following{/other_user}","gists_url":"https://api.github.com/users/obsidiansystems/gists{/gist_id}","starred_url":"https://api.github.com/users/obsidiansystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obsidiansystems/subscriptions","organizations_url":"https://api.github.com/users/obsidiansystems/orgs","repos_url":"https://api.github.com/users/obsidiansystems/repos","events_url":"https://api.github.com/users/obsidiansystems/events{/privacy}","received_events_url":"https://api.github.com/users/obsidiansystems/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/obsidiansystems/ledger-app-tezos","description":"Ledger app for Tezos","fork":false,"url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos","forks_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/forks","keys_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/teams","hooks_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/hooks","issue_events_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/events{/number}","events_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/events","assignees_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/assignees{/user}","branches_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/branches{/branch}","tags_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/tags","blobs_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/refs{/sha}","trees_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/statuses/{sha}","languages_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/languages","stargazers_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/stargazers","contributors_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/contributors","subscribers_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/subscribers","subscription_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/subscription","commits_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/commits{/sha}","git_commits_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/git/commits{/sha}","comments_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/comments{/number}","issue_comment_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/comments{/number}","contents_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/contents/{+path}","compare_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/merges","archive_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/downloads","issues_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues{/number}","pulls_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls{/number}","milestones_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/milestones{/number}","notifications_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/labels{/name}","releases_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/releases{/id}","deployments_url":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/deployments","created_at":"2018-05-31T15:32:34Z","updated_at":"2019-03-12T15:38:44Z","pushed_at":"2019-03-20T20:56:23Z","git_url":"git://github.com/obsidiansystems/ledger-app-tezos.git","ssh_url":"git@github.com:obsidiansystems/ledger-app-tezos.git","clone_url":"https://github.com/obsidiansystems/ledger-app-tezos.git","svn_url":"https://github.com/obsidiansystems/ledger-app-tezos","homepage":null,"size":718,"stargazers_count":58,"watchers_count":58,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":12,"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":19,"open_issues":12,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65"},"html":{"href":"https://github.com/obsidiansystems/ledger-app-tezos/pull/65"},"issue":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/65"},"comments":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/issues/65/comments"},"review_comments":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65/comments"},"review_comment":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/pulls/65/commits"},"statuses":{"href":"https://api.github.com/repos/obsidiansystems/ledger-app-tezos/statuses/32210dc2549fd41a5cc82e2f8bf68a926337b0f2"}},"author_association":"MEMBER"}}
other: {"actor":{"display_login":"3noch"}}