{"action":"created","issue":{"url":"https://api.github.com/repos/libssh2/libssh2/issues/143","repository_url":"https://api.github.com/repos/libssh2/libssh2","labels_url":"https://api.github.com/repos/libssh2/libssh2/issues/143/labels{/name}","comments_url":"https://api.github.com/repos/libssh2/libssh2/issues/143/comments","events_url":"https://api.github.com/repos/libssh2/libssh2/issues/143/events","html_url":"https://github.com/libssh2/libssh2/issues/143","id":185405840,"number":143,"title":"Patch to allow public-key from memory","user":{"login":"doublex","id":274624,"avatar_url":"https://avatars.githubusercontent.com/u/274624?v=3","gravatar_id":"","url":"https://api.github.com/users/doublex","html_url":"https://github.com/doublex","followers_url":"https://api.github.com/users/doublex/followers","following_url":"https://api.github.com/users/doublex/following{/other_user}","gists_url":"https://api.github.com/users/doublex/gists{/gist_id}","starred_url":"https://api.github.com/users/doublex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doublex/subscriptions","organizations_url":"https://api.github.com/users/doublex/orgs","repos_url":"https://api.github.com/users/doublex/repos","events_url":"https://api.github.com/users/doublex/events{/privacy}","received_events_url":"https://api.github.com/users/doublex/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-26T14:14:16Z","updated_at":"2016-12-04T17:02:52Z","closed_at":null,"body":"This patch fixes three issues:\na) Allow to pass a password to an in-memory private-key\nb) Add missing \"mbedtls_rsa_init()\"\nc) \"int mbedtls_pk_parse_key()\" checks in \"mbedtls/pkparse.c:1074\" if the last byte of the privatekey is null: `key[keylen - 1] != '\\0'`\nSo one has to pass the null-terminator to mbed-tls. \"libssh2\" needs the null-terminator anyways because libssh2 ignores the length parameter of \"libssh2_userauth_publickey_frommemory()\" and calls \"strlen()\"\n\n``` diff\n*** mbedtls.c-old       2016-10-26 14:10:16.755031650 +0200\n--- mbedtls.c   2016-10-26 16:08:13.474135845 +0200\n*************** _libssh2_mbedtls_rsa_new_private_frommem\n*** 374,383 ****\n      if (*rsa == NULL)\n          return -1;\n\n      mbedtls_pk_init(&pkey);\n\n!     ret = mbedtls_pk_parse_key(&pkey, (unsigned char *)filedata,\n!                               filedata_len, NULL, 0);\n      if( ret != 0 || mbedtls_pk_get_type(&pkey) != MBEDTLS_PK_RSA)\n      {\n          mbedtls_pk_free(&pkey);\n--- 374,388 ----\n      if (*rsa == NULL)\n          return -1;\n\n+     mbedtls_rsa_init(*rsa, MBEDTLS_RSA_PKCS_V15, 0);\n      mbedtls_pk_init(&pkey);\n\n!     if (passphrase != NULL)\n!         ret = mbedtls_pk_parse_key(&pkey, (unsigned char *)filedata,\n!                                   filedata_len + 1, passphrase, strlen((const char *)passphrase));\n!     else\n!         ret = mbedtls_pk_parse_key(&pkey, (unsigned char *)filedata,\n!                                   filedata_len + 1, NULL, 0);\n      if( ret != 0 || mbedtls_pk_get_type(&pkey) != MBEDTLS_PK_RSA)\n      {\n          mbedtls_pk_free(&pkey);\n*************** _libssh2_mbedtls_pub_priv_keyfilememory(\n*** 591,598 ****\n      int ret;\n\n      mbedtls_pk_init(&pkey);\n!     ret = mbedtls_pk_parse_key(&pkey, (unsigned char *)privatekeydata,\n!                               privatekeydata_len, NULL, 0);\n      if( ret != 0 )\n      {\n          mbedtls_strerror(ret, (char *)buf, sizeof(buf));\n--- 596,607 ----\n      int ret;\n\n      mbedtls_pk_init(&pkey);\n!     if (passphrase != NULL)\n!         ret = mbedtls_pk_parse_key(&pkey, (unsigned char *)privatekeydata,\n!                                   privatekeydata_len + 1, passphrase, strlen((const char *)passphrase));\n!     else\n!         ret = mbedtls_pk_parse_key(&pkey, (unsigned char *)privatekeydata,\n!                                   privatekeydata_len + 1, NULL, 0);\n      if( ret != 0 )\n      {\n          mbedtls_strerror(ret, (char *)buf, sizeof(buf));\n```\n"},"comment":{"url":"https://api.github.com/repos/libssh2/libssh2/issues/comments/264715917","html_url":"https://github.com/libssh2/libssh2/issues/143#issuecomment-264715917","issue_url":"https://api.github.com/repos/libssh2/libssh2/issues/143","id":264715917,"user":{"login":"alamaison","id":596743,"avatar_url":"https://avatars.githubusercontent.com/u/596743?v=3","gravatar_id":"","url":"https://api.github.com/users/alamaison","html_url":"https://github.com/alamaison","followers_url":"https://api.github.com/users/alamaison/followers","following_url":"https://api.github.com/users/alamaison/following{/other_user}","gists_url":"https://api.github.com/users/alamaison/gists{/gist_id}","starred_url":"https://api.github.com/users/alamaison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alamaison/subscriptions","organizations_url":"https://api.github.com/users/alamaison/orgs","repos_url":"https://api.github.com/users/alamaison/repos","events_url":"https://api.github.com/users/alamaison/events{/privacy}","received_events_url":"https://api.github.com/users/alamaison/received_events","type":"User","site_admin":false},"created_at":"2016-12-04T17:02:52Z","updated_at":"2016-12-04T17:02:52Z","body":"Sorry, I gave you a shortened version of the instructions to keep things simple.  But I forgot you needed to make multiple PRs in parallel.  Your combined PR is fine, but for the future the way to create PRs in parallel is to make you changes on a new git branch (`git checkout -b my_branch_name`) and push that branch to github instead of pushing master"}}
{"actor":{"display_login":"alamaison"}}