{"action":"opened","number":161,"pull_request":{"url":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/161","id":47416441,"html_url":"https://github.com/opendnssec/SoftHSMv2/pull/161","diff_url":"https://github.com/opendnssec/SoftHSMv2/pull/161.diff","patch_url":"https://github.com/opendnssec/SoftHSMv2/pull/161.patch","issue_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues/161","number":161,"state":"open","locked":false,"title":"softhsm2-migrate: add empty attributes for RSA values missing in SoftHSMv1","user":{"login":"kempniu","id":1301146,"avatar_url":"https://avatars.githubusercontent.com/u/1301146?v=3","gravatar_id":"","url":"https://api.github.com/users/kempniu","html_url":"https://github.com/kempniu","followers_url":"https://api.github.com/users/kempniu/followers","following_url":"https://api.github.com/users/kempniu/following{/other_user}","gists_url":"https://api.github.com/users/kempniu/gists{/gist_id}","starred_url":"https://api.github.com/users/kempniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kempniu/subscriptions","organizations_url":"https://api.github.com/users/kempniu/orgs","repos_url":"https://api.github.com/users/kempniu/repos","events_url":"https://api.github.com/users/kempniu/events{/privacy}","received_events_url":"https://api.github.com/users/kempniu/received_events","type":"User","site_admin":false},"body":"While both OpenSSL and Botan are happy with an RSA private key being created without *exponent1*, *exponent2* and *coefficient*, SoftHSMv2 [isn't](https://github.com/opendnssec/SoftHSMv2/blob/3b087c730920040301478a2e8d58ad6e9eb7f2a0/src/lib/SoftHSM.cpp#L9639). Here is an excerpt from OpenDNSSEC 1.4.8.2 logs when trying to sign a zone using a PKCS#11 slot migrated from SoftHSMv1 to SoftHSMv2 using current `softhsm2-migrate`:\r\n\r\n    SecureDataManager.cpp(359): Invalid IV in encrypted data\r\n    [hsm] sign init: CKR_GENERAL_ERROR\r\n    [hsm] error signing rrset with libhsm\r\n    [rrset] unable to sign RRset[6]: lhsm_sign() failed\r\n    [worker[1]] sign zone example.com failed: 1 RRsets failed\r\n    [worker[1]] CRITICAL: failed to sign zone example.com: General error\r\n    [worker[1]] backoff task [sign] for zone example.com with 60 seconds\r\n\r\nThis is expected, as the `CKA_EXPONENT_1`, `CKA_EXPONENT_2` and `CKA_COEFFICIENT` attributes are [not created](https://github.com/opendnssec/SoftHSMv2/blob/a7b85cd6eaa00fbbddcd8503836303ade81f88cc/src/bin/migrate/softhsm2-migrate.cpp#L683) in the destination object by `softhsm2-migrate`. This in turn causes `SoftHSM::getRSAPrivateKey()` to return `CKR_GENERAL_ERROR` when trying to fetch an RSA private key migrated in this manner.\r\n\r\nIf `dbRSAPriv2session()` is modified to create the missing attributes with empty values, SoftHSMv2 seems to be happy again. Am I missing something here? Because frankly speaking, I don't see how `softhsm2-migrate` is supposed to work without this change. That being said, everything written above is coming from someone whose knowledge about crypto is pretty vague. I also haven't tested this change with any PKCS#11 provider other than `libsofthsm2.so`.\r\n\r\nIt looks like @letoams also came across this issue [a while ago](http://lists.opendnssec.org/pipermail/opendnssec-user/2014-August/003072.html).\r\n","created_at":"2015-10-12T12:56:46Z","updated_at":"2015-10-12T12:56:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/161/commits","review_comments_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/161/comments","review_comment_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues/161/comments","statuses_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/statuses/931cbf0c55d0599d5508bc0de1c87ee69d916c97","head":{"label":"kempniu:migrate-missing-rsa-values","ref":"migrate-missing-rsa-values","sha":"931cbf0c55d0599d5508bc0de1c87ee69d916c97","user":{"login":"kempniu","id":1301146,"avatar_url":"https://avatars.githubusercontent.com/u/1301146?v=3","gravatar_id":"","url":"https://api.github.com/users/kempniu","html_url":"https://github.com/kempniu","followers_url":"https://api.github.com/users/kempniu/followers","following_url":"https://api.github.com/users/kempniu/following{/other_user}","gists_url":"https://api.github.com/users/kempniu/gists{/gist_id}","starred_url":"https://api.github.com/users/kempniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kempniu/subscriptions","organizations_url":"https://api.github.com/users/kempniu/orgs","repos_url":"https://api.github.com/users/kempniu/repos","events_url":"https://api.github.com/users/kempniu/events{/privacy}","received_events_url":"https://api.github.com/users/kempniu/received_events","type":"User","site_admin":false},"repo":{"id":44105080,"name":"SoftHSMv2","full_name":"kempniu/SoftHSMv2","owner":{"login":"kempniu","id":1301146,"avatar_url":"https://avatars.githubusercontent.com/u/1301146?v=3","gravatar_id":"","url":"https://api.github.com/users/kempniu","html_url":"https://github.com/kempniu","followers_url":"https://api.github.com/users/kempniu/followers","following_url":"https://api.github.com/users/kempniu/following{/other_user}","gists_url":"https://api.github.com/users/kempniu/gists{/gist_id}","starred_url":"https://api.github.com/users/kempniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kempniu/subscriptions","organizations_url":"https://api.github.com/users/kempniu/orgs","repos_url":"https://api.github.com/users/kempniu/repos","events_url":"https://api.github.com/users/kempniu/events{/privacy}","received_events_url":"https://api.github.com/users/kempniu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kempniu/SoftHSMv2","description":"SoftHSM version 2","fork":true,"url":"https://api.github.com/repos/kempniu/SoftHSMv2","forks_url":"https://api.github.com/repos/kempniu/SoftHSMv2/forks","keys_url":"https://api.github.com/repos/kempniu/SoftHSMv2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kempniu/SoftHSMv2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kempniu/SoftHSMv2/teams","hooks_url":"https://api.github.com/repos/kempniu/SoftHSMv2/hooks","issue_events_url":"https://api.github.com/repos/kempniu/SoftHSMv2/issues/events{/number}","events_url":"https://api.github.com/repos/kempniu/SoftHSMv2/events","assignees_url":"https://api.github.com/repos/kempniu/SoftHSMv2/assignees{/user}","branches_url":"https://api.github.com/repos/kempniu/SoftHSMv2/branches{/branch}","tags_url":"https://api.github.com/repos/kempniu/SoftHSMv2/tags","blobs_url":"https://api.github.com/repos/kempniu/SoftHSMv2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kempniu/SoftHSMv2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kempniu/SoftHSMv2/git/refs{/sha}","trees_url":"https://api.github.com/repos/kempniu/SoftHSMv2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kempniu/SoftHSMv2/statuses/{sha}","languages_url":"https://api.github.com/repos/kempniu/SoftHSMv2/languages","stargazers_url":"https://api.github.com/repos/kempniu/SoftHSMv2/stargazers","contributors_url":"https://api.github.com/repos/kempniu/SoftHSMv2/contributors","subscribers_url":"https://api.github.com/repos/kempniu/SoftHSMv2/subscribers","subscription_url":"https://api.github.com/repos/kempniu/SoftHSMv2/subscription","commits_url":"https://api.github.com/repos/kempniu/SoftHSMv2/commits{/sha}","git_commits_url":"https://api.github.com/repos/kempniu/SoftHSMv2/git/commits{/sha}","comments_url":"https://api.github.com/repos/kempniu/SoftHSMv2/comments{/number}","issue_comment_url":"https://api.github.com/repos/kempniu/SoftHSMv2/issues/comments{/number}","contents_url":"https://api.github.com/repos/kempniu/SoftHSMv2/contents/{+path}","compare_url":"https://api.github.com/repos/kempniu/SoftHSMv2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kempniu/SoftHSMv2/merges","archive_url":"https://api.github.com/repos/kempniu/SoftHSMv2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kempniu/SoftHSMv2/downloads","issues_url":"https://api.github.com/repos/kempniu/SoftHSMv2/issues{/number}","pulls_url":"https://api.github.com/repos/kempniu/SoftHSMv2/pulls{/number}","milestones_url":"https://api.github.com/repos/kempniu/SoftHSMv2/milestones{/number}","notifications_url":"https://api.github.com/repos/kempniu/SoftHSMv2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kempniu/SoftHSMv2/labels{/name}","releases_url":"https://api.github.com/repos/kempniu/SoftHSMv2/releases{/id}","created_at":"2015-10-12T12:09:39Z","updated_at":"2015-10-12T12:09:43Z","pushed_at":"2015-10-12T12:23:34Z","git_url":"git://github.com/kempniu/SoftHSMv2.git","ssh_url":"git@github.com:kempniu/SoftHSMv2.git","clone_url":"https://github.com/kempniu/SoftHSMv2.git","svn_url":"https://github.com/kempniu/SoftHSMv2","homepage":"http://www.softhsm.org/","size":4437,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"develop"}},"base":{"label":"opendnssec:develop","ref":"develop","sha":"5ed0707bd73eb7bf7d3c42cf267c63bd17122e28","user":{"login":"opendnssec","id":3379363,"avatar_url":"https://avatars.githubusercontent.com/u/3379363?v=3","gravatar_id":"","url":"https://api.github.com/users/opendnssec","html_url":"https://github.com/opendnssec","followers_url":"https://api.github.com/users/opendnssec/followers","following_url":"https://api.github.com/users/opendnssec/following{/other_user}","gists_url":"https://api.github.com/users/opendnssec/gists{/gist_id}","starred_url":"https://api.github.com/users/opendnssec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendnssec/subscriptions","organizations_url":"https://api.github.com/users/opendnssec/orgs","repos_url":"https://api.github.com/users/opendnssec/repos","events_url":"https://api.github.com/users/opendnssec/events{/privacy}","received_events_url":"https://api.github.com/users/opendnssec/received_events","type":"Organization","site_admin":false},"repo":{"id":10314787,"name":"SoftHSMv2","full_name":"opendnssec/SoftHSMv2","owner":{"login":"opendnssec","id":3379363,"avatar_url":"https://avatars.githubusercontent.com/u/3379363?v=3","gravatar_id":"","url":"https://api.github.com/users/opendnssec","html_url":"https://github.com/opendnssec","followers_url":"https://api.github.com/users/opendnssec/followers","following_url":"https://api.github.com/users/opendnssec/following{/other_user}","gists_url":"https://api.github.com/users/opendnssec/gists{/gist_id}","starred_url":"https://api.github.com/users/opendnssec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendnssec/subscriptions","organizations_url":"https://api.github.com/users/opendnssec/orgs","repos_url":"https://api.github.com/users/opendnssec/repos","events_url":"https://api.github.com/users/opendnssec/events{/privacy}","received_events_url":"https://api.github.com/users/opendnssec/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opendnssec/SoftHSMv2","description":"SoftHSM version 2","fork":false,"url":"https://api.github.com/repos/opendnssec/SoftHSMv2","forks_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/forks","keys_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/teams","hooks_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/hooks","issue_events_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues/events{/number}","events_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/events","assignees_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/assignees{/user}","branches_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/branches{/branch}","tags_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/tags","blobs_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/git/refs{/sha}","trees_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/statuses/{sha}","languages_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/languages","stargazers_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/stargazers","contributors_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/contributors","subscribers_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/subscribers","subscription_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/subscription","commits_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/commits{/sha}","git_commits_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/git/commits{/sha}","comments_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/comments{/number}","issue_comment_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues/comments{/number}","contents_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/contents/{+path}","compare_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/merges","archive_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/downloads","issues_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues{/number}","pulls_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls{/number}","milestones_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/milestones{/number}","notifications_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/labels{/name}","releases_url":"https://api.github.com/repos/opendnssec/SoftHSMv2/releases{/id}","created_at":"2013-05-27T12:54:47Z","updated_at":"2015-10-12T03:33:03Z","pushed_at":"2015-10-08T07:03:26Z","git_url":"git://github.com/opendnssec/SoftHSMv2.git","ssh_url":"git@github.com:opendnssec/SoftHSMv2.git","clone_url":"https://github.com/opendnssec/SoftHSMv2.git","svn_url":"https://github.com/opendnssec/SoftHSMv2","homepage":"http://www.softhsm.org/","size":4437,"stargazers_count":47,"watchers_count":47,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":24,"forks":27,"open_issues":24,"watchers":47,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/161"},"html":{"href":"https://github.com/opendnssec/SoftHSMv2/pull/161"},"issue":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues/161"},"comments":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/issues/161/comments"},"review_comments":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/161/comments"},"review_comment":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/pulls/161/commits"},"statuses":{"href":"https://api.github.com/repos/opendnssec/SoftHSMv2/statuses/931cbf0c55d0599d5508bc0de1c87ee69d916c97"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":7,"deletions":7,"changed_files":1}}