{"action":"created","issue":{"url":"https://api.github.com/repos/guanzhi/GmSSL/issues/33","repository_url":"https://api.github.com/repos/guanzhi/GmSSL","labels_url":"https://api.github.com/repos/guanzhi/GmSSL/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/guanzhi/GmSSL/issues/33/comments","events_url":"https://api.github.com/repos/guanzhi/GmSSL/issues/33/events","html_url":"https://github.com/guanzhi/GmSSL/issues/33","id":165726894,"number":33,"title":"sm2 加解密问题","user":{"login":"LiTianjue","id":8023990,"avatar_url":"https://avatars.githubusercontent.com/u/8023990?v=3","gravatar_id":"","url":"https://api.github.com/users/LiTianjue","html_url":"https://github.com/LiTianjue","followers_url":"https://api.github.com/users/LiTianjue/followers","following_url":"https://api.github.com/users/LiTianjue/following{/other_user}","gists_url":"https://api.github.com/users/LiTianjue/gists{/gist_id}","starred_url":"https://api.github.com/users/LiTianjue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiTianjue/subscriptions","organizations_url":"https://api.github.com/users/LiTianjue/orgs","repos_url":"https://api.github.com/users/LiTianjue/repos","events_url":"https://api.github.com/users/LiTianjue/events{/privacy}","received_events_url":"https://api.github.com/users/LiTianjue/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2016-07-15T07:24:05Z","updated_at":"2016-08-12T21:32:29Z","closed_at":null,"body":"老师，你好\r\n我用sm2做加解密测试的时候，\r\n加密可以出来结果\r\n解密的时候失败了，这是什么问题\r\nAPI的调用正确吗，还是其他的什么问题\r\n\r\n\r\n```c\r\n\r\nint test_sm2_enc()\r\n{\r\n\tEC_KEY *key1;\r\n\tEC_GROUP\t*group1;\r\n\tint nid,ret;\r\n\r\n\tkey1 = EC_KEY_new();\r\n\tif(!key1)\r\n\t\treturn 0;\r\n\r\n   \tint nid = NID_sm2p256v1;\r\n   \tgroup1 = EC_GROUP_new_by_curve_name(nid);\r\n   \tif(group1 == NULL)\r\n   \t\treturn 0;\r\n\r\n   \tret = EC_KEY_set_group(key1,group1);\r\n   \tif(ret != 1)\r\n\t\treturn 0;\r\n   \r\n  \tret = EC_KEY_generate_key(key1);\r\n\r\n\t//EC_KEY_print_fp(stdout,key1,0);\r\n\t/*---- ----*/\r\n\t\r\n\tprintf(\"----加密测试----\\n\");\r\n\tchar tmp_buf[48] = {0};\r\n\tmemset(tmp_buf,'1',48);\r\n\r\n\tchar out_buf[48+128] = {0};\r\n\tint buf_size = 48 +128;\r\n\r\n\tif(!SM2_encrypt_with_recommended(out_buf,&buf_size,\r\n\t\t\t\t(const unsigned char *)tmp_buf,sizeof(tmp_buf),key1)) {\r\n\t\tprintf(\"SM2 Encryp ERROR !!!\\n\");\r\n\t\treturn -1;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tprintf(\"SM2 Encrypt Result[%d] :\\n\",buf_size);\r\n\t\t//print_hex(out_buf,buf_size);\r\n\t\tprintf(\"----测试成功----\\n\\n\");\r\n\t}\r\n\r\n\tprintf(\"----解密测试----\\n\");\r\n\tunsigned char msg[128] = {0};\r\n\tsize_t msglen = 0;\r\n\tif(!SM2_decrypt_with_recommended(msg,&msglen,out_buf,buf_size,key1))\r\n\t{\r\n\t\tprintf(\"解密失败！！！\\n\");\r\n\t\treturn -1;\r\n\t}else {\r\n\t\tprintf(\"SM2 Decrypt Result[%d] :\\n\",msglen);\r\n\t\t//print_hex(msg,msglen);\r\n\t\tprintf(\"----测试成功----\\n\\n\");\r\n\t}\r\n\t\r\n   \treturn 0;\r\n}\r\n```\r\n\r\n另外想问一个国密SSL的问题\r\n现在代码树中定义了SSL_kECC 密钥交换算法，我想问这是什么算法\r\n从文档上看和SSL_kRSA算法应该是差不多(用非对称密钥加密预主密钥)，但是似乎openssl里面没有这种类似的算法\r\n是不是要自己实现"},"comment":{"url":"https://api.github.com/repos/guanzhi/GmSSL/issues/comments/239565001","html_url":"https://github.com/guanzhi/GmSSL/issues/33#issuecomment-239565001","issue_url":"https://api.github.com/repos/guanzhi/GmSSL/issues/33","id":239565001,"user":{"login":"guanzhi","id":1787781,"avatar_url":"https://avatars.githubusercontent.com/u/1787781?v=3","gravatar_id":"","url":"https://api.github.com/users/guanzhi","html_url":"https://github.com/guanzhi","followers_url":"https://api.github.com/users/guanzhi/followers","following_url":"https://api.github.com/users/guanzhi/following{/other_user}","gists_url":"https://api.github.com/users/guanzhi/gists{/gist_id}","starred_url":"https://api.github.com/users/guanzhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guanzhi/subscriptions","organizations_url":"https://api.github.com/users/guanzhi/orgs","repos_url":"https://api.github.com/users/guanzhi/repos","events_url":"https://api.github.com/users/guanzhi/events{/privacy}","received_events_url":"https://api.github.com/users/guanzhi/received_events","type":"User","site_admin":false},"created_at":"2016-08-12T21:32:29Z","updated_at":"2016-08-12T21:32:29Z","body":"iOS模拟器和arm32支持吗？"}}
{"actor":{"display_login":"guanzhi"}}