添加6A、6B关于P7的数字信封

This commit is contained in:
zb
2022-04-12 20:54:20 +08:00
parent b20bb8f2b0
commit b4bdf191de
9 changed files with 458 additions and 68 deletions
@@ -1353,8 +1353,7 @@ public class TestAllMethods {
String sessionKey = (String) retWrap.get("SessionKey");
String CipherKey = (String) retWrap.get("CipherKey");
String KCV = (String) retWrap.get("KCV");
System.out.println("CipherKey: " + CipherKey);
printRetWrap(retWrap);
RetWrap retWrap1 = api.decryptDE(sn, CipherKey);
sessionKey = (String) retWrap1.get("SessionKey");
@@ -1365,8 +1364,8 @@ public class TestAllMethods {
// 6B
@Test
public void testDecryptDE2() {
// String sn = "1004282452";
String sn = "1FD9F2049860FD072F0CC71B072EBF9952E2784E";
String sn = "1004282452";
// String sn = "1FD9F2049860FD072F0CC71B072EBF9952E2784E";
RetWrap retWrap = api.generateDE(sn, SydApi.ALG_SM4);
String CipherKey = (String) retWrap.get("CipherKey");
printRetWrap(retWrap);
@@ -1426,6 +1425,20 @@ public class TestAllMethods {
printRetWrap(retWrap1);
}
@Test
public void testDecryptDE5() throws UnsupportedEncodingException {
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
String oData = "00001111222233";
RetWrap retWrap = api.generateDEByDn(dn.getBytes("gbk"), oData);
String CipherKey = (String) retWrap.get(SydApi.RET_CIPHER_KEY);
String sessionKey = (String) retWrap.get(SydApi.RET_SESSION_KEY);
printRetWrap(retWrap);
RetWrap retWrap1 = api.decryptDEByDN(dn.getBytes("gbk"), CipherKey);
printRetWrap(retWrap1);
}
// 测试通过
// 6C
@Test
@@ -9,6 +9,11 @@ import org.junit.Before;
import org.junit.Test;
import racal.sunyard.main.SydApi4j;
import java.io.UnsupportedEncodingException;
import java.util.Base64;
import static com.sunyard.sydapi.util.PrintUtil.printRetWrap;
/**
* 衡泰例子
*/
@@ -71,7 +76,7 @@ public class TestHT {
// 8018
@Test
public void testAttachedSignAndVerify() {
String dn = "C=CN,O=Sunyard,OU=8001,CN=8001";
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
String orgData = "111111213323143243243";
String sign = api.attachedSign(orgData.getBytes(), dn);
System.out.println("签名结果: " + sign);
@@ -82,7 +87,7 @@ public class TestHT {
@Test
public void testAttachedSignAndVerifyGetX509() {
String dn = "C=CN,O=Sunyard,OU=8001,CN=8001";
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
String orgData = "111111213323143243243";
String sign = api.attachedSign(orgData.getBytes(), dn);
System.out.println("签名结果: " + sign);
@@ -93,7 +98,7 @@ public class TestHT {
@Test
public void testAttachedSignAndVerifyRD() {
String dn = "C=CN,O=Sunyard,OU=8001,CN=8001";
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
String orgData = "111111213323143243243";
String sign = api.attachedSign(orgData.getBytes(), dn);
System.out.println("签名结果: " + sign);
@@ -104,7 +109,7 @@ public class TestHT {
@Test
public void testAttachedSignAndVerifyGetAll() {
String dn = "C=CN,O=Sunyard,OU=8001,CN=8001";
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
String orgData = "111111213323143243243";
String sign = api.attachedSign(orgData.getBytes(), dn);
System.out.println("签名结果: " + sign);
@@ -116,6 +121,20 @@ public class TestHT {
}
}
@Test
public void testDecryptDE5() throws UnsupportedEncodingException {
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
String oData = "00001111222233";
RetWrap retWrap = api.generateDEByDn(dn.getBytes("gbk"), oData);
String CipherKey = (String) retWrap.get(SydApi.RET_CIPHER_KEY);
String sessionKey = (String) retWrap.get(SydApi.RET_SESSION_KEY);
printRetWrap(retWrap);
RetWrap retWrap1 = api.decryptDEByDN(dn.getBytes("gbk"), CipherKey);
printRetWrap(retWrap1);
}
// 测试通过
// 76
@Test