GmSSL icon indicating copy to clipboard operation
GmSSL copied to clipboard

windows7下,VS2008编译GmSSL报错,生成skf.lib和skf.dll不成功

Open light-years-run opened this issue 9 years ago • 20 comments

NMAKE : warning U4004: too many rules for target 'tmp32dll.dbg\modes.h' link /nologo /subsystem:console /opt:ref /debug /dll /out:out32dll.dbg\skf.dll @C:\Users\ZJ J-WC~1\AppData\Local\Temp\nm6AFA.tmp Creating library out32dll.dbg\skf.lib and object out32dll.dbg\skf.exp e_skf.obj : error LNK2019: unresolved external symbol _SKF_SetSymmKey@16 referenced in function _skf _init_key e_skf.obj : error LNK2019: unresolved external symbol _SKF_nid_to_encparams referenced in function _ skf_init_key e_skf.obj : error LNK2019: unresolved external symbol _SKF_DecryptUpdate@20 referenced in function _ skf_cipher e_skf.obj : error LNK2019: unresolved external symbol _SKF_EncryptUpdate@20 referenced in function _ skf_cipher e_skf.obj : error LNK2019: unresolved external symbol _SKF_DecryptInit@48 referenced in function _sk f_cipher e_skf.obj : error LNK2019: unresolved external symbol _SKF_EncryptInit@48 referenced in function _sk f_cipher e_skf.obj : error LNK2019: unresolved external symbol _SKF_GenRandom@12 referenced in function skf rand_bytes e_skf.obj : error LNK2019: unresolved external symbol _SKF_DigestInit@24 referenced in function _skf _sm3_init e_skf.obj : error LNK2019: unresolved external symbol _SKF_DigestUpdate@12 referenced in function _s kf_sm3_update e_skf.obj : error LNK2019: unresolved external symbol _SKF_CloseHandle@4 referenced in function _skf _sm3_final e_skf.obj : error LNK2019: unresolved external symbol _SKF_DigestFinal@12 referenced in function _sk f_sm3_final e_skf.obj : error LNK2019: unresolved external symbol _SKF_RSASignData@20 referenced in function _sk f_rsa_sign e_skf.obj : error LNK2019: unresolved external symbol _SKF_GetDevInfo@8 referenced in function _open _dev e_skf.obj : error LNK2019: unresolved external symbol _SKF_ConnectDev@8 referenced in function _open _dev e_skf.obj : error LNK2019: unresolved external symbol _SKF_DevAuth@12 referenced in function _dev_au th e_skf.obj : error LNK2019: unresolved external symbol _SKF_OpenApplication@12 referenced in function _open_app e_skf.obj : error LNK2019: unresolved external symbol _SKF_VerifyPIN@16 referenced in function _veri fy_pin e_skf.obj : error LNK2019: unresolved external symbol _SKF_OpenContainer@12 referenced in function _ open_container e_skf.obj : error LNK2019: unresolved external symbol _RSA_new_from_RSAPUBLICKEYBLOB referenced in f unction _skf_load_pubkey e_skf.obj : error LNK2019: unresolved external symbol _EC_KEY_new_from_ECCPUBLICKEYBLOB referenced i n function _skf_load_pubkey e_skf.obj : error LNK2019: unresolved external symbol _SKF_ExportPublicKey@16 referenced in function _skf_load_pubkey e_skf.obj : error LNK2019: unresolved external symbol _SKF_GetContainerType@8 referenced in function _skf_load_pubkey e_skf.obj : error LNK2019: unresolved external symbol _SKF_DisConnectDev@4 referenced in function _s kf_finish

该怎么解决,望回复!!!

light-years-run avatar Jan 10 '17 08:01 light-years-run

建议的安装方法是在安装gmssl的过程中将有关SKF的部分注释掉,然后在后面可能会产生生成的静态库中只包含了SM2算法声明而没有实现的问题,这个问题留在配置过程中进行解决。

chunheinanzi avatar Jan 11 '17 07:01 chunheinanzi

