{"action":"created","comment":{"url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/comments/41616818","id":41616818,"diff_hunk":"@@ -64,8 +64,8 @@\n     rp.key = password;\n \n     /* do the encryption */\n-    if (p.mode === \"ccm\" && sjcl.arrayBuffer && sjcl.arrayBuffer.ccm && plaintext instanceof ArrayBuffer) {\n-      p.ct = sjcl.arrayBuffer.ccm.encrypt(prp, plaintext, p.iv, adata, p.ts);\n+    if (p.mode === \"ccm\" && sjcl.arrayBuffer && sjcl.arrayBuffer.ccm) {\n+      p.ct = sjcl.arrayBuffer.ccm.compat_encrypt(prp, plaintext, p.iv, adata, p.ts);","path":"core/convenience.js","position":7,"original_position":7,"commit_id":"a740e6ec1f9839d7a006dc19851e9fa939b9b94e","original_commit_id":"a740e6ec1f9839d7a006dc19851e9fa939b9b94e","user":{"login":"Nilos","id":1300836,"avatar_url":"https://avatars.githubusercontent.com/u/1300836?v=3","gravatar_id":"","url":"https://api.github.com/users/Nilos","html_url":"https://github.com/Nilos","followers_url":"https://api.github.com/users/Nilos/followers","following_url":"https://api.github.com/users/Nilos/following{/other_user}","gists_url":"https://api.github.com/users/Nilos/gists{/gist_id}","starred_url":"https://api.github.com/users/Nilos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nilos/subscriptions","organizations_url":"https://api.github.com/users/Nilos/orgs","repos_url":"https://api.github.com/users/Nilos/repos","events_url":"https://api.github.com/users/Nilos/events{/privacy}","received_events_url":"https://api.github.com/users/Nilos/received_events","type":"User","site_admin":false},"body":"We might want to at least give the library user the option to have sjcl.arrayBuffer enabled but still not use it in the convenience function. Maybe a params attribute?","created_at":"2015-10-09T10:26:13Z","updated_at":"2015-10-09T10:26:13Z","html_url":"https://github.com/bitwiseshiftleft/sjcl/pull/244#discussion_r41616818","pull_request_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244","_links":{"self":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/comments/41616818"},"html":{"href":"https://github.com/bitwiseshiftleft/sjcl/pull/244#discussion_r41616818"},"pull_request":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244"}}},"pull_request":{"url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244","id":47161022,"html_url":"https://github.com/bitwiseshiftleft/sjcl/pull/244","diff_url":"https://github.com/bitwiseshiftleft/sjcl/pull/244.diff","patch_url":"https://github.com/bitwiseshiftleft/sjcl/pull/244.patch","issue_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues/244","number":244,"state":"open","locked":false,"title":"ccm arraybuffer implementation fix","user":{"login":"miha-stopar","id":2494901,"avatar_url":"https://avatars.githubusercontent.com/u/2494901?v=3","gravatar_id":"","url":"https://api.github.com/users/miha-stopar","html_url":"https://github.com/miha-stopar","followers_url":"https://api.github.com/users/miha-stopar/followers","following_url":"https://api.github.com/users/miha-stopar/following{/other_user}","gists_url":"https://api.github.com/users/miha-stopar/gists{/gist_id}","starred_url":"https://api.github.com/users/miha-stopar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miha-stopar/subscriptions","organizations_url":"https://api.github.com/users/miha-stopar/orgs","repos_url":"https://api.github.com/users/miha-stopar/repos","events_url":"https://api.github.com/users/miha-stopar/events{/privacy}","received_events_url":"https://api.github.com/users/miha-stopar/received_events","type":"User","site_admin":false},"body":"There was a ccm.encrypt call in sjcl._encrypt in convenience.js:\r\n p.ct = sjcl.arrayBuffer.ccm.encrypt(prp, plaintext, p.iv, adata, p.ts);\r\n\r\nI think this is wrong for two reasons:\r\n1) ccm.compat_encrypt is meant as a drop in replacement for old (non ArrayBuffers) ccm.encrypt (and the additional conditional statement checking whether the plaintext is ArrayBuffer can be this way removed)\r\n2) ccm.encrypt returns ArrayBuffer which is not properly encoded later in sjcl.encrypt function (and leaves the ct value as an empty string) and obviously making decryption impossible\r\n\r\nI modified compat_encrypt in the way that it accepts either bitArray or ArrayBuffer (and there is an additional test with plaintext being pushed into encryption as an ArrayBuffer).\r\n\r\nAlso, two minor points: I guess checking for iv having sufficient length has been mistakenly deleted and padding_count should be defaulted to 16, not 8?\r\n\r\n","created_at":"2015-10-08T14:38:24Z","updated_at":"2015-10-09T10:26:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c3b053433e06205f26bcc20cc37765cad061a89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244/commits","review_comments_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244/comments","review_comment_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues/244/comments","statuses_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/statuses/a740e6ec1f9839d7a006dc19851e9fa939b9b94e","head":{"label":"miha-stopar:ccm_arraybuffers_fix","ref":"ccm_arraybuffers_fix","sha":"a740e6ec1f9839d7a006dc19851e9fa939b9b94e","user":{"login":"miha-stopar","id":2494901,"avatar_url":"https://avatars.githubusercontent.com/u/2494901?v=3","gravatar_id":"","url":"https://api.github.com/users/miha-stopar","html_url":"https://github.com/miha-stopar","followers_url":"https://api.github.com/users/miha-stopar/followers","following_url":"https://api.github.com/users/miha-stopar/following{/other_user}","gists_url":"https://api.github.com/users/miha-stopar/gists{/gist_id}","starred_url":"https://api.github.com/users/miha-stopar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miha-stopar/subscriptions","organizations_url":"https://api.github.com/users/miha-stopar/orgs","repos_url":"https://api.github.com/users/miha-stopar/repos","events_url":"https://api.github.com/users/miha-stopar/events{/privacy}","received_events_url":"https://api.github.com/users/miha-stopar/received_events","type":"User","site_admin":false},"repo":{"id":43140288,"name":"sjcl","full_name":"miha-stopar/sjcl","owner":{"login":"miha-stopar","id":2494901,"avatar_url":"https://avatars.githubusercontent.com/u/2494901?v=3","gravatar_id":"","url":"https://api.github.com/users/miha-stopar","html_url":"https://github.com/miha-stopar","followers_url":"https://api.github.com/users/miha-stopar/followers","following_url":"https://api.github.com/users/miha-stopar/following{/other_user}","gists_url":"https://api.github.com/users/miha-stopar/gists{/gist_id}","starred_url":"https://api.github.com/users/miha-stopar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miha-stopar/subscriptions","organizations_url":"https://api.github.com/users/miha-stopar/orgs","repos_url":"https://api.github.com/users/miha-stopar/repos","events_url":"https://api.github.com/users/miha-stopar/events{/privacy}","received_events_url":"https://api.github.com/users/miha-stopar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/miha-stopar/sjcl","description":"Stanford Javascript Crypto Library","fork":true,"url":"https://api.github.com/repos/miha-stopar/sjcl","forks_url":"https://api.github.com/repos/miha-stopar/sjcl/forks","keys_url":"https://api.github.com/repos/miha-stopar/sjcl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miha-stopar/sjcl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miha-stopar/sjcl/teams","hooks_url":"https://api.github.com/repos/miha-stopar/sjcl/hooks","issue_events_url":"https://api.github.com/repos/miha-stopar/sjcl/issues/events{/number}","events_url":"https://api.github.com/repos/miha-stopar/sjcl/events","assignees_url":"https://api.github.com/repos/miha-stopar/sjcl/assignees{/user}","branches_url":"https://api.github.com/repos/miha-stopar/sjcl/branches{/branch}","tags_url":"https://api.github.com/repos/miha-stopar/sjcl/tags","blobs_url":"https://api.github.com/repos/miha-stopar/sjcl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miha-stopar/sjcl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miha-stopar/sjcl/git/refs{/sha}","trees_url":"https://api.github.com/repos/miha-stopar/sjcl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miha-stopar/sjcl/statuses/{sha}","languages_url":"https://api.github.com/repos/miha-stopar/sjcl/languages","stargazers_url":"https://api.github.com/repos/miha-stopar/sjcl/stargazers","contributors_url":"https://api.github.com/repos/miha-stopar/sjcl/contributors","subscribers_url":"https://api.github.com/repos/miha-stopar/sjcl/subscribers","subscription_url":"https://api.github.com/repos/miha-stopar/sjcl/subscription","commits_url":"https://api.github.com/repos/miha-stopar/sjcl/commits{/sha}","git_commits_url":"https://api.github.com/repos/miha-stopar/sjcl/git/commits{/sha}","comments_url":"https://api.github.com/repos/miha-stopar/sjcl/comments{/number}","issue_comment_url":"https://api.github.com/repos/miha-stopar/sjcl/issues/comments{/number}","contents_url":"https://api.github.com/repos/miha-stopar/sjcl/contents/{+path}","compare_url":"https://api.github.com/repos/miha-stopar/sjcl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miha-stopar/sjcl/merges","archive_url":"https://api.github.com/repos/miha-stopar/sjcl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miha-stopar/sjcl/downloads","issues_url":"https://api.github.com/repos/miha-stopar/sjcl/issues{/number}","pulls_url":"https://api.github.com/repos/miha-stopar/sjcl/pulls{/number}","milestones_url":"https://api.github.com/repos/miha-stopar/sjcl/milestones{/number}","notifications_url":"https://api.github.com/repos/miha-stopar/sjcl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miha-stopar/sjcl/labels{/name}","releases_url":"https://api.github.com/repos/miha-stopar/sjcl/releases{/id}","created_at":"2015-09-25T12:40:12Z","updated_at":"2015-09-25T12:40:14Z","pushed_at":"2015-10-09T09:53:10Z","git_url":"git://github.com/miha-stopar/sjcl.git","ssh_url":"git@github.com:miha-stopar/sjcl.git","clone_url":"https://github.com/miha-stopar/sjcl.git","svn_url":"https://github.com/miha-stopar/sjcl","homepage":"http://bitwiseshiftleft.github.com/sjcl/","size":12863,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bitwiseshiftleft:master","ref":"master","sha":"23cd0dee310a339b5b40e32924f0e91cd27967c6","user":{"login":"bitwiseshiftleft","id":288092,"avatar_url":"https://avatars.githubusercontent.com/u/288092?v=3","gravatar_id":"","url":"https://api.github.com/users/bitwiseshiftleft","html_url":"https://github.com/bitwiseshiftleft","followers_url":"https://api.github.com/users/bitwiseshiftleft/followers","following_url":"https://api.github.com/users/bitwiseshiftleft/following{/other_user}","gists_url":"https://api.github.com/users/bitwiseshiftleft/gists{/gist_id}","starred_url":"https://api.github.com/users/bitwiseshiftleft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitwiseshiftleft/subscriptions","organizations_url":"https://api.github.com/users/bitwiseshiftleft/orgs","repos_url":"https://api.github.com/users/bitwiseshiftleft/repos","events_url":"https://api.github.com/users/bitwiseshiftleft/events{/privacy}","received_events_url":"https://api.github.com/users/bitwiseshiftleft/received_events","type":"User","site_admin":false},"repo":{"id":688208,"name":"sjcl","full_name":"bitwiseshiftleft/sjcl","owner":{"login":"bitwiseshiftleft","id":288092,"avatar_url":"https://avatars.githubusercontent.com/u/288092?v=3","gravatar_id":"","url":"https://api.github.com/users/bitwiseshiftleft","html_url":"https://github.com/bitwiseshiftleft","followers_url":"https://api.github.com/users/bitwiseshiftleft/followers","following_url":"https://api.github.com/users/bitwiseshiftleft/following{/other_user}","gists_url":"https://api.github.com/users/bitwiseshiftleft/gists{/gist_id}","starred_url":"https://api.github.com/users/bitwiseshiftleft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitwiseshiftleft/subscriptions","organizations_url":"https://api.github.com/users/bitwiseshiftleft/orgs","repos_url":"https://api.github.com/users/bitwiseshiftleft/repos","events_url":"https://api.github.com/users/bitwiseshiftleft/events{/privacy}","received_events_url":"https://api.github.com/users/bitwiseshiftleft/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bitwiseshiftleft/sjcl","description":"Stanford Javascript Crypto Library","fork":false,"url":"https://api.github.com/repos/bitwiseshiftleft/sjcl","forks_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/forks","keys_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/teams","hooks_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/hooks","issue_events_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues/events{/number}","events_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/events","assignees_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/assignees{/user}","branches_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/branches{/branch}","tags_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/tags","blobs_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/statuses/{sha}","languages_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/languages","stargazers_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/stargazers","contributors_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/contributors","subscribers_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/subscribers","subscription_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/subscription","commits_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/contents/{+path}","compare_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/merges","archive_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/downloads","issues_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues{/number}","pulls_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls{/number}","milestones_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/milestones{/number}","notifications_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/labels{/name}","releases_url":"https://api.github.com/repos/bitwiseshiftleft/sjcl/releases{/id}","created_at":"2010-05-26T22:12:06Z","updated_at":"2015-10-08T18:20:47Z","pushed_at":"2015-10-09T09:53:12Z","git_url":"git://github.com/bitwiseshiftleft/sjcl.git","ssh_url":"git@github.com:bitwiseshiftleft/sjcl.git","clone_url":"https://github.com/bitwiseshiftleft/sjcl.git","svn_url":"https://github.com/bitwiseshiftleft/sjcl","homepage":"http://bitwiseshiftleft.github.com/sjcl/","size":21306,"stargazers_count":2925,"watchers_count":2925,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":373,"mirror_url":null,"open_issues_count":56,"forks":373,"open_issues":56,"watchers":2925,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244"},"html":{"href":"https://github.com/bitwiseshiftleft/sjcl/pull/244"},"issue":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues/244"},"comments":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/issues/244/comments"},"review_comments":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244/comments"},"review_comment":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/pulls/244/commits"},"statuses":{"href":"https://api.github.com/repos/bitwiseshiftleft/sjcl/statuses/a740e6ec1f9839d7a006dc19851e9fa939b9b94e"}}}}