mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
first step of v2 final release
This commit is contained in:
183
java/.gitignore
vendored
183
java/.gitignore
vendored
@@ -1,183 +0,0 @@
|
||||
# Ignore editor artefacts
|
||||
/.dir-locals.el
|
||||
|
||||
# Top level excludes
|
||||
/Makefile.orig
|
||||
/MINFO
|
||||
/TABLE
|
||||
/*.a
|
||||
/*.pc
|
||||
/rehash.time
|
||||
/inc.*
|
||||
/makefile.*
|
||||
/out.*
|
||||
/tmp.*
|
||||
/configdata.pm
|
||||
/GmSSL.h
|
||||
/*.so
|
||||
/*.dylib
|
||||
/*.jnilib
|
||||
|
||||
# *all* Makefiles
|
||||
#Makefile
|
||||
|
||||
# Links under apps
|
||||
/apps/CA.pl
|
||||
/apps/tsget
|
||||
/apps/tsget.pl
|
||||
/apps/md4.c
|
||||
|
||||
# Auto generated headers
|
||||
/crypto/buildinf.h
|
||||
/crypto/include/internal/*_conf.h
|
||||
/openssl/include/opensslconf.h
|
||||
/util/domd
|
||||
|
||||
# Executables
|
||||
/apps/openssl
|
||||
/test/sha256t
|
||||
/test/sha512t
|
||||
/test/gost2814789t
|
||||
/test/ssltest_old
|
||||
/test/*test
|
||||
/test/fips_aesavs
|
||||
/test/fips_desmovs
|
||||
/test/fips_dhvs
|
||||
/test/fips_drbgvs
|
||||
/test/fips_dssvs
|
||||
/test/fips_ecdhvs
|
||||
/test/fips_ecdsavs
|
||||
/test/fips_rngvs
|
||||
/test/fips_test_suite
|
||||
/test/ssltest_old
|
||||
/test/x509aux
|
||||
/test/v3ext
|
||||
|
||||
# Certain files that get created by tests on the fly
|
||||
/test/*.ss
|
||||
/test/*.srl
|
||||
/test/.rnd
|
||||
/test/test*.pem
|
||||
/test/newkey.pem
|
||||
/test/*.log
|
||||
/test/buildtest_*
|
||||
|
||||
# Fuzz stuff.
|
||||
# Anything without an extension is an executable on Unix, so we keep files
|
||||
# with extensions. And we keep the corpora subddir versioned as well.
|
||||
# Anything more generic with extensions that should be ignored will be taken
|
||||
# care of by general ignores for those extensions (*.o, *.obj, *.exe, ...)
|
||||
/fuzz/*
|
||||
!/fuzz/README*
|
||||
!/fuzz/corpora
|
||||
!/fuzz/*.*
|
||||
|
||||
# Misc auto generated files
|
||||
/include/openssl/opensslconf.h
|
||||
/tools/c_rehash
|
||||
/tools/c_rehash.pl
|
||||
/tags
|
||||
/TAGS
|
||||
/crypto.map
|
||||
/ssl.map
|
||||
|
||||
# Windows (legacy)
|
||||
/tmp32
|
||||
/tmp32.dbg
|
||||
/tmp32dll
|
||||
/tmp32dll.dbg
|
||||
/out32
|
||||
/out32.dbg
|
||||
/out32dll
|
||||
/out32dll.dbg
|
||||
/inc32
|
||||
/MINFO
|
||||
/ms/.rnd
|
||||
/ms/bcb.mak
|
||||
/ms/libeay32.def
|
||||
/ms/nt.mak
|
||||
/ms/ntdll.mak
|
||||
/ms/ssleay32.def
|
||||
/ms/version32.rc
|
||||
|
||||
# Files created on other branches that are not held in git, and are not
|
||||
# needed on this branch
|
||||
/include/openssl/asn1_mac.h
|
||||
/include/openssl/des_old.h
|
||||
/include/openssl/fips.h
|
||||
/include/openssl/fips_rand.h
|
||||
/include/openssl/krb5_asn.h
|
||||
/include/openssl/kssl.h
|
||||
/include/openssl/pq_compat.h
|
||||
/include/openssl/ssl23.h
|
||||
/include/openssl/tmdiff.h
|
||||
/include/openssl/ui_compat.h
|
||||
/test/fips_aesavs.c
|
||||
/test/fips_desmovs.c
|
||||
/test/fips_dsatest.c
|
||||
/test/fips_dssvs.c
|
||||
/test/fips_hmactest.c
|
||||
/test/fips_randtest.c
|
||||
/test/fips_rngvs.c
|
||||
/test/fips_rsagtest.c
|
||||
/test/fips_rsastest.c
|
||||
/test/fips_rsavtest.c
|
||||
/test/fips_shatest.c
|
||||
/test/fips_test_suite.c
|
||||
/test/shatest.c
|
||||
|
||||
##### Generic patterns
|
||||
# Auto generated assembly language source files
|
||||
*.s
|
||||
!/crypto/*/asm/*.s
|
||||
/crypto/arm*.S
|
||||
/crypto/*/*.S
|
||||
*.asm
|
||||
!/crypto/*/asm/*.asm
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# editor artefacts
|
||||
*.swp
|
||||
.#*
|
||||
\#*#
|
||||
*~
|
||||
|
||||
# Certificate symbolic links
|
||||
*.0
|
||||
|
||||
# All kinds of executables
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
*.dylib.*
|
||||
*.dll
|
||||
*.dll.*
|
||||
*.exe
|
||||
*.pyc
|
||||
*.exp
|
||||
*.lib
|
||||
*.pdb
|
||||
*.ilk
|
||||
*.def
|
||||
*.rc
|
||||
*.res
|
||||
*.class
|
||||
|
||||
# Misc generated stuff
|
||||
Makefile.save
|
||||
/crypto/**/lib
|
||||
/engines/**/lib
|
||||
/ssl/**/lib
|
||||
*.bak
|
||||
cscope.*
|
||||
*.d
|
||||
|
||||
# add by LiTianjue for GmSSL
|
||||
# auto create by Configure
|
||||
crypto/opensslconf.h
|
||||
tool/c_rehash
|
||||
# exec file
|
||||
apps/gmssl
|
||||
1528
java/GmSSL.c
1528
java/GmSSL.c
File diff suppressed because it is too large
Load Diff
1
java/GmSSL.ec
Normal file
1
java/GmSSL.ec
Normal file
@@ -0,0 +1 @@
|
||||
L JNI gmssl_err.h gmssl_err.c
|
||||
205
java/GmSSL.h
Normal file
205
java/GmSSL.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class GmSSL */
|
||||
|
||||
#ifndef _Included_GmSSL
|
||||
#define _Included_GmSSL
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getVersions
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getVersions
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getCiphers
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getCiphers
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getDigests
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getDigests
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getMacs
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getMacs
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getSignAlgorithms
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getSignAlgorithms
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getPublicKeyEncryptions
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getPublicKeyEncryptions
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getDeriveKeyAlgorithms
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getDeriveKeyAlgorithms
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: generateRandom
|
||||
* Signature: (I)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_generateRandom
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getCipherIVLength
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_GmSSL_getCipherIVLength
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getCipherKeyLength
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_GmSSL_getCipherKeyLength
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getCipherBlockSize
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_GmSSL_getCipherBlockSize
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: symmetricEncrypt
|
||||
* Signature: (Ljava/lang/String;[B[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_symmetricEncrypt
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: symmetricDecrypt
|
||||
* Signature: (Ljava/lang/String;[B[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_symmetricDecrypt
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getDigestLength
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_GmSSL_getDigestLength
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getDigestBlockSize
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_GmSSL_getDigestBlockSize
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: digest
|
||||
* Signature: (Ljava/lang/String;[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_digest
|
||||
(JNIEnv *, jobject, jstring, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getMacLength
|
||||
* Signature: (Ljava/lang/String;)[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getMacLength
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: mac
|
||||
* Signature: (Ljava/lang/String;[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_mac
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: sign
|
||||
* Signature: (Ljava/lang/String;[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_sign
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: verify
|
||||
* Signature: (Ljava/lang/String;[B[B[B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_GmSSL_verify
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: publicKeyEncrypt
|
||||
* Signature: (Ljava/lang/String;[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_publicKeyEncrypt
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: publicKeyDecrypt
|
||||
* Signature: (Ljava/lang/String;[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_publicKeyDecrypt
|
||||
(JNIEnv *, jobject, jstring, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: deriveKey
|
||||
* Signature: (Ljava/lang/String;I[B[B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL Java_GmSSL_deriveKey
|
||||
(JNIEnv *, jobject, jstring, jint, jbyteArray, jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: GmSSL
|
||||
* Method: getErrorStrings
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_GmSSL_getErrorStrings
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
206
java/GmSSL.java
206
java/GmSSL.java
@@ -49,39 +49,195 @@
|
||||
|
||||
public class GmSSL {
|
||||
|
||||
public native String getVersion(int type);
|
||||
public native byte [] generateRandom(int length);
|
||||
public native String [] getCiphers(boolean aliases);
|
||||
public native String[] getVersions();
|
||||
public native String[] getCiphers();
|
||||
public native String[] getDigests();
|
||||
public native String[] getMacs();
|
||||
public native String[] getSignAlgorithms();
|
||||
public native String[] getPublicKeyEncryptions();
|
||||
public native String[] getDeriveKeyAlgorithms();
|
||||
public native byte[] generateRandom(int length);
|
||||
public native int getCipherIVLength(String cipher);
|
||||
public native int getCipherKeyLength(String cipher);
|
||||
public native int getCipherBlockSize(String cipher);
|
||||
public native byte [] symmetricEncrypt(String cipher, int flag, byte [] in, byte [] key, byte [] iv);
|
||||
public native byte [] symmetricDecrypt(String cipher, int flag, byte [] in, byte [] key, byte [] iv);
|
||||
public native String [] getDigests(boolean aliases);
|
||||
public native int getDigestLength(String digestAlgor);
|
||||
public native int getDigestBlockSize(String digestAlgor);
|
||||
public native byte [] digest(String algor, int flag, byte [] data);
|
||||
public native String [] getMacs(boolean aliases);
|
||||
public native String [] getMacLength(String algor);
|
||||
public native byte [] mac(String algor, int flag, byte [] data, byte [] key);
|
||||
public native String [] getSignAlgorithms(boolean aliases);
|
||||
public native byte [] sign(String algor, int flag, byte [] data, byte [] privateKey);
|
||||
public native int verify(String algor, int flag, byte [] digest, byte [] signature, byte [] publicKey);
|
||||
public native String [] getPublicKeyEncryptions(boolean aliases);
|
||||
public native byte [] publicKeyEncrypt(String algor, int flag, byte [] in, byte [] publicKey);
|
||||
public native byte [] publicKeyDecrypt(String algor, int falg, byte [] in, byte [] privateKey);
|
||||
public native String [] getDeriveKeyAlgorithms(boolean aliases);
|
||||
public native byte [] deriveKey(String algor, int flag, int keyLength, byte [] peerPublicKey, byte [] privateKey);
|
||||
public native String getErrorString();
|
||||
public native byte[] symmetricEncrypt(String cipher, byte[] in, byte[] key, byte[] iv);
|
||||
public native byte[] symmetricDecrypt(String cipher, byte[] in, byte[] key, byte[] iv);
|
||||
public native int getDigestLength(String digest);
|
||||
public native int getDigestBlockSize(String digest);
|
||||
public native byte[] digest(String algor, byte[] data);
|
||||
public native String[] getMacLength(String algor);
|
||||
public native byte[] mac(String algor, byte[] data, byte[] key);
|
||||
public native byte[] sign(String algor, byte[] data, byte[] privateKey);
|
||||
public native int verify(String algor, byte[] digest, byte[] signature, byte[] publicKey);
|
||||
public native byte[] publicKeyEncrypt(String algor, byte[] in, byte[] publicKey);
|
||||
public native byte[] publicKeyDecrypt(String algor, byte[] in, byte[] privateKey);
|
||||
public native byte[] deriveKey(String algor, int keyLength, byte[] peerPublicKey, byte[] privateKey);
|
||||
public native String[] getErrorStrings();
|
||||
|
||||
public static void main(String[] args) {
|
||||
int i;
|
||||
final GmSSL gmssl = new GmSSL();
|
||||
System.out.println(gmssl.getVersion(0));
|
||||
System.out.println("IV length = " + gmssl.getCipherIVLength("aes-128-cbc"));
|
||||
|
||||
/* GmSSL versions */
|
||||
String[] versions = gmssl.getVersions();
|
||||
for (i = 0; i < versions.length; i++) {
|
||||
System.out.println(versions[i]);
|
||||
}
|
||||
|
||||
/* Supported algorithms */
|
||||
System.out.print("Ciphers: ");
|
||||
String[] ciphers = gmssl.getCiphers();
|
||||
for (i = 0; i < ciphers.length - 1; i++) {
|
||||
System.out.print(ciphers[i] + ", ");
|
||||
}
|
||||
System.out.println(ciphers[i]);
|
||||
|
||||
System.out.print("Digests: ");
|
||||
String[] digests = gmssl.getDigests();
|
||||
for (i = 0; i < digests.length - 1; i++) {
|
||||
System.out.print(digests[i] + ", ");
|
||||
}
|
||||
System.out.println(digests[i]);
|
||||
|
||||
System.out.print("MACs: ");
|
||||
String[] macs = gmssl.getMacs();
|
||||
for (i = 0; i < macs.length - 1; i++) {
|
||||
System.out.print(macs[i] + ", ");
|
||||
}
|
||||
System.out.println(macs[i]);
|
||||
|
||||
System.out.print("SignAlgorithms: ");
|
||||
String[] signAlgors = gmssl.getSignAlgorithms();
|
||||
for (i = 0; i < signAlgors.length - 1; i++) {
|
||||
System.out.print(signAlgors[i] + ", ");
|
||||
}
|
||||
System.out.println(signAlgors[i]);
|
||||
|
||||
System.out.print("PublicKeyEncryptions: ");
|
||||
String[] encAlgors = gmssl.getPublicKeyEncryptions();
|
||||
for (i = 0; i < encAlgors.length - 1; i++) {
|
||||
System.out.print(encAlgors[i] + ", ");
|
||||
}
|
||||
System.out.println(encAlgors[i]);
|
||||
|
||||
System.out.print("DeriveKeyAlgorithms: ");
|
||||
String[] kdfs = gmssl.getDeriveKeyAlgorithms();
|
||||
for (i = 0; i < kdfs.length - 1; i++) {
|
||||
System.out.print(kdfs[i] + ", ");
|
||||
}
|
||||
System.out.println(kdfs[i]);
|
||||
|
||||
/* Crypto operations */
|
||||
System.out.print("Random(20) = ");
|
||||
byte[] data = gmssl.generateRandom(20);
|
||||
for (i = 0; i < data.length; i++) {
|
||||
System.out.printf("%02X", data[i]);
|
||||
}
|
||||
System.out.println("");
|
||||
|
||||
System.out.printf("SMS4 IV length = %d bytes, key length = %d bytes, block size = %d bytes\n",
|
||||
gmssl.getCipherIVLength("SMS4"),
|
||||
gmssl.getCipherKeyLength("SMS4"),
|
||||
gmssl.getCipherBlockSize("SMS4"));
|
||||
|
||||
byte[] key = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
|
||||
byte[] iv = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
|
||||
byte[] ciphertext = gmssl.symmetricEncrypt("SMS4", "01234567".getBytes(), key, iv);
|
||||
|
||||
System.out.print("Ciphertext: ");
|
||||
for (i = 0; i < ciphertext.length; i++) {
|
||||
System.out.printf("%02X", ciphertext[i]);
|
||||
}
|
||||
System.out.println("");
|
||||
|
||||
byte[] plaintext = gmssl.symmetricDecrypt("sms4", ciphertext, key, iv);
|
||||
|
||||
System.out.print("Plaintext: ");
|
||||
for (i = 0; i < plaintext.length; i++) {
|
||||
System.out.printf("%02X", plaintext[i]);
|
||||
}
|
||||
System.out.println("");
|
||||
|
||||
byte[] dgst = gmssl.digest("SM3", "abc".getBytes());
|
||||
System.out.print("SM3(\"abc\") = ");
|
||||
for (i = 0; i < dgst.length; i++) {
|
||||
System.out.printf("%02X", dgst[i]);
|
||||
}
|
||||
System.out.println("");
|
||||
|
||||
byte[] macTag = gmssl.mac("HMAC-SM3", "abc".getBytes(), "password".getBytes());
|
||||
System.out.print("HMAC-SM3(\"abc\") = ");
|
||||
for (i = 0; i < macTag.length; i++) {
|
||||
System.out.printf("%02X", macTag[i]);
|
||||
}
|
||||
System.out.println("");
|
||||
|
||||
byte[] sm2PrivateKey = new byte[] {
|
||||
(byte)0x30,(byte)0x77,(byte)0x02,(byte)0x01,(byte)0x01,(byte)0x04,(byte)0x20,(byte)0x28,
|
||||
(byte)0x7d,(byte)0x3f,(byte)0xb9,(byte)0xf4,(byte)0xbb,(byte)0xc8,(byte)0xbd,(byte)0xe1,
|
||||
(byte)0x54,(byte)0x75,(byte)0x87,(byte)0x9f,(byte)0x08,(byte)0x61,(byte)0x20,(byte)0xe3,
|
||||
(byte)0x65,(byte)0xf8,(byte)0xb2,(byte)0xca,(byte)0x14,(byte)0x26,(byte)0x81,(byte)0xf6,
|
||||
(byte)0x1e,(byte)0xd8,(byte)0x7f,(byte)0xc0,(byte)0x66,(byte)0x20,(byte)0x29,(byte)0xa0,
|
||||
(byte)0x0a,(byte)0x06,(byte)0x08,(byte)0x2a,(byte)0x81,(byte)0x1c,(byte)0xcf,(byte)0x55,
|
||||
(byte)0x01,(byte)0x82,(byte)0x2d,(byte)0xa1,(byte)0x44,(byte)0x03,(byte)0x42,(byte)0x00,
|
||||
(byte)0x04,(byte)0xb1,(byte)0x1e,(byte)0x4c,(byte)0x8c,(byte)0xa9,(byte)0x02,(byte)0xf2,
|
||||
(byte)0x8d,(byte)0x8b,(byte)0x98,(byte)0xd2,(byte)0xd0,(byte)0xc4,(byte)0xf1,(byte)0x60,
|
||||
(byte)0x91,(byte)0xfb,(byte)0x61,(byte)0x62,(byte)0x00,(byte)0xcf,(byte)0x93,(byte)0x4e,
|
||||
(byte)0x3f,(byte)0xca,(byte)0xfd,(byte)0xf7,(byte)0x9d,(byte)0x76,(byte)0xb8,(byte)0x2b,
|
||||
(byte)0xb3,(byte)0x30,(byte)0x98,(byte)0x65,(byte)0xf5,(byte)0x12,(byte)0xab,(byte)0x45,
|
||||
(byte)0x78,(byte)0x29,(byte)0x87,(byte)0xdc,(byte)0x74,(byte)0x07,(byte)0x75,(byte)0xd0,
|
||||
(byte)0x68,(byte)0xad,(byte)0x85,(byte)0x71,(byte)0x08,(byte)0xc2,(byte)0x19,(byte)0xf0,
|
||||
(byte)0xf4,(byte)0xca,(byte)0x6e,(byte)0xe1,(byte)0xea,(byte)0x86,(byte)0xe6,(byte)0x21,
|
||||
(byte)0x76};
|
||||
|
||||
byte[] sm2PublicKey = new byte[] {
|
||||
(byte)0x30,(byte)0x59,(byte)0x30,(byte)0x13,(byte)0x06,(byte)0x07,(byte)0x2a,(byte)0x86,
|
||||
(byte)0x48,(byte)0xce,(byte)0x3d,(byte)0x02,(byte)0x01,(byte)0x06,(byte)0x08,(byte)0x2a,
|
||||
(byte)0x81,(byte)0x1c,(byte)0xcf,(byte)0x55,(byte)0x01,(byte)0x82,(byte)0x2d,(byte)0x03,
|
||||
(byte)0x42,(byte)0x00,(byte)0x04,(byte)0xb1,(byte)0x1e,(byte)0x4c,(byte)0x8c,(byte)0xa9,
|
||||
(byte)0x02,(byte)0xf2,(byte)0x8d,(byte)0x8b,(byte)0x98,(byte)0xd2,(byte)0xd0,(byte)0xc4,
|
||||
(byte)0xf1,(byte)0x60,(byte)0x91,(byte)0xfb,(byte)0x61,(byte)0x62,(byte)0x00,(byte)0xcf,
|
||||
(byte)0x93,(byte)0x4e,(byte)0x3f,(byte)0xca,(byte)0xfd,(byte)0xf7,(byte)0x9d,(byte)0x76,
|
||||
(byte)0xb8,(byte)0x2b,(byte)0xb3,(byte)0x30,(byte)0x98,(byte)0x65,(byte)0xf5,(byte)0x12,
|
||||
(byte)0xab,(byte)0x45,(byte)0x78,(byte)0x29,(byte)0x87,(byte)0xdc,(byte)0x74,(byte)0x07,
|
||||
(byte)0x75,(byte)0xd0,(byte)0x68,(byte)0xad,(byte)0x85,(byte)0x71,(byte)0x08,(byte)0xc2,
|
||||
(byte)0x19,(byte)0xf0,(byte)0xf4,(byte)0xca,(byte)0x6e,(byte)0xe1,(byte)0xea,(byte)0x86,
|
||||
(byte)0xe6,(byte)0x21,(byte)0x76};
|
||||
|
||||
byte[] sig = gmssl.sign("sm2sign", dgst, sm2PrivateKey);
|
||||
System.out.print("SM2 Signature : ");
|
||||
for (i = 0; i < sig.length; i++) {
|
||||
System.out.printf("%02X", sig[i]);
|
||||
}
|
||||
System.out.print("\n");
|
||||
|
||||
int vret = gmssl.verify("sm2sign", dgst, sig, sm2PublicKey);
|
||||
System.out.println("Verification result = " + vret);
|
||||
|
||||
byte[] sm2Ciphertext = gmssl.publicKeyEncrypt("sm2encrypt-with-sm3", dgst, sm2PublicKey);
|
||||
System.out.print("SM2 Ciphertext : ");
|
||||
for (i = 0; i < sm2Ciphertext.length; i++) {
|
||||
System.out.printf("%02X", sm2Ciphertext[i]);
|
||||
}
|
||||
System.out.print("\n");
|
||||
|
||||
byte[] sm2Plaintext = gmssl.publicKeyDecrypt("sm2encrypt-with-sm3", sm2Ciphertext, sm2PrivateKey);
|
||||
System.out.print("SM2 Plaintext : ");
|
||||
for (i = 0; i < sm2Plaintext.length; i++) {
|
||||
System.out.printf("%02X", sm2Plaintext[i]);
|
||||
}
|
||||
System.out.print("\n");
|
||||
|
||||
/* Errors */
|
||||
System.out.println("Errors:");
|
||||
String[] errors = gmssl.getErrorStrings();
|
||||
for (i = 0; i < errors.length; i++) {
|
||||
System.out.println(errors[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("gmssl");
|
||||
System.loadLibrary("gmssljni");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# GmSSL Java Wrapper
|
||||
|
||||
The purpose of this module is to provide a simple Java API to access GmSSL crypto library. To be simple, no key schedule or context is used. So the functions will not be very efficient for processing large files or stream data. And this module is not intend to be integrated with Java crypto frameworks such
|
||||
as JCE.
|
||||
|
||||
The implementation is based on the Java Native Interface (JNI). The JNI header files are also included, but you can replace them with version from you own compiling environment.
|
||||
|
||||
109
java/SOF.java
109
java/SOF.java
@@ -1,109 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2015 - 2017 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
public class SOF {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//public native long initCertAppPolicy(String PolicyName);
|
||||
|
||||
|
||||
public native boolean getCertTrustList(String ctlAltName, String ctlContent);
|
||||
public native String getCertTrustListAltNames();
|
||||
public native String getCertTrustList(String ctrlAltName);
|
||||
public native long delCertTrustList(String ctlAltName);
|
||||
public native String getInstance(String policyName);
|
||||
public native long setSignMethod(long SignMethod);
|
||||
public native long getSignMethod();
|
||||
public native long setEncryptMethod(long EncryptMethod);
|
||||
public native long getEncryptMethod();
|
||||
public native getServerCertificate();
|
||||
public native getServerCertificateByUsage(short certUsage);
|
||||
public native String genRandom(short randomLen);
|
||||
public native String getCertInfo(String base64EncodeCert, int type);
|
||||
public native String getCertInfoByOid(String base64EncodeCert, String oid);
|
||||
public native long validateCert(String base64EncodeCert);
|
||||
public native String signData(byte [] inData);
|
||||
public native boolean verifySignedData(String Base64EncodeCert, String InData, String SignValue);
|
||||
public native String signFile(String ContainerName, String InFile);
|
||||
public native boolean verifySignedFile(String Base64EncodeCert, String InFile, String SignValue);
|
||||
public native String encryptData(String Base64EncodeCert, String InData);
|
||||
public native String decryptData(String ContainerName, String InData);
|
||||
public native boolean encryptFile(String Base64EncodeCert, String InFile, String OutFile);
|
||||
public native boolean decryptFile(String ContainerName, String InFile, String OutFile);
|
||||
public native String signMessage(short flag, String ContainerName, String InData);
|
||||
public native boolean verifySignedMessage(String MessageData, String InData);
|
||||
public native String getInfoFromSignedMessage(String SignedMessage, short Type);
|
||||
public native boolean signMessageDetach();
|
||||
public native boolean verifySignedMessageDetach();
|
||||
public native String signDataXML(String ContainerName, String InData);
|
||||
public native boolean verifySignedDataXML(String InData);
|
||||
public native String getXMLSignatureInfo(String XMLSignedData, short Type);
|
||||
public native String createTimeStampRequest(String InData);
|
||||
public native String createTimeStampResponse(String TimeStampRequest);
|
||||
public native long verifyTimeStamp(String InData, String tsResponseData);
|
||||
public native String getTimeStampInfo(String tsResponseData, short type);
|
||||
public native long getLastError(void);
|
||||
|
||||
public static void main(String[] args) {
|
||||
final GmSSL gmssl = new GmSSL();
|
||||
System.out.println(gmssl.getVersion(0));
|
||||
System.out.println("IV length = " + gmssl.getCipherIVLength("aes-128-cbc"));
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("gmsof");
|
||||
}
|
||||
}
|
||||
|
||||
4
java/build.info
Normal file
4
java/build.info
Normal file
@@ -0,0 +1,4 @@
|
||||
LIBS=../libgmssljni
|
||||
SOURCE[../libgmssljni]=GmSSL.c
|
||||
DEPEND[../libgmssljni]=../libcrypto
|
||||
INCLUDE[../libgmssljni]=../include ./jni
|
||||
138
java/gmssl_err.c
Normal file
138
java/gmssl_err.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2017 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 <openssl/err.h>
|
||||
#include "gmssl_err.h"
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
# define ERR_FUNC(func) ERR_PACK(0,func,0)
|
||||
# define ERR_REASON(reason) ERR_PACK(0,0,reason)
|
||||
|
||||
static ERR_STRING_DATA JNI_str_functs[] = {
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_DERIVEKEY), "Java_GmSSL_deriveKey"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_DIGEST), "Java_GmSSL_digest"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GENERATERANDOM), "Java_GmSSL_generateRandom"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETCIPHERBLOCKSIZE),
|
||||
"Java_GmSSL_getCipherBlockSize"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETCIPHERIVLENGTH),
|
||||
"Java_GmSSL_getCipherIVLength"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETCIPHERKEYLENGTH),
|
||||
"Java_GmSSL_getCipherKeyLength"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETCIPHERS), "Java_GmSSL_getCiphers"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETDERIVEKEYALGORITHMS),
|
||||
"Java_GmSSL_getDeriveKeyAlgorithms"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETDIGESTBLOCKSIZE),
|
||||
"Java_GmSSL_getDigestBlockSize"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETDIGESTLENGTH),
|
||||
"Java_GmSSL_getDigestLength"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETDIGESTS), "Java_GmSSL_getDigests"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETERRORSTRINGS),
|
||||
"Java_GmSSL_getErrorStrings"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETMACS), "Java_GmSSL_getMacs"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETPUBLICKEYENCRYPTIONS),
|
||||
"Java_GmSSL_getPublicKeyEncryptions"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETSIGNALGORITHMS),
|
||||
"Java_GmSSL_getSignAlgorithms"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_GETVERSIONS), "Java_GmSSL_getVersions"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_MAC), "Java_GmSSL_mac"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_PUBLICKEYDECRYPT),
|
||||
"Java_GmSSL_publicKeyDecrypt"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_PUBLICKEYENCRYPT),
|
||||
"Java_GmSSL_publicKeyEncrypt"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_SIGN), "Java_GmSSL_sign"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_SYMMETRICDECRYPT),
|
||||
"Java_GmSSL_symmetricDecrypt"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_SYMMETRICENCRYPT),
|
||||
"Java_GmSSL_symmetricEncrypt"},
|
||||
{ERR_FUNC(JNI_F_JAVA_GMSSL_VERIFY), "Java_GmSSL_verify"},
|
||||
{ERR_FUNC(JNI_F_PRINT_ERRORS_CB), "print_errors_cb"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static ERR_STRING_DATA JNI_str_reasons[] = {
|
||||
{ERR_REASON(JNI_R_BAD_ARGUMENT), "bad argument"},
|
||||
{ERR_REASON(JNI_R_CMAC_ERROR), "cmac error"},
|
||||
{ERR_REASON(JNI_R_ERRORS_STACK_ERROR), "errors stack error"},
|
||||
{ERR_REASON(JNI_R_GMSSL_RNG_ERROR), "gmssl rng error"},
|
||||
{ERR_REASON(JNI_R_HMAC_ERROR), "hmac error"},
|
||||
{ERR_REASON(JNI_R_INVALID_CIPHER), "invalid cipher"},
|
||||
{ERR_REASON(JNI_R_INVALID_DERIVE_KEY_ALGOR), "invalid derive key algor"},
|
||||
{ERR_REASON(JNI_R_INVALID_DIGEST), "invalid digest"},
|
||||
{ERR_REASON(JNI_R_INVALID_IV_LENGTH), "invalid iv length"},
|
||||
{ERR_REASON(JNI_R_INVALID_KEY_LENGTH), "invalid key length"},
|
||||
{ERR_REASON(JNI_R_INVALID_LENGTH), "invalid length"},
|
||||
{ERR_REASON(JNI_R_INVALID_PRIVATE_KEY), "invalid private key"},
|
||||
{ERR_REASON(JNI_R_INVALID_PUBLIC_KEY), "invalid public key"},
|
||||
{ERR_REASON(JNI_R_INVALID_PUBLIC_KEY_ENCRYPTION_ALGOR),
|
||||
"invalid public key encryption algor"},
|
||||
{ERR_REASON(JNI_R_INVALID_SIGN_ALGOR), "invalid sign algor"},
|
||||
{ERR_REASON(JNI_R_IV_LENGTH), "iv length"},
|
||||
{ERR_REASON(JNI_R_JNI_MALLOC_FAILURE), "jni malloc failure"},
|
||||
{ERR_REASON(JNI_R_KEY_LENGTH), "key length"},
|
||||
{ERR_REASON(JNI_R_NONSUPPORTED_CIPHER), "nonsupported cipher"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef JNI_LIB_NAME
|
||||
static ERR_STRING_DATA JNI_lib_name[] = {
|
||||
{0, JNI_LIB_NAME},
|
||||
{0, NULL}
|
||||
};
|
||||
#endif
|
||||
|
||||
static int JNI_lib_error_code = 0;
|
||||
static int JNI_error_init = 1;
|
||||
|
||||
static int ERR_load_JNI_strings(void)
|
||||
{
|
||||
if (JNI_lib_error_code == 0)
|
||||
JNI_lib_error_code = ERR_get_next_error_library();
|
||||
|
||||
if (JNI_error_init) {
|
||||
JNI_error_init = 0;
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
ERR_load_strings(JNI_lib_error_code, JNI_str_functs);
|
||||
ERR_load_strings(JNI_lib_error_code, JNI_str_reasons);
|
||||
#endif
|
||||
|
||||
#ifdef JNI_LIB_NAME
|
||||
JNI_lib_name->error = ERR_PACK(JNI_lib_error_code, 0, 0);
|
||||
ERR_load_strings(0, JNI_lib_name);
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ERR_unload_JNI_strings(void)
|
||||
{
|
||||
if (JNI_error_init == 0) {
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
ERR_unload_strings(JNI_lib_error_code, JNI_str_functs);
|
||||
ERR_unload_strings(JNI_lib_error_code, JNI_str_reasons);
|
||||
#endif
|
||||
|
||||
#ifdef JNI_LIB_NAME
|
||||
ERR_unload_strings(0, JNI_lib_name);
|
||||
#endif
|
||||
JNI_error_init = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void ERR_JNI_error(int function, int reason, char *file, int line)
|
||||
{
|
||||
if (JNI_lib_error_code == 0)
|
||||
JNI_lib_error_code = ERR_get_next_error_library();
|
||||
ERR_PUT_error(JNI_lib_error_code, function, reason, file, line);
|
||||
}
|
||||
71
java/gmssl_err.h
Normal file
71
java/gmssl_err.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef HEADER_JNI_ERR_H
|
||||
# define HEADER_JNI_ERR_H
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
static int ERR_load_JNI_strings(void);
|
||||
static void ERR_unload_JNI_strings(void);
|
||||
static void ERR_JNI_error(int function, int reason, char *file, int line);
|
||||
# define JNIerr(f,r) ERR_JNI_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
|
||||
/* Error codes for the JNI functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define JNI_F_JAVA_GMSSL_DERIVEKEY 100
|
||||
# define JNI_F_JAVA_GMSSL_DIGEST 101
|
||||
# define JNI_F_JAVA_GMSSL_GENERATERANDOM 102
|
||||
# define JNI_F_JAVA_GMSSL_GETCIPHERBLOCKSIZE 103
|
||||
# define JNI_F_JAVA_GMSSL_GETCIPHERIVLENGTH 104
|
||||
# define JNI_F_JAVA_GMSSL_GETCIPHERKEYLENGTH 105
|
||||
# define JNI_F_JAVA_GMSSL_GETCIPHERS 106
|
||||
# define JNI_F_JAVA_GMSSL_GETDERIVEKEYALGORITHMS 107
|
||||
# define JNI_F_JAVA_GMSSL_GETDIGESTBLOCKSIZE 108
|
||||
# define JNI_F_JAVA_GMSSL_GETDIGESTLENGTH 109
|
||||
# define JNI_F_JAVA_GMSSL_GETDIGESTS 110
|
||||
# define JNI_F_JAVA_GMSSL_GETERRORSTRINGS 111
|
||||
# define JNI_F_JAVA_GMSSL_GETMACS 112
|
||||
# define JNI_F_JAVA_GMSSL_GETPUBLICKEYENCRYPTIONS 113
|
||||
# define JNI_F_JAVA_GMSSL_GETSIGNALGORITHMS 114
|
||||
# define JNI_F_JAVA_GMSSL_GETVERSIONS 115
|
||||
# define JNI_F_JAVA_GMSSL_MAC 116
|
||||
# define JNI_F_JAVA_GMSSL_PUBLICKEYDECRYPT 117
|
||||
# define JNI_F_JAVA_GMSSL_PUBLICKEYENCRYPT 118
|
||||
# define JNI_F_JAVA_GMSSL_SIGN 119
|
||||
# define JNI_F_JAVA_GMSSL_SYMMETRICDECRYPT 120
|
||||
# define JNI_F_JAVA_GMSSL_SYMMETRICENCRYPT 121
|
||||
# define JNI_F_JAVA_GMSSL_VERIFY 122
|
||||
# define JNI_F_PRINT_ERRORS_CB 123
|
||||
|
||||
/* Reason codes. */
|
||||
# define JNI_R_BAD_ARGUMENT 100
|
||||
# define JNI_R_CMAC_ERROR 114
|
||||
# define JNI_R_ERRORS_STACK_ERROR 101
|
||||
# define JNI_R_GMSSL_RNG_ERROR 102
|
||||
# define JNI_R_HMAC_ERROR 115
|
||||
# define JNI_R_INVALID_CIPHER 103
|
||||
# define JNI_R_INVALID_DERIVE_KEY_ALGOR 118
|
||||
# define JNI_R_INVALID_DIGEST 104
|
||||
# define JNI_R_INVALID_IV_LENGTH 105
|
||||
# define JNI_R_INVALID_KEY_LENGTH 106
|
||||
# define JNI_R_INVALID_LENGTH 107
|
||||
# define JNI_R_INVALID_PRIVATE_KEY 108
|
||||
# define JNI_R_INVALID_PUBLIC_KEY 109
|
||||
# define JNI_R_INVALID_PUBLIC_KEY_ENCRYPTION_ALGOR 117
|
||||
# define JNI_R_INVALID_SIGN_ALGOR 116
|
||||
# define JNI_R_IV_LENGTH 110
|
||||
# define JNI_R_JNI_MALLOC_FAILURE 111
|
||||
# define JNI_R_KEY_LENGTH 112
|
||||
# define JNI_R_NONSUPPORTED_CIPHER 113
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user