修改6A、6B接口的参数byte[]为String
This commit is contained in:
@@ -1430,12 +1430,12 @@ public class TestAllMethods {
|
||||
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);
|
||||
RetWrap retWrap = api.generateDEByDn(dn, 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);
|
||||
RetWrap retWrap1 = api.decryptDEByDN(dn, CipherKey);
|
||||
printRetWrap(retWrap1);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,13 +126,43 @@ public class TestHT {
|
||||
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 retWrap = api.generateDEByDn(dn, oData);
|
||||
String cipherKey = (String) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||
System.out.println("数字信封: " + cipherKey);
|
||||
|
||||
RetWrap retWrap1 = api.decryptDEByDN(dn, cipherKey);
|
||||
System.out.println("原数据: " + retWrap1.get("oData"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程演示
|
||||
*/
|
||||
@Test
|
||||
public void testProcess() {
|
||||
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);
|
||||
|
||||
// 生成数字信封
|
||||
RetWrap retWrap = api.generateDEByDn(dn, sign);
|
||||
String cipherKey = (String) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||
System.out.println("数字信封: " + cipherKey);
|
||||
|
||||
// 解密数字信封
|
||||
RetWrap retWrap1 = api.decryptDEByDN(dn, cipherKey);
|
||||
String oData = (String) retWrap1.get("oData");
|
||||
System.out.println("原数据: " + retWrap1.get("oData"));
|
||||
|
||||
// 验签
|
||||
RetWrap verify = api.attachedVerifyAndGetAll(oData);
|
||||
if (verify != null) {
|
||||
System.out.println("x509公钥: " + Util.bytes2HexString(((X509)verify.get("x509")).getPubKey()));
|
||||
System.out.println("签名原数据: " + verify.get("oData"));
|
||||
}
|
||||
|
||||
RetWrap retWrap1 = api.decryptDEByDN(dn.getBytes("gbk"), CipherKey);
|
||||
printRetWrap(retWrap1);
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
|
||||
Reference in New Issue
Block a user