payload: {"action":"created","comment":{"url":"https://api.github.com/repos/martindisch/aes-ccm/pulls/comments/352352608","pull_request_review_id":324946307,"id":352352608,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM1MjM1MjYwOA==","diff_hunk":"@@ -204,17 +210,18 @@ impl CcmMode {\n             ccm_cbc_mac(&mut b, associated_data, true, &self.cipher);\n         }\n         if plen > 0 {\n-            ccm_cbc_mac(&mut b, &out[..plen - self.mlen], false, &self.cipher);\n+            ccm_cbc_mac(&mut b, payload, false, &self.cipher);\n         }\n \n         // Comparing the received tag and the computed one\n-        if b[..self.mlen] != tag[..self.mlen] {\n+        use subtle::ConstantTimeEq;\n+        if b[..tlen].ct_eq(&t[..tlen]).unwrap_u8() == 0 {","path":"src/ccm.rs","position":255,"original_position":251,"commit_id":"b09d00f363ee94887ece775fe18e6a4a90659835","original_commit_id":"45bb4bcb43d7e0fcfc6e7968e0d78417e75a93e7","user":{"login":"tarcieri","id":797,"node_id":"MDQ6VXNlcjc5Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/797?v=4","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"body":"For the `subtle::ConstantTimeEq` trait specifically, I've usually seen it imported in this style, I assume with the intent of making it easier for a reviewer to see what's happening.","created_at":"2019-12-01T15:24:23Z","updated_at":"2019-12-01T15:24:23Z","html_url":"https://github.com/martindisch/aes-ccm/pull/3#discussion_r352352608","pull_request_url":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/martindisch/aes-ccm/pulls/comments/352352608"},"html":{"href":"https://github.com/martindisch/aes-ccm/pull/3#discussion_r352352608"},"pull_request":{"href":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3"}},"in_reply_to_id":352315732},"pull_request":{"url":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3","id":347253024,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQ3MjUzMDI0","html_url":"https://github.com/martindisch/aes-ccm/pull/3","diff_url":"https://github.com/martindisch/aes-ccm/pull/3.diff","patch_url":"https://github.com/martindisch/aes-ccm/pull/3.patch","issue_url":"https://api.github.com/repos/martindisch/aes-ccm/issues/3","number":3,"state":"open","locked":false,"title":"Use traits from the `aead` crate","user":{"login":"tarcieri","id":797,"node_id":"MDQ6VXNlcjc5Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/797?v=4","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"body":"Doesn't compile yet, but curious about the general direction.\r\n\r\nThe current `aead` traits heavily leverage `generic-array` and `typenum`. Are you ok with that? They're a bit awful for now, but const generics seem like they're [shaping up and may hopefully be available in 2020](https://www.reddit.com/r/rust/comments/e3sa3z/staticvec_050_seriously_this_is_whats_possible/).\r\n\r\nTo fit `mlen` into the `Aead` traits, I made it a generic parameter. It still enforces the valid set of tag sizes, but using the type system via a `TagSize` marker trait which is only impl'd for the valid sizes.\r\n\r\nNote that there are default impls of the rest of the methods of the `Aead` trait (e.g. `encrypt`, `encrypt_in_place`) which you get \"for free\" with any cipher with a postfix tag, which AES-CCM appears to be.\r\n\r\nUsing in-place encryption in heapless environments requires the `heapless` crate, but is hopefully a bit more ergonomic than the current API. See here for an example:\r\n\r\nhttps://docs.rs/chacha20poly1305/0.3.0/chacha20poly1305/#in-place-usage-eliminates-alloc-requirement\r\n\r\nFinally, it's using the upstream `aead::Error` type, which is fully opaque. I hope that's ok: we prefer it for preventing potential sidechannel leakage. Note it doesn't (yet) have an optional `impl std::error::Error` which is an oversight I'll open an upstream PR for.","created_at":"2019-11-30T19:33:12Z","updated_at":"2019-12-01T15:24:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d970d2c6e1a9cf3e37250d5ce7f8614f8da18ae3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3/commits","review_comments_url":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3/comments","review_comment_url":"https://api.github.com/repos/martindisch/aes-ccm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/martindisch/aes-ccm/issues/3/comments","statuses_url":"https://api.github.com/repos/martindisch/aes-ccm/statuses/b09d00f363ee94887ece775fe18e6a4a90659835","head":{"label":"tarcieri:aead-trait","ref":"aead-trait","sha":"b09d00f363ee94887ece775fe18e6a4a90659835","user":{"login":"tarcieri","id":797,"node_id":"MDQ6VXNlcjc5Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/797?v=4","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"repo":{"id":225048686,"node_id":"MDEwOlJlcG9zaXRvcnkyMjUwNDg2ODY=","name":"aes-ccm","full_name":"tarcieri/aes-ccm","private":false,"owner":{"login":"tarcieri","id":797,"node_id":"MDQ6VXNlcjc5Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/797?v=4","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"html_url":"https://github.com/tarcieri/aes-ccm","description":"Rust port of TinyCrypt's CCM mode implementation using RustCrypto's AES","fork":true,"url":"https://api.github.com/repos/tarcieri/aes-ccm","forks_url":"https://api.github.com/repos/tarcieri/aes-ccm/forks","keys_url":"https://api.github.com/repos/tarcieri/aes-ccm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tarcieri/aes-ccm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tarcieri/aes-ccm/teams","hooks_url":"https://api.github.com/repos/tarcieri/aes-ccm/hooks","issue_events_url":"https://api.github.com/repos/tarcieri/aes-ccm/issues/events{/number}","events_url":"https://api.github.com/repos/tarcieri/aes-ccm/events","assignees_url":"https://api.github.com/repos/tarcieri/aes-ccm/assignees{/user}","branches_url":"https://api.github.com/repos/tarcieri/aes-ccm/branches{/branch}","tags_url":"https://api.github.com/repos/tarcieri/aes-ccm/tags","blobs_url":"https://api.github.com/repos/tarcieri/aes-ccm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tarcieri/aes-ccm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tarcieri/aes-ccm/git/refs{/sha}","trees_url":"https://api.github.com/repos/tarcieri/aes-ccm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tarcieri/aes-ccm/statuses/{sha}","languages_url":"https://api.github.com/repos/tarcieri/aes-ccm/languages","stargazers_url":"https://api.github.com/repos/tarcieri/aes-ccm/stargazers","contributors_url":"https://api.github.com/repos/tarcieri/aes-ccm/contributors","subscribers_url":"https://api.github.com/repos/tarcieri/aes-ccm/subscribers","subscription_url":"https://api.github.com/repos/tarcieri/aes-ccm/subscription","commits_url":"https://api.github.com/repos/tarcieri/aes-ccm/commits{/sha}","git_commits_url":"https://api.github.com/repos/tarcieri/aes-ccm/git/commits{/sha}","comments_url":"https://api.github.com/repos/tarcieri/aes-ccm/comments{/number}","issue_comment_url":"https://api.github.com/repos/tarcieri/aes-ccm/issues/comments{/number}","contents_url":"https://api.github.com/repos/tarcieri/aes-ccm/contents/{+path}","compare_url":"https://api.github.com/repos/tarcieri/aes-ccm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tarcieri/aes-ccm/merges","archive_url":"https://api.github.com/repos/tarcieri/aes-ccm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tarcieri/aes-ccm/downloads","issues_url":"https://api.github.com/repos/tarcieri/aes-ccm/issues{/number}","pulls_url":"https://api.github.com/repos/tarcieri/aes-ccm/pulls{/number}","milestones_url":"https://api.github.com/repos/tarcieri/aes-ccm/milestones{/number}","notifications_url":"https://api.github.com/repos/tarcieri/aes-ccm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tarcieri/aes-ccm/labels{/name}","releases_url":"https://api.github.com/repos/tarcieri/aes-ccm/releases{/id}","deployments_url":"https://api.github.com/repos/tarcieri/aes-ccm/deployments","created_at":"2019-11-30T17:45:53Z","updated_at":"2019-11-30T17:45:55Z","pushed_at":"2019-12-01T13:34:56Z","git_url":"git://github.com/tarcieri/aes-ccm.git","ssh_url":"git@github.com:tarcieri/aes-ccm.git","clone_url":"https://github.com/tarcieri/aes-ccm.git","svn_url":"https://github.com/tarcieri/aes-ccm","homepage":null,"size":133,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"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":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"martindisch:master","ref":"master","sha":"d188b8e21ada9fd1924052f7d18b388cdbbbe67f","user":{"login":"martindisch","id":5547518,"node_id":"MDQ6VXNlcjU1NDc1MTg=","avatar_url":"https://avatars3.githubusercontent.com/u/5547518?v=4","gravatar_id":"","url":"https://api.github.com/users/martindisch","html_url":"https://github.com/martindisch","followers_url":"https://api.github.com/users/martindisch/followers","following_url":"https://api.github.com/users/martindisch/following{/other_user}","gists_url":"https://api.github.com/users/martindisch/gists{/gist_id}","starred_url":"https://api.github.com/users/martindisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martindisch/subscriptions","organizations_url":"https://api.github.com/users/martindisch/orgs","repos_url":"https://api.github.com/users/martindisch/repos","events_url":"https://api.github.com/users/martindisch/events{/privacy}","received_events_url":"https://api.github.com/users/martindisch/received_events","type":"User","site_admin":false},"repo":{"id":202498167,"node_id":"MDEwOlJlcG9zaXRvcnkyMDI0OTgxNjc=","name":"aes-ccm","full_name":"martindisch/aes-ccm","private":false,"owner":{"login":"martindisch","id":5547518,"node_id":"MDQ6VXNlcjU1NDc1MTg=","avatar_url":"https://avatars3.githubusercontent.com/u/5547518?v=4","gravatar_id":"","url":"https://api.github.com/users/martindisch","html_url":"https://github.com/martindisch","followers_url":"https://api.github.com/users/martindisch/followers","following_url":"https://api.github.com/users/martindisch/following{/other_user}","gists_url":"https://api.github.com/users/martindisch/gists{/gist_id}","starred_url":"https://api.github.com/users/martindisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martindisch/subscriptions","organizations_url":"https://api.github.com/users/martindisch/orgs","repos_url":"https://api.github.com/users/martindisch/repos","events_url":"https://api.github.com/users/martindisch/events{/privacy}","received_events_url":"https://api.github.com/users/martindisch/received_events","type":"User","site_admin":false},"html_url":"https://github.com/martindisch/aes-ccm","description":"Rust port of TinyCrypt's CCM mode implementation using RustCrypto's AES","fork":false,"url":"https://api.github.com/repos/martindisch/aes-ccm","forks_url":"https://api.github.com/repos/martindisch/aes-ccm/forks","keys_url":"https://api.github.com/repos/martindisch/aes-ccm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/martindisch/aes-ccm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/martindisch/aes-ccm/teams","hooks_url":"https://api.github.com/repos/martindisch/aes-ccm/hooks","issue_events_url":"https://api.github.com/repos/martindisch/aes-ccm/issues/events{/number}","events_url":"https://api.github.com/repos/martindisch/aes-ccm/events","assignees_url":"https://api.github.com/repos/martindisch/aes-ccm/assignees{/user}","branches_url":"https://api.github.com/repos/martindisch/aes-ccm/branches{/branch}","tags_url":"https://api.github.com/repos/martindisch/aes-ccm/tags","blobs_url":"https://api.github.com/repos/martindisch/aes-ccm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/martindisch/aes-ccm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/martindisch/aes-ccm/git/refs{/sha}","trees_url":"https://api.github.com/repos/martindisch/aes-ccm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/martindisch/aes-ccm/statuses/{sha}","languages_url":"https://api.github.com/repos/martindisch/aes-ccm/languages","stargazers_url":"https://api.github.com/repos/martindisch/aes-ccm/stargazers","contributors_url":"https://api.github.com/repos/martindisch/aes-ccm/contributors","subscribers_url":"https://api.github.com/repos/martindisch/aes-ccm/subscribers","subscription_url":"https://api.github.com/repos/martindisch/aes-ccm/subscription","commits_url":"https://api.github.com/repos/martindisch/aes-ccm/commits{/sha}","git_commits_url":"https://api.github.com/repos/martindisch/aes-ccm/git/commits{/sha}","comments_url":"https://api.github.com/repos/martindisch/aes-ccm/comments{/number}","issue_comment_url":"https://api.github.com/repos/martindisch/aes-ccm/issues/comments{/number}","contents_url":"https://api.github.com/repos/martindisch/aes-ccm/contents/{+path}","compare_url":"https://api.github.com/repos/martindisch/aes-ccm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/martindisch/aes-ccm/merges","archive_url":"https://api.github.com/repos/martindisch/aes-ccm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/martindisch/aes-ccm/downloads","issues_url":"https://api.github.com/repos/martindisch/aes-ccm/issues{/number}","pulls_url":"https://api.github.com/repos/martindisch/aes-ccm/pulls{/number}","milestones_url":"https://api.github.com/repos/martindisch/aes-ccm/milestones{/number}","notifications_url":"https://api.github.com/repos/martindisch/aes-ccm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/martindisch/aes-ccm/labels{/name}","releases_url":"https://api.github.com/repos/martindisch/aes-ccm/releases{/id}","deployments_url":"https://api.github.com/repos/martindisch/aes-ccm/deployments","created_at":"2019-08-15T07:51:26Z","updated_at":"2019-12-01T15:09:32Z","pushed_at":"2019-12-01T13:34:58Z","git_url":"git://github.com/martindisch/aes-ccm.git","ssh_url":"git@github.com:martindisch/aes-ccm.git","clone_url":"https://github.com/martindisch/aes-ccm.git","svn_url":"https://github.com/martindisch/aes-ccm","homepage":null,"size":113,"stargazers_count":5,"watchers_count":5,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3"},"html":{"href":"https://github.com/martindisch/aes-ccm/pull/3"},"issue":{"href":"https://api.github.com/repos/martindisch/aes-ccm/issues/3"},"comments":{"href":"https://api.github.com/repos/martindisch/aes-ccm/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/martindisch/aes-ccm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/martindisch/aes-ccm/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/martindisch/aes-ccm/statuses/b09d00f363ee94887ece775fe18e6a4a90659835"}},"author_association":"NONE"}}
other: {"actor":{"display_login":"tarcieri"}}