cms decrypt iv
1. 数字信封解封时使用数字信封中的 IV
2. 数字信封解封格式错误时抛出异常 IllegalArgumentException("数字信封解封格式错误")
This commit is contained in:
@@ -5,11 +5,13 @@ import com.sunyard.SydApi;
|
||||
import com.sunyard.cert.X509;
|
||||
import com.sunyard.proto.Util;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
@@ -179,6 +181,7 @@ public class TestHT {
|
||||
byte[] sign = api.attachedSignC(orgData, dn);
|
||||
System.out.println("签名结果: " + sign);
|
||||
|
||||
|
||||
RetWrap verify = api.attachedVerifyAndGetAll(sign);
|
||||
if (verify != null) {
|
||||
System.out.println("x509公钥: " + Util.bytes2HexString(((X509)verify.get("x509")).getPubKey()));
|
||||
@@ -186,6 +189,39 @@ public class TestHT {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecryptDE54k12() throws UnsupportedEncodingException {
|
||||
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
byte[] oData = new byte[ 4 * 1024 ];
|
||||
|
||||
RetWrap retWrap = api.generateDEByDnHsm(dn, oData);
|
||||
byte[] CipherKey = (byte[]) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||
byte[] sessionKey = (byte[]) retWrap.get(SydApi.RET_SESSION_KEY);
|
||||
printRetWrap(retWrap);
|
||||
|
||||
RetWrap retWrap1 = api.decryptDEByDNSoft(dn, new String(CipherKey));
|
||||
printRetWrap(retWrap1);
|
||||
byte[] deData = (byte[]) retWrap1.get("oData");
|
||||
Assert.assertArrayEquals( deData, oData );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecryptDE54k21() throws UnsupportedEncodingException {
|
||||
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
byte[] oData = new byte[ 4 * 1024 ];
|
||||
|
||||
RetWrap retWrap = api.generateDEByDnSoft(dn, oData);
|
||||
byte[] CipherKey = (byte[]) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||
byte[] sessionKey = (byte[]) retWrap.get(SydApi.RET_SESSION_KEY);
|
||||
printRetWrap(retWrap);
|
||||
|
||||
RetWrap retWrap1 = api.decryptDEByDNHsm(dn, new String(CipherKey));
|
||||
printRetWrap(retWrap1);
|
||||
byte[] deData = (byte[]) retWrap1.get("oData");
|
||||
Assert.assertArrayEquals( deData, oData );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDecryptDE54k() throws UnsupportedEncodingException {
|
||||
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||
|
||||
Reference in New Issue
Block a user