调整协议,index 改为 4 字节。

This commit is contained in:
cheney 2026-06-01 10:02:49 +08:00
parent 12bdac2d7c
commit 882e84320c
2 changed files with 1179 additions and 1429 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
package cmbpoc;
import com.sunyard.RetWrap;
import com.sunyard.proto.Util;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import racal.sunyard.main.SydApi4j;
public class FunctionTest {
@ -22,7 +20,7 @@ public class FunctionTest {
System.setProperty("com.sunyard.sydapi4j.debug", "true");
// 建立链接单台
this.api = (SydApi4j) new SydApi4j().connect("192.168.0.100", 8889, null, 1000);
this.api = (SydApi4j) new SydApi4j().connect("192.168.21.166", 8889, null, 1000);
}
@ -37,13 +35,29 @@ public class FunctionTest {
@Ignore
@Test
public void genKeyPair(){
RetWrap r = this.api.SYD_SM2GenKeyPair();
String pk = r.get("publicKey").toString();
String sk = r.get("privateKey").toString();
System.out.println("pk=" + pk);
System.out.println("sk=" + sk);
this.privateKey = Util.hexString2Bytes(sk);
this.publicKey = Util.hexString2Bytes(pk);
}
@Ignore
@Test
public void getPrivateKeyAndPublickKey(){
this.publicKey = Util.hexString2Bytes(
this.api.SM2GetPublicKeyC(keypairIndex)
);
this.privateKey = Util.hexString2Bytes(
this.api.SM2GetPrivateKeyC(keypairIndex)
);
@ -61,7 +75,7 @@ public class FunctionTest {
@Test
public void SYD_SM2_Encrypt(){
byte[] enData = this.api.SYD_SM2_Encrypt(publicKey, orgData);
byte[] enData = this.api.SYD_SM2Encrypt(publicKey, orgData);
byte[] deData = this.api.SYD_SM2Decrypt(privateKey, enData);
Assert.assertArrayEquals(enData, deData);
}