{"action":"created","comment":{"url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/comments/63278382","id":63278382,"diff_hunk":"@@ -0,0 +1,70 @@\n+package gpg\n+\n+import (\n+\t\"bytes\"\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"io\"\n+\n+\t\"golang.org/x/crypto/openpgp\"\n+)\n+\n+// GPG contains the data necessary to perform our cryptographical actions.\n+type GPG struct {\n+\tserverEntity *openpgp.Entity\n+}\n+\n+// NewGPG initializes a GPG object from a buffer containing the server's private key.\n+func NewGPG(r io.Reader, passphrase string) (*GPG, error) {\n+\tbuffer := new(bytes.Buffer)\n+\t_, err := buffer.ReadFrom(r)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tgpg := new(GPG)\n+\tfor _, armored := range []bool{false, true} {\n+\t\tgpg.serverEntity, err = ReadEntity(bytes.NewReader([]byte(buffer.String())), armored)\n+\t\tif err == nil {\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\terr = DecryptPrivateKeys(gpg.serverEntity, []byte(passphrase))\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\treturn gpg, nil\n+}\n+\n+// SignUserID signs an armored public key read from r as validated to correspond to the given email and writes the signed public key to w.\n+func (gpg *GPG) SignUserID(signedEMail string, r io.Reader, w io.Writer) error {\n+\tclientEntity, err := ReadEntity(r, true)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tsignedIdentity := \"\"\n+\tfor _, identity := range clientEntity.Identities {\n+\t\tif identity.UserId.Email == signedEMail {\n+\t\t\tsignedIdentity = identity.Name\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\n+\tif signedIdentity == \"\" {\n+\t\treturn errors.New(fmt.Sprint(\"Could find\", signedEMail, \"in identities of client key\"))","path":"gpg/gpg.go","position":60,"original_position":60,"commit_id":"9f3c0cdd9bd4e2f544e47ae0bd89a78ae951b1e7","original_commit_id":"9f3c0cdd9bd4e2f544e47ae0bd89a78ae951b1e7","user":{"login":"JohannesEbke","id":355473,"avatar_url":"https://avatars.githubusercontent.com/u/355473?v=3","gravatar_id":"","url":"https://api.github.com/users/JohannesEbke","html_url":"https://github.com/JohannesEbke","followers_url":"https://api.github.com/users/JohannesEbke/followers","following_url":"https://api.github.com/users/JohannesEbke/following{/other_user}","gists_url":"https://api.github.com/users/JohannesEbke/gists{/gist_id}","starred_url":"https://api.github.com/users/JohannesEbke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohannesEbke/subscriptions","organizations_url":"https://api.github.com/users/JohannesEbke/orgs","repos_url":"https://api.github.com/users/JohannesEbke/repos","events_url":"https://api.github.com/users/JohannesEbke/events{/privacy}","received_events_url":"https://api.github.com/users/JohannesEbke/received_events","type":"User","site_admin":false},"body":"Could not find?","created_at":"2016-05-14T16:21:21Z","updated_at":"2016-05-14T16:21:21Z","html_url":"https://github.com/TNG/gpg-validation-server/pull/3#discussion_r63278382","pull_request_url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/comments/63278382"},"html":{"href":"https://github.com/TNG/gpg-validation-server/pull/3#discussion_r63278382"},"pull_request":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3","id":69993689,"html_url":"https://github.com/TNG/gpg-validation-server/pull/3","diff_url":"https://github.com/TNG/gpg-validation-server/pull/3.diff","patch_url":"https://github.com/TNG/gpg-validation-server/pull/3.patch","issue_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues/3","number":3,"state":"open","locked":false,"title":"Add rudimentary GPG functionality","user":{"login":"v-maurer","id":18613288,"avatar_url":"https://avatars.githubusercontent.com/u/18613288?v=3","gravatar_id":"","url":"https://api.github.com/users/v-maurer","html_url":"https://github.com/v-maurer","followers_url":"https://api.github.com/users/v-maurer/followers","following_url":"https://api.github.com/users/v-maurer/following{/other_user}","gists_url":"https://api.github.com/users/v-maurer/gists{/gist_id}","starred_url":"https://api.github.com/users/v-maurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/v-maurer/subscriptions","organizations_url":"https://api.github.com/users/v-maurer/orgs","repos_url":"https://api.github.com/users/v-maurer/repos","events_url":"https://api.github.com/users/v-maurer/events{/privacy}","received_events_url":"https://api.github.com/users/v-maurer/received_events","type":"User","site_admin":false},"body":"Addresses issue #5 \r\nIncludes functions to:\r\n- read openpgp.Entity from io.Reader\r\n- decrypt private keys of openpgp.Entity\r\n- sign public key of one Entity with private key of another and export as armored ascii string","created_at":"2016-05-13T13:14:28Z","updated_at":"2016-05-14T16:21:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9399d89ad313597640872abd7a58a79c20d55f47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3/commits","review_comments_url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3/comments","review_comment_url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues/3/comments","statuses_url":"https://api.github.com/repos/TNG/gpg-validation-server/statuses/9f3c0cdd9bd4e2f544e47ae0bd89a78ae951b1e7","head":{"label":"TNG:gpgsigning","ref":"gpgsigning","sha":"9f3c0cdd9bd4e2f544e47ae0bd89a78ae951b1e7","user":{"login":"TNG","id":432256,"avatar_url":"https://avatars.githubusercontent.com/u/432256?v=3","gravatar_id":"","url":"https://api.github.com/users/TNG","html_url":"https://github.com/TNG","followers_url":"https://api.github.com/users/TNG/followers","following_url":"https://api.github.com/users/TNG/following{/other_user}","gists_url":"https://api.github.com/users/TNG/gists{/gist_id}","starred_url":"https://api.github.com/users/TNG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TNG/subscriptions","organizations_url":"https://api.github.com/users/TNG/orgs","repos_url":"https://api.github.com/users/TNG/repos","events_url":"https://api.github.com/users/TNG/events{/privacy}","received_events_url":"https://api.github.com/users/TNG/received_events","type":"Organization","site_admin":false},"repo":{"id":58740241,"name":"gpg-validation-server","full_name":"TNG/gpg-validation-server","owner":{"login":"TNG","id":432256,"avatar_url":"https://avatars.githubusercontent.com/u/432256?v=3","gravatar_id":"","url":"https://api.github.com/users/TNG","html_url":"https://github.com/TNG","followers_url":"https://api.github.com/users/TNG/followers","following_url":"https://api.github.com/users/TNG/following{/other_user}","gists_url":"https://api.github.com/users/TNG/gists{/gist_id}","starred_url":"https://api.github.com/users/TNG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TNG/subscriptions","organizations_url":"https://api.github.com/users/TNG/orgs","repos_url":"https://api.github.com/users/TNG/repos","events_url":"https://api.github.com/users/TNG/events{/privacy}","received_events_url":"https://api.github.com/users/TNG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TNG/gpg-validation-server","description":"Automatically Validate GPG Keys","fork":false,"url":"https://api.github.com/repos/TNG/gpg-validation-server","forks_url":"https://api.github.com/repos/TNG/gpg-validation-server/forks","keys_url":"https://api.github.com/repos/TNG/gpg-validation-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TNG/gpg-validation-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TNG/gpg-validation-server/teams","hooks_url":"https://api.github.com/repos/TNG/gpg-validation-server/hooks","issue_events_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues/events{/number}","events_url":"https://api.github.com/repos/TNG/gpg-validation-server/events","assignees_url":"https://api.github.com/repos/TNG/gpg-validation-server/assignees{/user}","branches_url":"https://api.github.com/repos/TNG/gpg-validation-server/branches{/branch}","tags_url":"https://api.github.com/repos/TNG/gpg-validation-server/tags","blobs_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TNG/gpg-validation-server/statuses/{sha}","languages_url":"https://api.github.com/repos/TNG/gpg-validation-server/languages","stargazers_url":"https://api.github.com/repos/TNG/gpg-validation-server/stargazers","contributors_url":"https://api.github.com/repos/TNG/gpg-validation-server/contributors","subscribers_url":"https://api.github.com/repos/TNG/gpg-validation-server/subscribers","subscription_url":"https://api.github.com/repos/TNG/gpg-validation-server/subscription","commits_url":"https://api.github.com/repos/TNG/gpg-validation-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/TNG/gpg-validation-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/TNG/gpg-validation-server/contents/{+path}","compare_url":"https://api.github.com/repos/TNG/gpg-validation-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TNG/gpg-validation-server/merges","archive_url":"https://api.github.com/repos/TNG/gpg-validation-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TNG/gpg-validation-server/downloads","issues_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues{/number}","pulls_url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls{/number}","milestones_url":"https://api.github.com/repos/TNG/gpg-validation-server/milestones{/number}","notifications_url":"https://api.github.com/repos/TNG/gpg-validation-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TNG/gpg-validation-server/labels{/name}","releases_url":"https://api.github.com/repos/TNG/gpg-validation-server/releases{/id}","deployments_url":"https://api.github.com/repos/TNG/gpg-validation-server/deployments","created_at":"2016-05-13T12:52:03Z","updated_at":"2016-05-13T13:00:29Z","pushed_at":"2016-05-14T16:15:13Z","git_url":"git://github.com/TNG/gpg-validation-server.git","ssh_url":"git@github.com:TNG/gpg-validation-server.git","clone_url":"https://github.com/TNG/gpg-validation-server.git","svn_url":"https://github.com/TNG/gpg-validation-server","homepage":null,"size":81,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"TNG:master","ref":"master","sha":"78ab23f3a08736d19af4da0af3ae14d671df40c1","user":{"login":"TNG","id":432256,"avatar_url":"https://avatars.githubusercontent.com/u/432256?v=3","gravatar_id":"","url":"https://api.github.com/users/TNG","html_url":"https://github.com/TNG","followers_url":"https://api.github.com/users/TNG/followers","following_url":"https://api.github.com/users/TNG/following{/other_user}","gists_url":"https://api.github.com/users/TNG/gists{/gist_id}","starred_url":"https://api.github.com/users/TNG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TNG/subscriptions","organizations_url":"https://api.github.com/users/TNG/orgs","repos_url":"https://api.github.com/users/TNG/repos","events_url":"https://api.github.com/users/TNG/events{/privacy}","received_events_url":"https://api.github.com/users/TNG/received_events","type":"Organization","site_admin":false},"repo":{"id":58740241,"name":"gpg-validation-server","full_name":"TNG/gpg-validation-server","owner":{"login":"TNG","id":432256,"avatar_url":"https://avatars.githubusercontent.com/u/432256?v=3","gravatar_id":"","url":"https://api.github.com/users/TNG","html_url":"https://github.com/TNG","followers_url":"https://api.github.com/users/TNG/followers","following_url":"https://api.github.com/users/TNG/following{/other_user}","gists_url":"https://api.github.com/users/TNG/gists{/gist_id}","starred_url":"https://api.github.com/users/TNG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TNG/subscriptions","organizations_url":"https://api.github.com/users/TNG/orgs","repos_url":"https://api.github.com/users/TNG/repos","events_url":"https://api.github.com/users/TNG/events{/privacy}","received_events_url":"https://api.github.com/users/TNG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TNG/gpg-validation-server","description":"Automatically Validate GPG Keys","fork":false,"url":"https://api.github.com/repos/TNG/gpg-validation-server","forks_url":"https://api.github.com/repos/TNG/gpg-validation-server/forks","keys_url":"https://api.github.com/repos/TNG/gpg-validation-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TNG/gpg-validation-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TNG/gpg-validation-server/teams","hooks_url":"https://api.github.com/repos/TNG/gpg-validation-server/hooks","issue_events_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues/events{/number}","events_url":"https://api.github.com/repos/TNG/gpg-validation-server/events","assignees_url":"https://api.github.com/repos/TNG/gpg-validation-server/assignees{/user}","branches_url":"https://api.github.com/repos/TNG/gpg-validation-server/branches{/branch}","tags_url":"https://api.github.com/repos/TNG/gpg-validation-server/tags","blobs_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TNG/gpg-validation-server/statuses/{sha}","languages_url":"https://api.github.com/repos/TNG/gpg-validation-server/languages","stargazers_url":"https://api.github.com/repos/TNG/gpg-validation-server/stargazers","contributors_url":"https://api.github.com/repos/TNG/gpg-validation-server/contributors","subscribers_url":"https://api.github.com/repos/TNG/gpg-validation-server/subscribers","subscription_url":"https://api.github.com/repos/TNG/gpg-validation-server/subscription","commits_url":"https://api.github.com/repos/TNG/gpg-validation-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/TNG/gpg-validation-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/TNG/gpg-validation-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/TNG/gpg-validation-server/contents/{+path}","compare_url":"https://api.github.com/repos/TNG/gpg-validation-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TNG/gpg-validation-server/merges","archive_url":"https://api.github.com/repos/TNG/gpg-validation-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TNG/gpg-validation-server/downloads","issues_url":"https://api.github.com/repos/TNG/gpg-validation-server/issues{/number}","pulls_url":"https://api.github.com/repos/TNG/gpg-validation-server/pulls{/number}","milestones_url":"https://api.github.com/repos/TNG/gpg-validation-server/milestones{/number}","notifications_url":"https://api.github.com/repos/TNG/gpg-validation-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TNG/gpg-validation-server/labels{/name}","releases_url":"https://api.github.com/repos/TNG/gpg-validation-server/releases{/id}","deployments_url":"https://api.github.com/repos/TNG/gpg-validation-server/deployments","created_at":"2016-05-13T12:52:03Z","updated_at":"2016-05-13T13:00:29Z","pushed_at":"2016-05-14T16:15:13Z","git_url":"git://github.com/TNG/gpg-validation-server.git","ssh_url":"git@github.com:TNG/gpg-validation-server.git","clone_url":"https://github.com/TNG/gpg-validation-server.git","svn_url":"https://github.com/TNG/gpg-validation-server","homepage":null,"size":81,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3"},"html":{"href":"https://github.com/TNG/gpg-validation-server/pull/3"},"issue":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/issues/3"},"comments":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/TNG/gpg-validation-server/statuses/9f3c0cdd9bd4e2f544e47ae0bd89a78ae951b1e7"}}}}