Git Product home page Git Product logo

gmssl-java's People

Contributors

guanzhi avatar wangtsiao avatar yxk123 avatar zxm256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gmssl-java's Issues

Android 平台上 NativeLoader 运行异常

image

如图,我将 gmssl 的源码以及 gmssl-java 集成在一起编译, 在安卓手机上运行时 NativeLoader.load() 会报错: lib file is not found!, 我改换为安卓上的加载动态库System.loadLibrary("gmssljni"); , 运行没有问题,希望可以兼容处理一下

Sm2Test 中拆开执行报错而放在一起执行正确的问题

https://github.com/GmSSL/GmSSL-Java/blob/main/src/test/java/org/gmssl/Sm2Test.java

具体原因是因为 @BeforeTest 每次都重新生成key

@Before
  public void beforeTest(){
      sm2_key = new Sm2Key();
      sm2_key.generateKey();
  }

需要将key固化到磁盘,然后在其他的测试用例内加载,即可解决问题

class TestSm2 {

    private val sm2Key = Sm2Key(has_private_key = true)

    @Test
    fun generateKeys() {
        sm2Key.generateKey()
        sm2Key.exportPublicKeyInfoPem("publickey.pem")
        sm2Key.exportEncryptedPrivateKeyInfoPem("12345678", "privatekey.pk8")
    }

    private fun loadKeys() {
        sm2Key.importPublicKeyInfoPem("publickey.pem")
        sm2Key.importEncryptedPrivateKeyInfoPem("12345678", "privatekey.pk8")
    }

    @Test
    fun testEncrypt() {
        loadKeys()
        val testStr = "gmssl"
        val ciphertext = sm2Key.encrypt(testStr.toByteArray())
        val textHex = HexUtil.byteToHex(ciphertext)
        println(textHex)
    }

    @Test
    fun testDecrypt() {
        loadKeys()
        val textHex = "306f0221008d769703b894dbf832409e2497f87a52bd203d83e7d56616a95ff8597ee0b5fb022100befc69ee3141f53e94ddfa2155f1bd3289e5c7b6cdc828bd4b7fdd49f4360d0f04206300ec08d80eab55c7999fb5c114da7398d76d575bc20ddf881627497fd14aa404051136b536c6"
        val ciphertext = HexUtil.hexToByte(textHex)
        val plaintext = sm2Key.decrypt(ciphertext)
        val plaintextStr = String(plaintext)
        println(plaintextStr)
    }
}

Build Error

GmSSL-Java/src/main/c/gmssljni.c:21:10: fatal error: 'gmssl/aead.h' file not found

make 执行错误

[root@localhost build]# make [ 20%] Building C object CMakeFiles/gmssljni-native.dir/gmssljni.c.o /home/zc/GmSSL-Java-main/gmssljni.c:14:23: 致命错误:gmssl/sm2.h:没有那个文件或目录 #include <gmssl/sm2.h> ^ 编译中断。 make[2]: *** [CMakeFiles/gmssljni-native.dir/gmssljni.c.o] 错误 1 make[1]: *** [CMakeFiles/gmssljni-native.dir/all] 错误 2 make: *** [all] 错误 2

zuc算法

你好,请问什么时候支持zuc算法。

Java应用程序崩溃的的问题

在Sm3、Sm4Cbc传入long sm4_cbc_ctx、sm3_cbc_ctx时,Java应用程序崩溃,发生了SIGSEGV信号,访问了无效的内存地址:

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x00007ff5b9ec91b1, pid=31540, tid=0x00007ff5fe54f700

JRE version: OpenJDK Runtime Environment (8.0_392-b08) (build 1.8.0_392-b08)

Java VM: OpenJDK 64-Bit Server VM (25.392-b08 mixed mode linux-amd64 compressed oops)

Problematic frame:

C [libgmssl.so.3+0x2a1b1] sm4_cbc_encrypt_update+0x24

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

在Windows 64位生成的dll无法使用

运行后错误提示
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\admin\AppData\Local\Temp\libgmssljni359268608746332705.dll: Can't load this .dll (machine code=0xbd) on a AMD 64-bit platform at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at org.gmssl.NativeLoader.load(NativeLoader.java:60) at org.gmssl.GmSSLJNI.<clinit>(GmSSLJNI.java:360) at org.gmssl.Sm2Key.importPublicKeyInfoDer(Sm2Key.java:91) at cn.stylefeng.guns.base.BaseJunit.main(BaseJunit.java:47)

