Win10 system compile and install gmssl record

1. Download the source code: https://github.com/guanzhi/GmSSL/

2. Download and install perl and nasm:  https://www.perl.org/get.html  , https://www.nasm.us/  . nasm sets the path of the running file to the environment variable.

3. Install the latest version of Visual Studio:  https://visualstudio.microsoft.com/zh-hans/vs/

4. Generate a makefile: perl Configure VC-WIN64A, or specify the gmssl installation directory with the --prefix= parameter, and --openssldir= specify the openssl path.

5. Compile: nmake

6. Installation: nmake install

7. Problems encountered:

(1) A problem with perl

Modify the D:\Perl64\site\lib\ActivePerlConfig.pm file and comment out the implementation code in the corresponding function body:

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) Unresolved external symbols EVP_get_ciphernames, EVP_get_digestnames

Add the following code to the end of the GmSSL-master\crypto\evp\names2.c file:

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

Reference: https://blog.csdn.net/liuxing9345/article/details/110742166

Guess you like

Origin blog.csdn.net/eidolon_foot/article/details/110915762