{"action":"created","comment":{"url":"https://api.github.com/repos/pyca/cryptography/pulls/comments/40366268","id":40366268,"diff_hunk":"@@ -0,0 +1,120 @@\n+# This file is dual licensed under the terms of the Apache License, Version\n+# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n+# for complete details.\n+\n+from __future__ import absolute_import, division, print_function\n+\n+import binascii\n+\n+import pytest\n+\n+from cryptography.exceptions import (\n+    AlreadyFinalized, InvalidKey, _Reasons\n+)\n+from cryptography.hazmat.backends.interfaces import HashBackend\n+from cryptography.hazmat.primitives import hashes\n+from cryptography.hazmat.primitives.kdf.x963kdf import X963KDF\n+\n+from ...utils import raises_unsupported_algorithm\n+\n+\n+@pytest.mark.requires_backend_interface(interface=HashBackend)\n+class TestX963KDF(object):\n+    def test_length_limit(self, backend):\n+        big_length = hashes.SHA256().digest_size * (2 ** 32 - 1) + 1\n+\n+        with pytest.raises(ValueError):\n+            X963KDF(hashes.SHA256(), big_length, None, backend)\n+\n+    def test_already_finalized(self, backend):\n+        ckdf = X963KDF(hashes.SHA256(), 16, None, backend)\n+\n+        ckdf.derive(b\"\\x01\" * 16)\n+\n+        with pytest.raises(AlreadyFinalized):\n+            ckdf.derive(b\"\\x02\" * 16)\n+\n+    def test_derive(self, backend):\n+        prk = binascii.unhexlify(\n+            b\"96c05619d56c328ab95fe84b18264b08725b85e33fd34f08\"\n+        )\n+\n+        okm = binascii.unhexlify(b\"443024c3dae66b95e6f5670601558f71\")\n+\n+        ckdf = X963KDF(hashes.SHA256(), 16, None, backend)\n+\n+        assert ckdf.derive(prk) == okm\n+\n+    def test_verify(self, backend):\n+        prk = binascii.unhexlify(","path":"tests/hazmat/primitives/test_x963kdf.py","position":49,"original_position":49,"commit_id":"23608114b654ec53f9ad723c39aaa80803c9ce67","original_commit_id":"23608114b654ec53f9ad723c39aaa80803c9ce67","user":{"login":"simo5","id":8332609,"avatar_url":"https://avatars.githubusercontent.com/u/8332609?v=3","gravatar_id":"","url":"https://api.github.com/users/simo5","html_url":"https://github.com/simo5","followers_url":"https://api.github.com/users/simo5/followers","following_url":"https://api.github.com/users/simo5/following{/other_user}","gists_url":"https://api.github.com/users/simo5/gists{/gist_id}","starred_url":"https://api.github.com/users/simo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simo5/subscriptions","organizations_url":"https://api.github.com/users/simo5/orgs","repos_url":"https://api.github.com/users/simo5/repos","events_url":"https://api.github.com/users/simo5/events{/privacy}","received_events_url":"https://api.github.com/users/simo5/received_events","type":"User","site_admin":false},"body":"It's the same definitions as used in ConcatKDF's CAVS files I guess.\r\nI can change them to use z and key_data if you prefer","created_at":"2015-09-24T20:09:42Z","updated_at":"2015-09-24T20:09:42Z","html_url":"https://github.com/pyca/cryptography/pull/2343#discussion_r40366268","pull_request_url":"https://api.github.com/repos/pyca/cryptography/pulls/2343","_links":{"self":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/comments/40366268"},"html":{"href":"https://github.com/pyca/cryptography/pull/2343#discussion_r40366268"},"pull_request":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/2343"}}},"pull_request":{"url":"https://api.github.com/repos/pyca/cryptography/pulls/2343","id":45065120,"html_url":"https://github.com/pyca/cryptography/pull/2343","diff_url":"https://github.com/pyca/cryptography/pull/2343.diff","patch_url":"https://github.com/pyca/cryptography/pull/2343.patch","issue_url":"https://api.github.com/repos/pyca/cryptography/issues/2343","number":2343,"state":"open","locked":false,"title":"Implement ANSI X9.63 KDF","user":{"login":"simo5","id":8332609,"avatar_url":"https://avatars.githubusercontent.com/u/8332609?v=3","gravatar_id":"","url":"https://api.github.com/users/simo5","html_url":"https://github.com/simo5","followers_url":"https://api.github.com/users/simo5/followers","following_url":"https://api.github.com/users/simo5/following{/other_user}","gists_url":"https://api.github.com/users/simo5/gists{/gist_id}","starred_url":"https://api.github.com/users/simo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simo5/subscriptions","organizations_url":"https://api.github.com/users/simo5/orgs","repos_url":"https://api.github.com/users/simo5/repos","events_url":"https://api.github.com/users/simo5/events{/privacy}","received_events_url":"https://api.github.com/users/simo5/received_events","type":"User","site_admin":false},"body":"Add ANSI X9.63 KDf function as it is needed for Let's encrypt.\r\nThis function is just a minor variation of ConcatKDFHash, but different enough that we need a separate name/implementation.","created_at":"2015-09-15T15:37:11Z","updated_at":"2015-09-24T20:09:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f48ec073f6a59616483016ca4d00b36a2f448792","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pyca/cryptography/pulls/2343/commits","review_comments_url":"https://api.github.com/repos/pyca/cryptography/pulls/2343/comments","review_comment_url":"https://api.github.com/repos/pyca/cryptography/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyca/cryptography/issues/2343/comments","statuses_url":"https://api.github.com/repos/pyca/cryptography/statuses/23608114b654ec53f9ad723c39aaa80803c9ce67","head":{"label":"simo5:ANS_X963","ref":"ANS_X963","sha":"23608114b654ec53f9ad723c39aaa80803c9ce67","user":{"login":"simo5","id":8332609,"avatar_url":"https://avatars.githubusercontent.com/u/8332609?v=3","gravatar_id":"","url":"https://api.github.com/users/simo5","html_url":"https://github.com/simo5","followers_url":"https://api.github.com/users/simo5/followers","following_url":"https://api.github.com/users/simo5/following{/other_user}","gists_url":"https://api.github.com/users/simo5/gists{/gist_id}","starred_url":"https://api.github.com/users/simo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simo5/subscriptions","organizations_url":"https://api.github.com/users/simo5/orgs","repos_url":"https://api.github.com/users/simo5/repos","events_url":"https://api.github.com/users/simo5/events{/privacy}","received_events_url":"https://api.github.com/users/simo5/received_events","type":"User","site_admin":false},"repo":{"id":34753046,"name":"cryptography","full_name":"simo5/cryptography","owner":{"login":"simo5","id":8332609,"avatar_url":"https://avatars.githubusercontent.com/u/8332609?v=3","gravatar_id":"","url":"https://api.github.com/users/simo5","html_url":"https://github.com/simo5","followers_url":"https://api.github.com/users/simo5/followers","following_url":"https://api.github.com/users/simo5/following{/other_user}","gists_url":"https://api.github.com/users/simo5/gists{/gist_id}","starred_url":"https://api.github.com/users/simo5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simo5/subscriptions","organizations_url":"https://api.github.com/users/simo5/orgs","repos_url":"https://api.github.com/users/simo5/repos","events_url":"https://api.github.com/users/simo5/events{/privacy}","received_events_url":"https://api.github.com/users/simo5/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/simo5/cryptography","description":"cryptography is a package designed to expose cryptographic primitives and recipes to Python developers.","fork":true,"url":"https://api.github.com/repos/simo5/cryptography","forks_url":"https://api.github.com/repos/simo5/cryptography/forks","keys_url":"https://api.github.com/repos/simo5/cryptography/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simo5/cryptography/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simo5/cryptography/teams","hooks_url":"https://api.github.com/repos/simo5/cryptography/hooks","issue_events_url":"https://api.github.com/repos/simo5/cryptography/issues/events{/number}","events_url":"https://api.github.com/repos/simo5/cryptography/events","assignees_url":"https://api.github.com/repos/simo5/cryptography/assignees{/user}","branches_url":"https://api.github.com/repos/simo5/cryptography/branches{/branch}","tags_url":"https://api.github.com/repos/simo5/cryptography/tags","blobs_url":"https://api.github.com/repos/simo5/cryptography/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simo5/cryptography/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simo5/cryptography/git/refs{/sha}","trees_url":"https://api.github.com/repos/simo5/cryptography/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simo5/cryptography/statuses/{sha}","languages_url":"https://api.github.com/repos/simo5/cryptography/languages","stargazers_url":"https://api.github.com/repos/simo5/cryptography/stargazers","contributors_url":"https://api.github.com/repos/simo5/cryptography/contributors","subscribers_url":"https://api.github.com/repos/simo5/cryptography/subscribers","subscription_url":"https://api.github.com/repos/simo5/cryptography/subscription","commits_url":"https://api.github.com/repos/simo5/cryptography/commits{/sha}","git_commits_url":"https://api.github.com/repos/simo5/cryptography/git/commits{/sha}","comments_url":"https://api.github.com/repos/simo5/cryptography/comments{/number}","issue_comment_url":"https://api.github.com/repos/simo5/cryptography/issues/comments{/number}","contents_url":"https://api.github.com/repos/simo5/cryptography/contents/{+path}","compare_url":"https://api.github.com/repos/simo5/cryptography/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simo5/cryptography/merges","archive_url":"https://api.github.com/repos/simo5/cryptography/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simo5/cryptography/downloads","issues_url":"https://api.github.com/repos/simo5/cryptography/issues{/number}","pulls_url":"https://api.github.com/repos/simo5/cryptography/pulls{/number}","milestones_url":"https://api.github.com/repos/simo5/cryptography/milestones{/number}","notifications_url":"https://api.github.com/repos/simo5/cryptography/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simo5/cryptography/labels{/name}","releases_url":"https://api.github.com/repos/simo5/cryptography/releases{/id}","created_at":"2015-04-28T20:04:21Z","updated_at":"2015-04-28T20:04:28Z","pushed_at":"2015-09-23T19:22:07Z","git_url":"git://github.com/simo5/cryptography.git","ssh_url":"git@github.com:simo5/cryptography.git","clone_url":"https://github.com/simo5/cryptography.git","svn_url":"https://github.com/simo5/cryptography","homepage":"https://cryptography.io/","size":31083,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pyca:master","ref":"master","sha":"b99a359f1b855037af581379c35ae32b89bc25fa","user":{"login":"pyca","id":5615737,"avatar_url":"https://avatars.githubusercontent.com/u/5615737?v=3","gravatar_id":"","url":"https://api.github.com/users/pyca","html_url":"https://github.com/pyca","followers_url":"https://api.github.com/users/pyca/followers","following_url":"https://api.github.com/users/pyca/following{/other_user}","gists_url":"https://api.github.com/users/pyca/gists{/gist_id}","starred_url":"https://api.github.com/users/pyca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyca/subscriptions","organizations_url":"https://api.github.com/users/pyca/orgs","repos_url":"https://api.github.com/users/pyca/repos","events_url":"https://api.github.com/users/pyca/events{/privacy}","received_events_url":"https://api.github.com/users/pyca/received_events","type":"Organization","site_admin":false},"repo":{"id":11939484,"name":"cryptography","full_name":"pyca/cryptography","owner":{"login":"pyca","id":5615737,"avatar_url":"https://avatars.githubusercontent.com/u/5615737?v=3","gravatar_id":"","url":"https://api.github.com/users/pyca","html_url":"https://github.com/pyca","followers_url":"https://api.github.com/users/pyca/followers","following_url":"https://api.github.com/users/pyca/following{/other_user}","gists_url":"https://api.github.com/users/pyca/gists{/gist_id}","starred_url":"https://api.github.com/users/pyca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyca/subscriptions","organizations_url":"https://api.github.com/users/pyca/orgs","repos_url":"https://api.github.com/users/pyca/repos","events_url":"https://api.github.com/users/pyca/events{/privacy}","received_events_url":"https://api.github.com/users/pyca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pyca/cryptography","description":"cryptography is a package designed to expose cryptographic primitives and recipes to Python developers.","fork":false,"url":"https://api.github.com/repos/pyca/cryptography","forks_url":"https://api.github.com/repos/pyca/cryptography/forks","keys_url":"https://api.github.com/repos/pyca/cryptography/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyca/cryptography/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyca/cryptography/teams","hooks_url":"https://api.github.com/repos/pyca/cryptography/hooks","issue_events_url":"https://api.github.com/repos/pyca/cryptography/issues/events{/number}","events_url":"https://api.github.com/repos/pyca/cryptography/events","assignees_url":"https://api.github.com/repos/pyca/cryptography/assignees{/user}","branches_url":"https://api.github.com/repos/pyca/cryptography/branches{/branch}","tags_url":"https://api.github.com/repos/pyca/cryptography/tags","blobs_url":"https://api.github.com/repos/pyca/cryptography/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyca/cryptography/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyca/cryptography/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyca/cryptography/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyca/cryptography/statuses/{sha}","languages_url":"https://api.github.com/repos/pyca/cryptography/languages","stargazers_url":"https://api.github.com/repos/pyca/cryptography/stargazers","contributors_url":"https://api.github.com/repos/pyca/cryptography/contributors","subscribers_url":"https://api.github.com/repos/pyca/cryptography/subscribers","subscription_url":"https://api.github.com/repos/pyca/cryptography/subscription","commits_url":"https://api.github.com/repos/pyca/cryptography/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyca/cryptography/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyca/cryptography/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyca/cryptography/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyca/cryptography/contents/{+path}","compare_url":"https://api.github.com/repos/pyca/cryptography/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyca/cryptography/merges","archive_url":"https://api.github.com/repos/pyca/cryptography/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyca/cryptography/downloads","issues_url":"https://api.github.com/repos/pyca/cryptography/issues{/number}","pulls_url":"https://api.github.com/repos/pyca/cryptography/pulls{/number}","milestones_url":"https://api.github.com/repos/pyca/cryptography/milestones{/number}","notifications_url":"https://api.github.com/repos/pyca/cryptography/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyca/cryptography/labels{/name}","releases_url":"https://api.github.com/repos/pyca/cryptography/releases{/id}","created_at":"2013-08-07T02:23:38Z","updated_at":"2015-09-24T09:19:52Z","pushed_at":"2015-09-23T19:22:08Z","git_url":"git://github.com/pyca/cryptography.git","ssh_url":"git@github.com:pyca/cryptography.git","clone_url":"https://github.com/pyca/cryptography.git","svn_url":"https://github.com/pyca/cryptography","homepage":"https://cryptography.io/","size":45576,"stargazers_count":817,"watchers_count":817,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":194,"mirror_url":null,"open_issues_count":94,"forks":194,"open_issues":94,"watchers":817,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/2343"},"html":{"href":"https://github.com/pyca/cryptography/pull/2343"},"issue":{"href":"https://api.github.com/repos/pyca/cryptography/issues/2343"},"comments":{"href":"https://api.github.com/repos/pyca/cryptography/issues/2343/comments"},"review_comments":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/2343/comments"},"review_comment":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/2343/commits"},"statuses":{"href":"https://api.github.com/repos/pyca/cryptography/statuses/23608114b654ec53f9ad723c39aaa80803c9ce67"}}}}