关于Ukey相关使用

有人对接过UKey是直接使用目前库还是要找其他厂家要SKF库?
比如海泰、龙脉等厂家。

执行mvn clean package构建时出错 gmssl/aead.h:No such file or directory

执行mvn clean package构建时出现如下错误, 我是从github这边clone的最新的包
[ 50%] Building C object CMakeFiles/gmssljni-native.dir/gmssljni.c.o
/mnt/filemanage/tools/GmSSL-Java/src/main/c/gmssljni.c:21:10: 致命错误:gmssl/aead.h:No such file or directory
21 | #include <gmssl/aead.h>
| ^~~~~~~~~~~~~~
编译中断。
gmake[2]: *** [CMakeFiles/gmssljni-native.dir/build.make:76:CMakeFiles/gmssljni-native.dir/gmssljni.c.o] 错误 1
gmake[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/gmssljni-native.dir/all] 错误 2
gmake: *** [Makefile:91:all] 错误 2
[WARNING] Command: [/mnt/filemanage/tools/GmSSL-Java/target/dependency/cmake/bin/cmake, --build, /mnt/filemanage/tools/GmSSL-Java/target/build]
[WARNING] Directory: null

编译和运行链接so错误

按文档编译指示,在Ubuntu22.04上命令行编译
mkdir build
cd build
cmake ..
这都没问题,但是make的时候报错以下,似乎是无法正确引用java依赖库:
[ 20%] Building C object CMakeFiles/gmssljni-native.dir/gmssljni.c.o
[ 40%] Linking C shared library libgmssljni.so
[ 40%] Built target gmssljni-native
[ 60%] Building Java objects for GmSSLJNI.jar
src/main/java/org/gmssl/NativeLoader.java:11: error: package org.apache.maven.model does not exist
import org.apache.maven.model.Model;
^
src/main/java/org/gmssl/NativeLoader.java:12: error: package org.apache.maven.model.io.xpp3 does not exist
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
^
src/main/java/org/gmssl/NativeLoader.java:13: error: package org.codehaus.plexus.util.xml.pull does not exist
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
^
src/main/java/org/gmssl/NativeLoader.java:159: error: cannot find symbol
Model model = new MavenXpp3Reader().read(new FileReader("pom.xml"));
^
symbol: class Model
location: class NativeLoader
src/main/java/org/gmssl/NativeLoader.java:159: error: cannot find symbol
Model model = new MavenXpp3Reader().read(new FileReader("pom.xml"));
^
symbol: class MavenXpp3Reader
location: class NativeLoader
src/main/java/org/gmssl/NativeLoader.java:161: error: cannot find symbol
} catch (IOException | XmlPullParserException e) {
^
symbol: class XmlPullParserException
location: class NativeLoader
6 errors
make[2]: *** [CMakeFiles/GmSSLJNI.dir/build.make:103: CMakeFiles/GmSSLJNI.dir/java_compiled_GmSSLJNI] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/GmSSLJNI.dir/all] Error 2
make: *** [Makefile:101: all] Error 2

如果在项目目录下执行mvn install,可以完成编译,但run test时链接错误,报错以下:

T E S T S

Running org.gmssl.Sm2Test
Tests run: 7, Failures: 0, Errors: 7, Skipped: 0, Time elapsed: 0.115 sec <<< FAILURE!
computeZTest(org.gmssl.Sm2Test) Time elapsed: 0.069 sec <<< ERROR!
java.lang.UnsatisfiedLinkError: /home/hdq/trials/GmSSL-Java-main/target/classes/lib/libgmssljni.so: libgmssl.so.3: cannot open shared object file: No such file or directory
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2450)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2506)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2705)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2635)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1854)
at org.gmssl.NativeLoader.loadLibFile(NativeLoader.java:126)
at org.gmssl.NativeLoader.load(NativeLoader.java:59)
at org.gmssl.GmSSLJNI.(GmSSLJNI.java:360)
at org.gmssl.Sm2Key.generateKey(Sm2Key.java:51)
at org.gmssl.Sm2Test.beforeTest(Sm2Test.java:33)
确认GmSSL已安装到/usr/local/lib,且GmSSL和GmSSL-Java都使用最新dev版,甚至均使用readme指示的zip代码也一样。

以上应该都是小问题,请教解决方法,谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.