添加测试
This commit is contained in:
parent
758a4ea116
commit
56eb803514
@ -42,12 +42,7 @@ public class TestCertUtil {
|
||||
@Test
|
||||
public void case3() throws CertificateException, NoSuchProviderException {
|
||||
|
||||
// 此证书是错误的
|
||||
try {
|
||||
CertUtil.isSM2Cert(readCert("/x509/c3.crt"));
|
||||
} catch ( CertificateException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
CertUtil.isSM2Cert(readCert("/x509/c3.crt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
44
src/test/java/sample/TestDE.java
Normal file
44
src/test/java/sample/TestDE.java
Normal file
@ -0,0 +1,44 @@
|
||||
package sample;
|
||||
|
||||
import com.sunyard.RetWrap;
|
||||
import com.sunyard.SydApi;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
public class TestDE {
|
||||
|
||||
// private static final String ip = "172.16.17.161";
|
||||
private static final String ip = "192.168.1.156";
|
||||
private static final String rsa = "C=CN,O=sunyard,OU=rsa,CN=javaRsa";
|
||||
private SydApi api;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||
api = new SydApi4j().connect(ip, 8889, null, 5000);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
if (null != api) {
|
||||
api.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void de4K_rsa_aes() {
|
||||
byte[] data = new byte[3 * 1024];
|
||||
RetWrap ret = api.generateDEByDn(0, rsa, data);
|
||||
byte[] cipherKey = (byte[]) ret.get(SydApi.RET_CIPHER_KEY);
|
||||
|
||||
System.out.println("cipherKey=" + new String(cipherKey));
|
||||
|
||||
ret = api.decryptDEByDN(0, rsa, cipherKey);
|
||||
byte[] oData = (byte[]) ret.get("oData");
|
||||
|
||||
Assert.assertArrayEquals(data, oData);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user