GMSSL 编译过程 (Windows10 x64 20H2)

1: 下载源码包

http://gmssl.org/docs/install.html

2: 安装perl 以及vs2019
3: 修改 c:\perl64\lib\ActivePerl\Config.pm 文件

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";
}

修改源代码 crypto/evp/names2.c

/*

Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the OpenSSL license (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <internal/objects.h>
#include <openssl/x509.h>
#include "internal/evp_int.h"

const EVP_CIPHER *EVP_get_default_cipher(void)
{
return NULL;
}

/*

use MD5 as default:
X509_REQ_to_X509 x509_r2x.c
X509_issuer_and_serial_hash x509_cmp.c
X509_NAME_hash_old x509_cmp.c
PEM_ASN1_write_bio pem_lib.c
*/
const EVP_MD *EVP_get_default_digest(void)
{
#if !defined(OPENSSL_NO_MD5)
return EVP_md5();
#elif !defined(OPENSSL_NO_SHA)
return EVP_sha1();
#elif !defined(OPENSSL_NO_SM3)
return EVP_sm3();
#elif !defined(OPENSSL_NO_RIPEMD)
return EVP_rmd160();
#else
return NULL;
#endif
}
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";
}

否则会报错
libcrypto-1_1-x64.def : error LNK2001: 无法解析的外部符号 EVP_get_ciphernames

4: 运行 vs2019 自带控制台 x64版本的
5: 运行 perl Configure VC-WIN64A no-asm
6: 运行 nmake
7: 运行 nmake install
8: 编译完成

posted @ 2021-01-27 16:12  knva  阅读(41)  评论(0编辑  收藏