{"action":"created","comment":{"url":"https://api.github.com/repos/open-keychain/open-keychain/pulls/comments/67706218","id":67706218,"diff_hunk":"@@ -255,26 +272,47 @@ boolean verifySignatureOnePass(Object o, OperationLog log, int indent) throws PG\n \n         // PGPOnePassSignature and PGPSignature packets are \"bracketed\",\n         // so we need to take the last-minus-index'th element here\n-        PGPSignature messageSignature = signatureList.get(signatureList.size() - 1 - signatureIndex);\n+        signature = signatureList.get(signatureList.size() - 1 - signatureIndex);\n \n-        // Verify signature\n-        boolean validSignature = onePassSignature.verify(messageSignature);\n+        verifySignatureInternal(log, indent);\n+\n+        return true;\n+    }\n+\n+    private void verifySignatureInternal(OperationLog log, int indent) throws PGPException {\n+        if (signature == null) {\n+            throw new IllegalStateException(\"signature must be set at this point!\");\n+        }\n+\n+        digest.update(signature.getSignatureTrailer());\n+\n+        PGPContentVerifierBuilder pgpContentVerifierBuilder = new JcaPGPRawDigestContentVerifierBuilderProvider()\n+                .get(signingKey.getAlgorithm(), signature.getHashAlgorithm());\n+        PGPContentVerifier pgpContentVerifier = pgpContentVerifierBuilder.build(signingKey.getPublicKey());\n+        byte[] signedMessageDigest = digest.digest();\n+\n+        try {\n+            OutputStream outputStream = pgpContentVerifier.getOutputStream();\n+            outputStream.write(signedMessageDigest);\n+        } catch (IOException e) {\n+            e.printStackTrace();","path":"OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignatureChecker.java","position":309,"original_position":309,"commit_id":"7b6d8c1234d1656a5d25314da38af01409e64716","original_commit_id":"7b6d8c1234d1656a5d25314da38af01409e64716","user":{"login":"Valodim","id":27813,"avatar_url":"https://avatars.githubusercontent.com/u/27813?v=3","gravatar_id":"","url":"https://api.github.com/users/Valodim","html_url":"https://github.com/Valodim","followers_url":"https://api.github.com/users/Valodim/followers","following_url":"https://api.github.com/users/Valodim/following{/other_user}","gists_url":"https://api.github.com/users/Valodim/gists{/gist_id}","starred_url":"https://api.github.com/users/Valodim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Valodim/subscriptions","organizations_url":"https://api.github.com/users/Valodim/orgs","repos_url":"https://api.github.com/users/Valodim/repos","events_url":"https://api.github.com/users/Valodim/events{/privacy}","received_events_url":"https://api.github.com/users/Valodim/received_events","type":"User","site_admin":false},"body":":+1:","created_at":"2016-06-20T15:06:26Z","updated_at":"2016-06-20T15:06:26Z","html_url":"https://github.com/open-keychain/open-keychain/pull/1891#discussion_r67706218","pull_request_url":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891","_links":{"self":{"href":"https://api.github.com/repos/open-keychain/open-keychain/pulls/comments/67706218"},"html":{"href":"https://github.com/open-keychain/open-keychain/pull/1891#discussion_r67706218"},"pull_request":{"href":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891"}}},"pull_request":{"url":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891","id":73991722,"html_url":"https://github.com/open-keychain/open-keychain/pull/1891","diff_url":"https://github.com/open-keychain/open-keychain/pull/1891.diff","patch_url":"https://github.com/open-keychain/open-keychain/pull/1891.patch","issue_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1891","number":1891,"state":"open","locked":false,"title":"Signature message digest","user":{"login":"Valodim","id":27813,"avatar_url":"https://avatars.githubusercontent.com/u/27813?v=3","gravatar_id":"","url":"https://api.github.com/users/Valodim","html_url":"https://github.com/Valodim","followers_url":"https://api.github.com/users/Valodim/followers","following_url":"https://api.github.com/users/Valodim/following{/other_user}","gists_url":"https://api.github.com/users/Valodim/gists{/gist_id}","starred_url":"https://api.github.com/users/Valodim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Valodim/subscriptions","organizations_url":"https://api.github.com/users/Valodim/orgs","repos_url":"https://api.github.com/users/Valodim/repos","events_url":"https://api.github.com/users/Valodim/events{/privacy}","received_events_url":"https://api.github.com/users/Valodim/received_events","type":"User","site_admin":false},"body":"This PR changes `PgpSignatureChecker` to obtain the computed message digest as an intermediate result, which is then placed in OpenPgpSignatureResult.\r\n\r\nUnfortunately, I had to work around BouncyCastle a bit more than I would have liked. Most importantly, I ended up doing the PKCS1 DER formatting for RSA signatures manually which uh, sort of sucks. It seems to be the intended way though, since there is a comment \"For raw RSA, the DigestInfo must be prepared externally\" in DigestSignatureSpi.\r\n\r\nThe point of this is that this digest can be cached, and revisited at a later point. This is helpful internally because we can \"refresh\" the key status simply by running the verification again. It also means we don't have to decrypt and verify all data again after download if we didn't have a signing key available when we first processed the data.\r\n\r\nThe same applies for client apps. Decryption delay in K-9 is a serious problem, which is why I would like to cache some of the decryption results in K-9 at some point. However, just caching the decrypted data isn't enough, and I really wouldn't feel comfortable \"caching\" the signature status, since it can change over time (due to expiry or revocation).","created_at":"2016-06-15T22:00:46Z","updated_at":"2016-06-20T15:06:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96175cd78ce0d4e690a11b78997e1a4be19951ea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891/commits","review_comments_url":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891/comments","review_comment_url":"https://api.github.com/repos/open-keychain/open-keychain/pulls/comments{/number}","comments_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/1891/comments","statuses_url":"https://api.github.com/repos/open-keychain/open-keychain/statuses/7b6d8c1234d1656a5d25314da38af01409e64716","head":{"label":"open-keychain:signatureMessageDigest","ref":"signatureMessageDigest","sha":"7b6d8c1234d1656a5d25314da38af01409e64716","user":{"login":"open-keychain","id":6513445,"avatar_url":"https://avatars.githubusercontent.com/u/6513445?v=3","gravatar_id":"","url":"https://api.github.com/users/open-keychain","html_url":"https://github.com/open-keychain","followers_url":"https://api.github.com/users/open-keychain/followers","following_url":"https://api.github.com/users/open-keychain/following{/other_user}","gists_url":"https://api.github.com/users/open-keychain/gists{/gist_id}","starred_url":"https://api.github.com/users/open-keychain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-keychain/subscriptions","organizations_url":"https://api.github.com/users/open-keychain/orgs","repos_url":"https://api.github.com/users/open-keychain/repos","events_url":"https://api.github.com/users/open-keychain/events{/privacy}","received_events_url":"https://api.github.com/users/open-keychain/received_events","type":"Organization","site_admin":false},"repo":{"id":3669065,"name":"open-keychain","full_name":"open-keychain/open-keychain","owner":{"login":"open-keychain","id":6513445,"avatar_url":"https://avatars.githubusercontent.com/u/6513445?v=3","gravatar_id":"","url":"https://api.github.com/users/open-keychain","html_url":"https://github.com/open-keychain","followers_url":"https://api.github.com/users/open-keychain/followers","following_url":"https://api.github.com/users/open-keychain/following{/other_user}","gists_url":"https://api.github.com/users/open-keychain/gists{/gist_id}","starred_url":"https://api.github.com/users/open-keychain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-keychain/subscriptions","organizations_url":"https://api.github.com/users/open-keychain/orgs","repos_url":"https://api.github.com/users/open-keychain/repos","events_url":"https://api.github.com/users/open-keychain/events{/privacy}","received_events_url":"https://api.github.com/users/open-keychain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-keychain/open-keychain","description":"OpenKeychain is an OpenPGP implementation for Android.","fork":false,"url":"https://api.github.com/repos/open-keychain/open-keychain","forks_url":"https://api.github.com/repos/open-keychain/open-keychain/forks","keys_url":"https://api.github.com/repos/open-keychain/open-keychain/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-keychain/open-keychain/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-keychain/open-keychain/teams","hooks_url":"https://api.github.com/repos/open-keychain/open-keychain/hooks","issue_events_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/events{/number}","events_url":"https://api.github.com/repos/open-keychain/open-keychain/events","assignees_url":"https://api.github.com/repos/open-keychain/open-keychain/assignees{/user}","branches_url":"https://api.github.com/repos/open-keychain/open-keychain/branches{/branch}","tags_url":"https://api.github.com/repos/open-keychain/open-keychain/tags","blobs_url":"https://api.github.com/repos/open-keychain/open-keychain/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-keychain/open-keychain/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-keychain/open-keychain/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-keychain/open-keychain/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-keychain/open-keychain/statuses/{sha}","languages_url":"https://api.github.com/repos/open-keychain/open-keychain/languages","stargazers_url":"https://api.github.com/repos/open-keychain/open-keychain/stargazers","contributors_url":"https://api.github.com/repos/open-keychain/open-keychain/contributors","subscribers_url":"https://api.github.com/repos/open-keychain/open-keychain/subscribers","subscription_url":"https://api.github.com/repos/open-keychain/open-keychain/subscription","commits_url":"https://api.github.com/repos/open-keychain/open-keychain/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-keychain/open-keychain/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-keychain/open-keychain/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-keychain/open-keychain/contents/{+path}","compare_url":"https://api.github.com/repos/open-keychain/open-keychain/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-keychain/open-keychain/merges","archive_url":"https://api.github.com/repos/open-keychain/open-keychain/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-keychain/open-keychain/downloads","issues_url":"https://api.github.com/repos/open-keychain/open-keychain/issues{/number}","pulls_url":"https://api.github.com/repos/open-keychain/open-keychain/pulls{/number}","milestones_url":"https://api.github.com/repos/open-keychain/open-keychain/milestones{/number}","notifications_url":"https://api.github.com/repos/open-keychain/open-keychain/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-keychain/open-keychain/labels{/name}","releases_url":"https://api.github.com/repos/open-keychain/open-keychain/releases{/id}","deployments_url":"https://api.github.com/repos/open-keychain/open-keychain/deployments","created_at":"2012-03-09T09:10:42Z","updated_at":"2016-06-20T05:36:30Z","pushed_at":"2016-06-20T09:37:15Z","git_url":"git://github.com/open-keychain/open-keychain.git","ssh_url":"git@github.com:open-keychain/open-keychain.git","clone_url":"https://github.com/open-keychain/open-keychain.git","svn_url":"https://github.com/open-keychain/open-keychain","homepage":"https://www.openkeychain.org","size":79150,"stargazers_count":617,"watchers_count":617,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":276,"mirror_url":null,"open_issues_count":166,"forks":276,"open_issues":166,"watchers":617,"default_branch":"master"}},"base":{"label":"open-keychain:master","ref":"master","sha":"02a5611ec999bef02e7a03e69d4719ba14b87844","user":{"login":"open-keychain","id":6513445,"avatar_url":"https://avatars.githubusercontent.com/u/6513445?v=3","gravatar_id":"","url":"https://api.github.com/users/open-keychain","html_url":"https://github.com/open-keychain","followers_url":"https://api.github.com/users/open-keychain/followers","following_url":"https://api.github.com/users/open-keychain/following{/other_user}","gists_url":"https://api.github.com/users/open-keychain/gists{/gist_id}","starred_url":"https://api.github.com/users/open-keychain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-keychain/subscriptions","organizations_url":"https://api.github.com/users/open-keychain/orgs","repos_url":"https://api.github.com/users/open-keychain/repos","events_url":"https://api.github.com/users/open-keychain/events{/privacy}","received_events_url":"https://api.github.com/users/open-keychain/received_events","type":"Organization","site_admin":false},"repo":{"id":3669065,"name":"open-keychain","full_name":"open-keychain/open-keychain","owner":{"login":"open-keychain","id":6513445,"avatar_url":"https://avatars.githubusercontent.com/u/6513445?v=3","gravatar_id":"","url":"https://api.github.com/users/open-keychain","html_url":"https://github.com/open-keychain","followers_url":"https://api.github.com/users/open-keychain/followers","following_url":"https://api.github.com/users/open-keychain/following{/other_user}","gists_url":"https://api.github.com/users/open-keychain/gists{/gist_id}","starred_url":"https://api.github.com/users/open-keychain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-keychain/subscriptions","organizations_url":"https://api.github.com/users/open-keychain/orgs","repos_url":"https://api.github.com/users/open-keychain/repos","events_url":"https://api.github.com/users/open-keychain/events{/privacy}","received_events_url":"https://api.github.com/users/open-keychain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-keychain/open-keychain","description":"OpenKeychain is an OpenPGP implementation for Android.","fork":false,"url":"https://api.github.com/repos/open-keychain/open-keychain","forks_url":"https://api.github.com/repos/open-keychain/open-keychain/forks","keys_url":"https://api.github.com/repos/open-keychain/open-keychain/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-keychain/open-keychain/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-keychain/open-keychain/teams","hooks_url":"https://api.github.com/repos/open-keychain/open-keychain/hooks","issue_events_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/events{/number}","events_url":"https://api.github.com/repos/open-keychain/open-keychain/events","assignees_url":"https://api.github.com/repos/open-keychain/open-keychain/assignees{/user}","branches_url":"https://api.github.com/repos/open-keychain/open-keychain/branches{/branch}","tags_url":"https://api.github.com/repos/open-keychain/open-keychain/tags","blobs_url":"https://api.github.com/repos/open-keychain/open-keychain/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-keychain/open-keychain/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-keychain/open-keychain/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-keychain/open-keychain/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-keychain/open-keychain/statuses/{sha}","languages_url":"https://api.github.com/repos/open-keychain/open-keychain/languages","stargazers_url":"https://api.github.com/repos/open-keychain/open-keychain/stargazers","contributors_url":"https://api.github.com/repos/open-keychain/open-keychain/contributors","subscribers_url":"https://api.github.com/repos/open-keychain/open-keychain/subscribers","subscription_url":"https://api.github.com/repos/open-keychain/open-keychain/subscription","commits_url":"https://api.github.com/repos/open-keychain/open-keychain/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-keychain/open-keychain/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-keychain/open-keychain/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-keychain/open-keychain/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-keychain/open-keychain/contents/{+path}","compare_url":"https://api.github.com/repos/open-keychain/open-keychain/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-keychain/open-keychain/merges","archive_url":"https://api.github.com/repos/open-keychain/open-keychain/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-keychain/open-keychain/downloads","issues_url":"https://api.github.com/repos/open-keychain/open-keychain/issues{/number}","pulls_url":"https://api.github.com/repos/open-keychain/open-keychain/pulls{/number}","milestones_url":"https://api.github.com/repos/open-keychain/open-keychain/milestones{/number}","notifications_url":"https://api.github.com/repos/open-keychain/open-keychain/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-keychain/open-keychain/labels{/name}","releases_url":"https://api.github.com/repos/open-keychain/open-keychain/releases{/id}","deployments_url":"https://api.github.com/repos/open-keychain/open-keychain/deployments","created_at":"2012-03-09T09:10:42Z","updated_at":"2016-06-20T05:36:30Z","pushed_at":"2016-06-20T09:37:15Z","git_url":"git://github.com/open-keychain/open-keychain.git","ssh_url":"git@github.com:open-keychain/open-keychain.git","clone_url":"https://github.com/open-keychain/open-keychain.git","svn_url":"https://github.com/open-keychain/open-keychain","homepage":"https://www.openkeychain.org","size":79150,"stargazers_count":617,"watchers_count":617,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":276,"mirror_url":null,"open_issues_count":166,"forks":276,"open_issues":166,"watchers":617,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891"},"html":{"href":"https://github.com/open-keychain/open-keychain/pull/1891"},"issue":{"href":"https://api.github.com/repos/open-keychain/open-keychain/issues/1891"},"comments":{"href":"https://api.github.com/repos/open-keychain/open-keychain/issues/1891/comments"},"review_comments":{"href":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891/comments"},"review_comment":{"href":"https://api.github.com/repos/open-keychain/open-keychain/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/open-keychain/open-keychain/pulls/1891/commits"},"statuses":{"href":"https://api.github.com/repos/open-keychain/open-keychain/statuses/7b6d8c1234d1656a5d25314da38af01409e64716"}}}}
{"actor":{"display_login":"Valodim"}}