这个编译错误,我已经解决了,但是编译出来的可执行文件中,没有SM2和SM4的算法,请问这个怎么解决

在 2017-01-11 15:57:03,"chunheinanzi" [email protected] 写道:

建议的安装方法是在安装gmssl的过程中将有关SKF的部分注释掉,然后在后面可能会产生生成的静态库中只包含了SM2算法声明而没有实现的问题,这个问题留在配置过程中进行解决。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 08:01 light-years-run

能再详细描述么

chunheinanzi avatar Jan 11 '17 08:01 chunheinanzi

就是 使用指令的时候 gmssl dgst -sm2... 或者 gmssl dgst -sm4 不可用, 然后就打印出显示可用的算法,里面有sm3和md4、md5 等其他的。

在 2017-01-11 16:19:08,"chunheinanzi" [email protected] 写道:

能再详细描述么

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 08:01 light-years-run

这是我显示的算法 Message Digest commands (see the `dgst' command for more details) md4 md5 mdc2 rmd160 sha sha1 sm3

在 2017-01-11 16:19:08,"chunheinanzi" [email protected] 写道:

能再详细描述么

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 08:01 light-years-run

那你就尴尬了,我也没遇到这样的情况。vs2008 spi 你装了么

chunheinanzi avatar Jan 11 '17 08:01 chunheinanzi

我是安装的VS2008集成开发环境,关键是在Linux系统下,我也安装了GmSSL,也没有这两个算法。是不是GmSSL不支持SM2和SM4啊?

在 2017-01-11 16:50:27,"chunheinanzi" [email protected] 写道:

那你就尴尬了,我也没遇到这样的情况。vs2008 spi 你装了么

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 08:01 light-years-run

我这里刚装完,SM2好使,你打个vs2008 spi补丁试试

chunheinanzi avatar Jan 11 '17 09:01 chunheinanzi

那我Linux系统环境下同样的问题,什么原因呢,或者你能把你windows下编译的源码,以及编译好的 发我一份吗? 谢谢!!

在 2017-01-11 17:03:33,"chunheinanzi" [email protected] 写道:

我这里刚装完,SM2好使,你打个vs2008 spi补丁试试

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 09:01 light-years-run

是我使用方式不对吗,你用的什么样的指令使用SM2,能告诉我吗?

在 2017-01-11 17:03:33,"chunheinanzi" [email protected] 写道:

我这里刚装完,SM2好使,你打个vs2008 spi补丁试试

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 09:01 light-years-run

sm2test.cpp 这个文件你搜一下 编译看看你的库有没有 有的话再说

chunheinanzi avatar Jan 11 '17 09:01 chunheinanzi

有这个库sm2test.obj,并且已经生产了sm2test.exe文件,但是运行时报错: \GmSSL-master\out32dll.dbg>sm2test.exe sm2 sign p256 passed sm2 sign b257 passed sm2 enc p256 passed sm2 enc b257 passed sm2 kap p256 passed test_evp_pkey_sign(sm-scheme) passed test_evp_pkey_sign(secg-scheme) passed test_evp_pkey_encrypt(sm-scheme) passed test_evp_pkey_encrypt(secg-scheme) passed error: .\crypto\sm2\sm2test.c 897 error: .\crypto\sm2\sm2test.c 1220 3328:error:3406A06A:SM2 routines:SM2_decrypt:error:.\crypto\sm2\sm2_enc.c:519: 3328:error:1012D09E:elliptic curve routines:PKEY_EC_DECRYPT:sm2 decrypt with recommended failed:.\crypto\ec\ec_pmeth.c:4 37:

SM2 test failed

在 2017-01-11 17:25:58,"chunheinanzi" [email protected] 写道:

sm2test.cpp 这个文件你搜一下 编译看看你的库有没有 有的话再说

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 09:01 light-years-run

你去安装的路径找libeay32.lib ssleay32.lib 两个库 在代码里加入#pragma comment(lib,"libeay32.lib") #pragma comment(lib,"ssleay32.lib") 试试 别忘了把该添加的路径都添加好

chunheinanzi avatar Jan 11 '17 10:01 chunheinanzi

安装要求加入了这两个静态库导入 #pragma comment(lib,"E:/usr/local/ssl/lib/libeay32.lib") #pragma comment(lib,"E:/usr/local/ssl/lib/ssleay32.lib") 用绝对路径,保证路径正确,并且编译通过,运行还是有错: E:\src\GmSSL-master\out32dll.dbg>sm2test.exe sm2 sign p256 passed sm2 sign b257 passed sm2 enc p256 passed sm2 enc b257 passed sm2 kap p256 passed test_evp_pkey_sign(sm-scheme) passed test_evp_pkey_sign(secg-scheme) passed test_evp_pkey_encrypt(sm-scheme) passed test_evp_pkey_encrypt(secg-scheme) passed error: .\crypto\sm2\sm2test.c 900 error: .\crypto\sm2\sm2test.c 1223 12168:error:3406A06A:SM2 routines:SM2_decrypt:error:.\crypto\sm2\sm2_enc.c:519: 12168:error:1012D09E:elliptic curve routines:PKEY_EC_DECRYPT:sm2 decrypt with recommended failed:.\crypto\ec\ec_pmeth.c: 437:

SM2 test failed

在 2017-01-11 18:36:46,"chunheinanzi" [email protected] 写道:

你去安装的路径找libeay32.lib ssleay32.lib 两个库 在代码里加入#pragma comment(lib,"libeay32.lib") #pragma comment(lib,"ssleay32.lib") 试试 别忘了把该添加的路径都添加好

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 11 '17 11:01 light-years-run

还在吗,你能发你windows环境下编译好的发我邮箱一下吗? [email protected]

在 2017-01-11 18:36:46,"chunheinanzi" [email protected] 写道:

你去安装的路径找libeay32.lib ssleay32.lib 两个库 在代码里加入#pragma comment(lib,"libeay32.lib") #pragma comment(lib,"ssleay32.lib") 试试 别忘了把该添加的路径都添加好

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 12 '17 08:01 light-years-run

恭喜恭喜 sm2算法加密解密 签名验签的过程并没有相应的函数调用文档,好多逻辑,调用都要自己搞

chunheinanzi avatar Jan 12 '17 09:01 chunheinanzi

我就说吧.............不可能那么简单的就给免费提供SM2的算法服务了.........

在 2017-01-12 17:01:55,"chunheinanzi" [email protected] 写道:

恭喜恭喜 sm2算法加密解密 签名验签的过程并没有相应的函数调用文档,好多逻辑,调用都要自己搞

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 12 '17 09:01 light-years-run

GmSSL提供了SM2的命令行调用方法,参见demo/gmssl/gmssl.sh 中SM2加密解密的命令行调用例子。其中命令pkey, pkeyutl, pkeyparam(请参考OpenSSL对应的手册页或-help)对公钥密码进行了包装,因此不需要独立的sm2命令,这也是OpenSSL推荐的方式。如果需要编程调用的话也可以使用EVP API,在test/sm2test.c中有完整的例子。EVP API请参考OpenSSL的手册页和OpenSSL Wiki。

guanzhi avatar Jan 12 '17 14:01 guanzhi

好的,谢谢啦!! 祝好!

在 2017-01-12 22:21:47,"Zhi Guan" [email protected] 写道:

GmSSL提供了SM2的命令行调用方法,参见demo/gmssl/gmssl.sh 中SM2加密解密的命令行调用例子。其中命令pkey, pkeyutl, pkeyparam(请参考OpenSSL对应的手册页或-help)对公钥密码进行了包装,因此不需要独立的sm2命令,这也是OpenSSL推荐的方式。如果需要编程调用的话也可以使用EVP API,在test/sm2test.c中有完整的例子。EVP API请参考OpenSSL的手册页和OpenSSL Wiki。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

light-years-run avatar Jan 13 '17 00:01 light-years-run

Marked as stale issue. Will be closed later if no activity for a while.

github-actions[bot] avatar Oct 18 '20 01:10 github-actions[bot]