1.下载源码:https://github.com/guanzhi/GmSSL/
2.下载安装perl和nasm: https://www.perl.org/get.html ,https://www.nasm.us/ 。nasm设置运行文件路径到环境变量。
3. 安装最新版Visual Studio: https://visualstudio.microsoft.com/zh-hans/vs/
4. 生成makefile:perl Configure VC-WIN64A , 或者带--prefix= 参数指定gmssl安装目录, --openssldir=指定openssl路径。
5. 编译:nmake
6. 安装:nmake install
7. 遇到的问题:
(1)perl出现的一个问题
修改D:\Perl64\site\lib\ActivePerlConfig.pm文件,注释掉相应函数体内的实现代码:
my $console;
sub _warn {
# my($msg) = @_;
# unless (-t STDOUT) {
# print "\n$msg\n";
# return;
# }
# require Win32::Console;
# unless ($console) {
# $console = Win32::Console->new(Win32::Console::STD_OUTPUT_HANDLE());
# }
# my($col,undef) = $console->Size;
# print "\n";
# my $attr = $console->Attr;
# $console->Attr($Win32::Console::FG_RED | $Win32::Console::BG_WHITE);
# for (split(/\n/, "$msg")) {
# $_ .= " " while length() < $col-1;
# print "$_\n";
# }
# $console->Attr($attr);
# print "\n";
}
(2)无法解析的外部符号 EVP_get_ciphernames、EVP_get_digestnames
GmSSL-master\crypto\evp\names2.c文件末尾添加下面的代码:
static void cipher_name_len(const EVP_CIPHER *cipher, const char *from,
const char *to, void *x)
{
*((int *)x) += strlen(EVP_CIPHER_name(cipher));
}
static void cipher_name(const EVP_CIPHER *cipher, const char *from,
const char *to, void *x)
{
strcat((char *)x, EVP_CIPHER_name(cipher));
}
char *EVP_get_ciphernames(int aliases)
{
char *ret = NULL;
int len = 0;
EVP_CIPHER_do_all_sorted(cipher_name_len, &len);
ret = OPENSSL_zalloc(len);
if (!ret) {
return NULL;
}
EVP_CIPHER_do_all_sorted(cipher_name, ret);
return ret;
}
char *EVP_get_digestnames(int aliases)
{
return "sm3:sha1:sha256";
}
参考:https://blog.csdn.net/liuxing9345/article/details/110742166