openssl win平台编译

参考 http://www.leoxiaofei.com/build-openssl.html

   https://gitee.com/mirrors/openssl/blob/master/NOTES-WINDOWS.md#native-builds-using-mingw

参照官方的案例很简单就搞定了,网上找到的都是openssl1.0.2版本的,不适用与1.1.1和3.0.0

 

简单操作

1 安装 https://www.activestate.com/products/perl/

      这个链接可以直接下载exe文件进行安装

  https://platform.activestate.com/ActiveState/ActivePerl-5.28/distributions

2 安装 nasm

  https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/

PATH中加入ActivePerl和NASM

 

3 下载源码

  https://www.openssl.org/source/

4 找到readme,找到对应的文件安装说明

 

 

 

 

此处使用vs2019 编译

 

 

cd 到解压目录 运行指令此处是x64平台,就运行

 

Perl Configure VC-WIN64A  --prefix=目标目录

 

 

 

nmake install

 

DEMO

 

 #include <openssl/evp.h>

 /* obtain an EVP_PKEY using whatever methods... */
 mctx = EVP_MD_CTX_new();
 pctx = EVP_PKEY_CTX_new(pkey, NULL);
 EVP_PKEY_CTX_set1_id(pctx, id, id_len);
 EVP_MD_CTX_set_pkey_ctx(mctx, pctx);
 EVP_DigestVerifyInit(mctx, NULL, EVP_sm3(), NULL, pkey);
 EVP_DigestVerifyUpdate(mctx, msg, msg_len);
 EVP_DigestVerifyFinal(mctx, sig, sig_len)



  
//

 openssl API   https://www.openssl.org/docs/man3.0/

国家SM2算法标准要求  http://www.sca.gov.cn/sca/xwdt/2010-12/17/content_1002386.shtml

//

posted @ 2021-10-14 13:48  小城熊儿  阅读(101)  评论(0编辑  收藏  举报