{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/2009","repository_url":"https://api.github.com/repos/ARMmbed/mbedtls","labels_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/2009/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/2009/comments","events_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/2009/events","html_url":"https://github.com/ARMmbed/mbedtls/issues/2009","id":357807421,"node_id":"MDU6SXNzdWUzNTc4MDc0MjE=","number":2009,"title":"Potential Bug in Configuration when MBEDTLS_ECDSA_SIGN_ALT is enabled","user":{"login":"umanayana","id":34135197,"node_id":"MDQ6VXNlcjM0MTM1MTk3","avatar_url":"https://avatars1.githubusercontent.com/u/34135197?v=4","gravatar_id":"","url":"https://api.github.com/users/umanayana","html_url":"https://github.com/umanayana","followers_url":"https://api.github.com/users/umanayana/followers","following_url":"https://api.github.com/users/umanayana/following{/other_user}","gists_url":"https://api.github.com/users/umanayana/gists{/gist_id}","starred_url":"https://api.github.com/users/umanayana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umanayana/subscriptions","organizations_url":"https://api.github.com/users/umanayana/orgs","repos_url":"https://api.github.com/users/umanayana/repos","events_url":"https://api.github.com/users/umanayana/events{/privacy}","received_events_url":"https://api.github.com/users/umanayana/received_events","type":"User","site_admin":false},"labels":[{"id":19280388,"node_id":"MDU6TGFiZWwxOTI4MDM4OA==","url":"https://api.github.com/repos/ARMmbed/mbedtls/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-09-06T20:08:44Z","updated_at":"2018-09-18T16:17:33Z","closed_at":"2018-09-18T16:17:33Z","author_association":"NONE","body":"Hi, \r\nI am adding a custom ECDSA signature process thus I enable the configuration flag `MBEDTLS_ECDSA_SIGN_ALT`.\r\n\r\nWhen I do this the method `mbedtls_ecdsa_sign()` is removed. I then write code which setups my own `mbedtls_pk_context` with custom callback to signing method and so on.\r\n\r\nWhat I've noticed is the method `mbedtls_ecdsa_write_signature()` calls `mbedtls_ecdsa_sign()`. This `mbedtls_ecdsa_write_signature()` would never be called and should be disabled in some manner.\r\nIt never gets called because  `mbedtls_pk_context::pk_info` actually points to a custom `pk_info` which uses a custom `sign_func` method.\r\n\r\nI've added the following to `mbedtls_ecdsa_write_signature()` method.\r\n\r\n```\r\n#if defined(MBEDTLS_ECDSA_DETERMINISTIC)\r\n    (void) f_rng;\r\n    (void) p_rng;\r\n\r\n    MBEDTLS_MPI_CHK( mbedtls_ecdsa_sign_det( &ctx->grp, &r, &s, &ctx->d,\r\n                             hash, hlen, md_alg ) );\r\n#elif !defined(MBEDTLS_ECDSA_SIGN_ALT)\r\n    (void) md_alg;\r\n\r\n    MBEDTLS_MPI_CHK( mbedtls_ecdsa_sign( &ctx->grp, &r, &s, &ctx->d,\r\n                         hash, hlen, f_rng, p_rng ) );\r\n#else\r\n    ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;\r\n    goto cleanup;\r\n#endif\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/comments/422456990","html_url":"https://github.com/ARMmbed/mbedtls/issues/2009#issuecomment-422456990","issue_url":"https://api.github.com/repos/ARMmbed/mbedtls/issues/2009","id":422456990,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjQ1Njk5MA==","user":{"login":"hanno-arm","id":26892988,"node_id":"MDQ6VXNlcjI2ODkyOTg4","avatar_url":"https://avatars1.githubusercontent.com/u/26892988?v=4","gravatar_id":"","url":"https://api.github.com/users/hanno-arm","html_url":"https://github.com/hanno-arm","followers_url":"https://api.github.com/users/hanno-arm/followers","following_url":"https://api.github.com/users/hanno-arm/following{/other_user}","gists_url":"https://api.github.com/users/hanno-arm/gists{/gist_id}","starred_url":"https://api.github.com/users/hanno-arm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanno-arm/subscriptions","organizations_url":"https://api.github.com/users/hanno-arm/orgs","repos_url":"https://api.github.com/users/hanno-arm/repos","events_url":"https://api.github.com/users/hanno-arm/events{/privacy}","received_events_url":"https://api.github.com/users/hanno-arm/received_events","type":"User","site_admin":false},"created_at":"2018-09-18T16:17:33Z","updated_at":"2018-09-18T16:17:33Z","author_association":"CONTRIBUTOR","body":"Thanks for the update, @umanayana. Closing."}}
{"actor":{"display_login":"hanno-arm"}}