GmSSL是一个开源的密码工具箱,支持SM2/SM3/SM4/SM9等国密(国家商用密码)算法、SM2国密数字证书及基于SM2证书的SSL/TLS安全通信协议,支持国密硬件密码设备,提供符合国密规范的编程接口与命令行工具,可以用于构建PKI/CA、安全通信、数据加密等符合国密标准的安全应用。GmSSL项目是OpenSSL项目的分支,并与OpenSSL保持接口兼容。
GmSSL 提供了java 接口,在windows下,编译JAVA接口的步骤
1、首先编译GmSSL
a)工具 perl ,vs2017(或者其他版本)
b)编译步骤
perl Configure VC-WIN64A no-asm
nmake
2、编译java 库文件
a) 工具 JDK vs
b) nmake -f winmake
c) nmake -f winmake test
makefile 内容
##WINDOWS native library gmssljni.dll generation
LIBCRYPTOS=../libcrypto.lib
JAVADLL=gmssljni.dll
CC=cl
CFLAGS=-DNDEBUG -W3 -wd4090 -Gs0 -GF -Gy -nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE /O2
LD=link
LDFLAGS=/nologo /dll
EX_LIBS=ws2_32.lib advapi32.lib crypt32.lib user32.lib
LIB_CFLAGS=
!IF DEFINED(STATIC)
CFLAGS = $(CFLAGS) /MT
!ELSE
CFLAGS = $(CFLAGS) /MD
!ENDIF
#JAVA_HOME check
!IF "x$(JAVA_HOME)x" == "xx"
!ERROR "The environment variable JAVA_HOME is empty!"
!ENDIF
!IF ! EXIST("$(JAVA_HOME)/bin/javac.exe")
!ERROR "Javac was not found in JAVA_HOME($(JAVA_HOME)/bin)!"
!ENDIF
JAVAC="$(JAVA_HOME)/bin/javac"
JAVAINCLUDE=-I "$(JAVA_HOME)\include" -I "$(JAVA_HOME)\include\win32"
JAVADLLPATH=-Djava.library.path=.
JAVA=java
all: $(JAVADLL) GmSSL.class
GmSSL.obj:
$(CC) /I "." /I "..\include" $(JAVAINCLUDE) $(CFLAGS) $(LIB_CFLAGS) -c GmSSL.c
gmssl_err.obj:
$(CC) /I "." /I "..\include" $(JAVAINCLUDE) $(CFLAGS) $(LIB_CFLAGS) -c gmssl_err.c
$(JAVADLL): GmSSL.obj gmssl_err.obj
$(LD) $(LIBCRYPTOS) $(EX_LIBS) $(LDFLAGS) /out:$@ $**
GmSSL.class:
$(JAVAC) GmSSL.java
test: $(JAVADLL) GmSSL.class
IF EXIST ..\libcrypto-1_1*.dll copy /Y ..\libcrypto-1_1*.dll .
$(JAVA) $(JAVADLLPATH) GmSSL
clean:
IF EXIST *.obj DEL /F /Q *.obj
IF EXIST GmSSL.class DEL /F /Q GmSSL.class
IF EXIST libcrypto-1_1*.dll DEL /F /Q libcrypto-1_1*.dll
IF EXIST $(JAVADLL).* DEL /F /Q $(JAVADLL).*
网友评论