{"action":"created","comment":{"url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/comments/168148763","pull_request_review_id":96429514,"id":168148763,"diff_hunk":"@@ -323,3 +323,194 @@ exit:\n     mbedtls_pk_free( &transparent_ctx );\n }\n /* END_CASE */\n+\n+/* BEGIN_CASE depends_on:MBEDTLS_PK_C:MBEDTLS_SHA256_C */\n+void pk_signX_verifyX( int key_type )\n+{\n+    /* Sign with cryptoki, convert to mbedTLS format and save, \n+       verify by cryptoki with a conversion to a raw, concatenated\n+       format by the engine. */\n+    mbedtls_pk_context pkcs11_ctx;\n+    mbedtls_pk_context transparent_ctx;\n+    CK_SESSION_HANDLE hSession = CK_INVALID_HANDLE;\n+    CK_OBJECT_HANDLE hPublicKey = CK_INVALID_HANDLE;\n+    CK_OBJECT_HANDLE hPrivateKey = CK_INVALID_HANDLE;\n+    unsigned char hash_value[32] = \"Fake hash, it doesn't matter....\";\n+    unsigned char sig_buffer[RSA_KEY_SIZE_BYTES];\n+    size_t sig_length = sizeof( sig_buffer );\n+\n+    mbedtls_pk_init( &pkcs11_ctx );\n+    mbedtls_pk_init( &transparent_ctx );\n+\n+    /* Initialize cryptoki and generate a key in the token */\n+    hSession = pkcs11_init( );\n+    TEST_ASSERT( hSession != CK_INVALID_HANDLE );\n+\n+    CK_ASSERT( pkcs11_generate_key( key_type,\n+                                    hSession,\n+                                    &hPublicKey, &hPrivateKey ) );\n+    TEST_ASSERT( hPublicKey != CK_INVALID_HANDLE );\n+    TEST_ASSERT( hPrivateKey != CK_INVALID_HANDLE );\n+\n+    /* Prepare the mbed TLS contexts */\n+    TEST_ASSERT( mbedtls_pk_setup( &transparent_ctx,\n+                                   mbedtls_pk_info_from_type( key_type ) ) == 0 );\n+    TEST_ASSERT( mbedtls_pk_setup_pkcs11( &pkcs11_ctx,\n+                                          hSession,\n+                                          hPublicKey,\n+                                          hPrivateKey ) == 0 );\n+\n+    /* Retrieve the public key from the token */\n+    switch( key_type )\n+    {\n+#if defined(MBEDTLS_RSA_C)\n+    case MBEDTLS_PK_RSA:\n+        {\n+            unsigned char n_buffer[RSA_KEY_SIZE_BYTES];\n+            unsigned char e_buffer[RSA_KEY_SIZE_BYTES];\n+            CK_ATTRIBUTE public_attributes[] = {\n+                {CKA_MODULUS, n_buffer, sizeof( n_buffer )},\n+                {CKA_PUBLIC_EXPONENT, e_buffer, sizeof( e_buffer )},\n+            };\n+            CK_ULONG *n_length = &public_attributes[0].ulValueLen;\n+            CK_ULONG *e_length = &public_attributes[1].ulValueLen;\n+            mbedtls_rsa_context *rsa_ctx = mbedtls_pk_rsa( transparent_ctx );\n+\n+            CK_ASSERT( C_GetAttributeValue( hSession, hPublicKey,\n+                                            public_attributes, ARRAY_LENGTH( public_attributes ) ) );\n+            TEST_ASSERT( mbedtls_mpi_read_binary( &rsa_ctx->N,\n+                                                  n_buffer, *n_length ) == 0 );\n+            TEST_ASSERT( mbedtls_mpi_read_binary( &rsa_ctx->E,\n+                                                  e_buffer, *e_length ) == 0 );\n+            rsa_ctx->len = mbedtls_mpi_size( &rsa_ctx->N );\n+        }\n+        break;\n+#endif /* MBEDTLS_RSA_C */\n+\n+#if defined(MBEDTLS_ECDSA_C)\n+    case MBEDTLS_PK_ECDSA:\n+        {\n+            unsigned char ecParams[16];\n+            unsigned char ecPoint[128];","path":"tests/suites/test_suite_pkcs11_client.function","position":205,"original_position":72,"commit_id":"cc6294c12e495589608760728f887d656fe55ace","original_commit_id":"c289bf1a308bf7d0e4abfdfff860774ba85d7969","user":{"login":"mpg","id":60640,"avatar_url":"https://avatars0.githubusercontent.com/u/60640?v=4","gravatar_id":"","url":"https://api.github.com/users/mpg","html_url":"https://github.com/mpg","followers_url":"https://api.github.com/users/mpg/followers","following_url":"https://api.github.com/users/mpg/following{/other_user}","gists_url":"https://api.github.com/users/mpg/gists{/gist_id}","starred_url":"https://api.github.com/users/mpg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpg/subscriptions","organizations_url":"https://api.github.com/users/mpg/orgs","repos_url":"https://api.github.com/users/mpg/repos","events_url":"https://api.github.com/users/mpg/events{/privacy}","received_events_url":"https://api.github.com/users/mpg/received_events","type":"User","site_admin":false},"body":"Same here, even if the curve used for testing is currently always P-256, it doesn't hurt to use something based on `MBEDTLS_ECP_MAX_BYTES` here instead of `128`.","created_at":"2018-02-14T11:38:54Z","updated_at":"2018-02-14T12:00:55Z","html_url":"https://github.com/ARMmbed/mbedtls/pull/1300#discussion_r168148763","pull_request_url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/comments/168148763"},"html":{"href":"https://github.com/ARMmbed/mbedtls/pull/1300#discussion_r168148763"},"pull_request":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300"}}},"pull_request":{"url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300","id":164568233,"html_url":"https://github.com/ARMmbed/mbedtls/pull/1300","diff_url":"https://github.com/ARMmbed/mbedtls/pull/1300.diff","patch_url":"https://github.com/ARMmbed/mbedtls/pull/1300.patch","issue_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/1300","number":1300,"state":"open","locked":false,"title":"Opaque keys - ecdsa sign & verify implementation","user":{"login":"AndrzejKurek","id":29195988,"avatar_url":"https://avatars0.githubusercontent.com/u/29195988?v=4","gravatar_id":"","url":"https://api.github.com/users/AndrzejKurek","html_url":"https://github.com/AndrzejKurek","followers_url":"https://api.github.com/users/AndrzejKurek/followers","following_url":"https://api.github.com/users/AndrzejKurek/following{/other_user}","gists_url":"https://api.github.com/users/AndrzejKurek/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrzejKurek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrzejKurek/subscriptions","organizations_url":"https://api.github.com/users/AndrzejKurek/orgs","repos_url":"https://api.github.com/users/AndrzejKurek/repos","events_url":"https://api.github.com/users/AndrzejKurek/events{/privacy}","received_events_url":"https://api.github.com/users/AndrzejKurek/received_events","type":"User","site_admin":false},"body":"PKCS11 client implementation with ECDSA signing and verification\r\n\r\nObjectives:\r\nImplement an engine for opaque keys using softHSM2, and testing it on ECDSA signing & verification.\r\nAdd tests for various cases - internal/external/hardcoded signature, internal/external verification.\r\n\r\nIn order to test it, softHSM2 has to be installed and initialized by calling:\r\nexport SOFTHSM2_CONF=/path_to_mbedtls/mbedtls/tests/softhsm2.conf\r\ncd tests && scripts/pkcs11-client-test.sh init\r\n\r\nMbedTLS has to be built with:\r\nCFLAGS=\"-I/usr/include/softhsm/\" LDFLAGS=\"-L/usr/lib/softhsm -lsofthsm2\" make check\r\n\r\nReviewers, please focus only on changes from \"[New module: pkcs11_client](https://github.com/ARMmbed/mbedtls/pull/1300/commits/c53dee302d94c4efc78dfcd7cda23c9e617d9ad3)\" (c53dee3) onwards, as this pull request is based on ARMmbed#1293","created_at":"2018-01-23T12:55:23Z","updated_at":"2018-02-14T12:00:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2482439e2659d33e94665c1e83898410ca6cd20a","assignee":null,"assignees":[],"requested_reviewers":[{"login":"yanesca","id":6871045,"avatar_url":"https://avatars1.githubusercontent.com/u/6871045?v=4","gravatar_id":"","url":"https://api.github.com/users/yanesca","html_url":"https://github.com/yanesca","followers_url":"https://api.github.com/users/yanesca/followers","following_url":"https://api.github.com/users/yanesca/following{/other_user}","gists_url":"https://api.github.com/users/yanesca/gists{/gist_id}","starred_url":"https://api.github.com/users/yanesca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanesca/subscriptions","organizations_url":"https://api.github.com/users/yanesca/orgs","repos_url":"https://api.github.com/users/yanesca/repos","events_url":"https://api.github.com/users/yanesca/events{/privacy}","received_events_url":"https://api.github.com/users/yanesca/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":19280386,"url":"https://api.github.com/repos/ARMmbed/mbedtls/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":408190313,"url":"https://api.github.com/repos/ARMmbed/mbedtls/labels/mbed%20TLS%20team","name":"mbed TLS team","color":"66e0ff","default":false},{"id":705358813,"url":"https://api.github.com/repos/ARMmbed/mbedtls/labels/needs%20review","name":"needs review","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300/commits","review_comments_url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300/comments","review_comment_url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/1300/comments","statuses_url":"https://api.github.com/repos/ARMmbed/mbedtls/statuses/cc6294c12e495589608760728f887d656fe55ace","head":{"label":"ARMmbed:feature-opaque-keys-ECDSA","ref":"feature-opaque-keys-ECDSA","sha":"cc6294c12e495589608760728f887d656fe55ace","user":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars3.githubusercontent.com/u/8916057?v=4","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"repo":{"id":6687936,"name":"mbedtls","full_name":"ARMmbed/mbedtls","owner":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars3.githubusercontent.com/u/8916057?v=4","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARMmbed/mbedtls","description":"An open source, portable, easy to use, readable and flexible SSL library","fork":false,"url":"https://api.github.com/repos/ARMmbed/mbedtls","forks_url":"https://api.github.com/repos/ARMmbed/mbedtls/forks","keys_url":"https://api.github.com/repos/ARMmbed/mbedtls/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARMmbed/mbedtls/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARMmbed/mbedtls/teams","hooks_url":"https://api.github.com/repos/ARMmbed/mbedtls/hooks","issue_events_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/events{/number}","events_url":"https://api.github.com/repos/ARMmbed/mbedtls/events","assignees_url":"https://api.github.com/repos/ARMmbed/mbedtls/assignees{/user}","branches_url":"https://api.github.com/repos/ARMmbed/mbedtls/branches{/branch}","tags_url":"https://api.github.com/repos/ARMmbed/mbedtls/tags","blobs_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARMmbed/mbedtls/statuses/{sha}","languages_url":"https://api.github.com/repos/ARMmbed/mbedtls/languages","stargazers_url":"https://api.github.com/repos/ARMmbed/mbedtls/stargazers","contributors_url":"https://api.github.com/repos/ARMmbed/mbedtls/contributors","subscribers_url":"https://api.github.com/repos/ARMmbed/mbedtls/subscribers","subscription_url":"https://api.github.com/repos/ARMmbed/mbedtls/subscription","commits_url":"https://api.github.com/repos/ARMmbed/mbedtls/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARMmbed/mbedtls/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARMmbed/mbedtls/contents/{+path}","compare_url":"https://api.github.com/repos/ARMmbed/mbedtls/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARMmbed/mbedtls/merges","archive_url":"https://api.github.com/repos/ARMmbed/mbedtls/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARMmbed/mbedtls/downloads","issues_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues{/number}","pulls_url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls{/number}","milestones_url":"https://api.github.com/repos/ARMmbed/mbedtls/milestones{/number}","notifications_url":"https://api.github.com/repos/ARMmbed/mbedtls/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARMmbed/mbedtls/labels{/name}","releases_url":"https://api.github.com/repos/ARMmbed/mbedtls/releases{/id}","deployments_url":"https://api.github.com/repos/ARMmbed/mbedtls/deployments","created_at":"2012-11-14T13:13:13Z","updated_at":"2018-02-13T12:15:11Z","pushed_at":"2018-02-14T10:43:11Z","git_url":"git://github.com/ARMmbed/mbedtls.git","ssh_url":"git@github.com:ARMmbed/mbedtls.git","clone_url":"https://github.com/ARMmbed/mbedtls.git","svn_url":"https://github.com/ARMmbed/mbedtls","homepage":"https://tls.mbed.org","size":24308,"stargazers_count":1258,"watchers_count":1258,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":772,"mirror_url":null,"archived":false,"open_issues_count":433,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":772,"open_issues":433,"watchers":1258,"default_branch":"development"}},"base":{"label":"ARMmbed:feature-opaque-keys","ref":"feature-opaque-keys","sha":"297d7535fb7f325507a4c35104f11000c613bbc4","user":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars3.githubusercontent.com/u/8916057?v=4","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"repo":{"id":6687936,"name":"mbedtls","full_name":"ARMmbed/mbedtls","owner":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars3.githubusercontent.com/u/8916057?v=4","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARMmbed/mbedtls","description":"An open source, portable, easy to use, readable and flexible SSL library","fork":false,"url":"https://api.github.com/repos/ARMmbed/mbedtls","forks_url":"https://api.github.com/repos/ARMmbed/mbedtls/forks","keys_url":"https://api.github.com/repos/ARMmbed/mbedtls/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARMmbed/mbedtls/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARMmbed/mbedtls/teams","hooks_url":"https://api.github.com/repos/ARMmbed/mbedtls/hooks","issue_events_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/events{/number}","events_url":"https://api.github.com/repos/ARMmbed/mbedtls/events","assignees_url":"https://api.github.com/repos/ARMmbed/mbedtls/assignees{/user}","branches_url":"https://api.github.com/repos/ARMmbed/mbedtls/branches{/branch}","tags_url":"https://api.github.com/repos/ARMmbed/mbedtls/tags","blobs_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARMmbed/mbedtls/statuses/{sha}","languages_url":"https://api.github.com/repos/ARMmbed/mbedtls/languages","stargazers_url":"https://api.github.com/repos/ARMmbed/mbedtls/stargazers","contributors_url":"https://api.github.com/repos/ARMmbed/mbedtls/contributors","subscribers_url":"https://api.github.com/repos/ARMmbed/mbedtls/subscribers","subscription_url":"https://api.github.com/repos/ARMmbed/mbedtls/subscription","commits_url":"https://api.github.com/repos/ARMmbed/mbedtls/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARMmbed/mbedtls/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARMmbed/mbedtls/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARMmbed/mbedtls/contents/{+path}","compare_url":"https://api.github.com/repos/ARMmbed/mbedtls/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARMmbed/mbedtls/merges","archive_url":"https://api.github.com/repos/ARMmbed/mbedtls/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARMmbed/mbedtls/downloads","issues_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues{/number}","pulls_url":"https://api.github.com/repos/ARMmbed/mbedtls/pulls{/number}","milestones_url":"https://api.github.com/repos/ARMmbed/mbedtls/milestones{/number}","notifications_url":"https://api.github.com/repos/ARMmbed/mbedtls/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARMmbed/mbedtls/labels{/name}","releases_url":"https://api.github.com/repos/ARMmbed/mbedtls/releases{/id}","deployments_url":"https://api.github.com/repos/ARMmbed/mbedtls/deployments","created_at":"2012-11-14T13:13:13Z","updated_at":"2018-02-13T12:15:11Z","pushed_at":"2018-02-14T10:43:11Z","git_url":"git://github.com/ARMmbed/mbedtls.git","ssh_url":"git@github.com:ARMmbed/mbedtls.git","clone_url":"https://github.com/ARMmbed/mbedtls.git","svn_url":"https://github.com/ARMmbed/mbedtls","homepage":"https://tls.mbed.org","size":24308,"stargazers_count":1258,"watchers_count":1258,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":772,"mirror_url":null,"archived":false,"open_issues_count":433,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":772,"open_issues":433,"watchers":1258,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300"},"html":{"href":"https://github.com/ARMmbed/mbedtls/pull/1300"},"issue":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/issues/1300"},"comments":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/issues/1300/comments"},"review_comments":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300/comments"},"review_comment":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/pulls/1300/commits"},"statuses":{"href":"https://api.github.com/repos/ARMmbed/mbedtls/statuses/cc6294c12e495589608760728f887d656fe55ace"}},"author_association":"NONE"}}
{"actor":{"display_login":"mpg"}}