修改6A、6B接口的参数byte[]为String
This commit is contained in:
parent
b4bdf191de
commit
8bb86fdb95
Binary file not shown.
@ -226,7 +226,7 @@ public interface SydGenApi {
|
|||||||
* SessionKey 本地LMK 加密的会话密钥,HEX 格式, 本地 LMK 加密的会话密钥长度,HEX 格式(不包括第 1 个字符),一般为 33 个 Bytes。默认输入值为缓冲区的大小。
|
* SessionKey 本地LMK 加密的会话密钥,HEX 格式, 本地 LMK 加密的会话密钥长度,HEX 格式(不包括第 1 个字符),一般为 33 个 Bytes。默认输入值为缓冲区的大小。
|
||||||
* KCV 会话密钥的检验值,HEX 格式,长度为 32H。
|
* KCV 会话密钥的检验值,HEX 格式,长度为 32H。
|
||||||
*/
|
*/
|
||||||
RetWrap generateDEByDn(byte[] certSerial, String oData);
|
RetWrap generateDEByDn(String certSerial, String oData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产生对称密钥,通过公钥加密生成网联格式的数字信封。
|
* 产生对称密钥,通过公钥加密生成网联格式的数字信封。
|
||||||
@ -308,7 +308,7 @@ public interface SydGenApi {
|
|||||||
* KCV 会话密钥的检验值,HEX 格式,长度为 36H。
|
* KCV 会话密钥的检验值,HEX 格式,长度为 36H。
|
||||||
* orgCode 如果有机构码的话会返回机构码
|
* orgCode 如果有机构码的话会返回机构码
|
||||||
*/
|
*/
|
||||||
RetWrap decryptDEByDN(byte[] certSerial, String pCipherKey);
|
RetWrap decryptDEByDN(String certSerial, String pCipherKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接收用私钥解密数字信封,还原对称密钥。
|
* 接收用私钥解密数字信封,还原对称密钥。
|
||||||
|
|||||||
@ -2194,8 +2194,14 @@ public class SydApi4j implements SydApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RetWrap generateDEByDn(byte[] certSerial, String oData) {
|
public RetWrap generateDEByDn(String certSerial, String oData) {
|
||||||
return generateDE(certSerial, 3, 1, oData);
|
byte[] dnBytes = null;
|
||||||
|
try {
|
||||||
|
dnBytes = certSerial.getBytes("gbk");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return generateDE(dnBytes, 3, 1, oData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2308,8 +2314,14 @@ public class SydApi4j implements SydApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RetWrap decryptDEByDN(byte[] certSerial, String pCipherKey) {
|
public RetWrap decryptDEByDN(String certSerial, String pCipherKey) {
|
||||||
return decryptDE(true, 1, certSerial, pCipherKey);
|
byte[] dnBytes = null;
|
||||||
|
try {
|
||||||
|
dnBytes = certSerial.getBytes("gbk");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return decryptDE(true, 1, dnBytes, pCipherKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试通过
|
// 测试通过
|
||||||
|
|||||||
@ -1430,12 +1430,12 @@ public class TestAllMethods {
|
|||||||
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||||
String oData = "00001111222233";
|
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 CipherKey = (String) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||||
String sessionKey = (String) retWrap.get(SydApi.RET_SESSION_KEY);
|
String sessionKey = (String) retWrap.get(SydApi.RET_SESSION_KEY);
|
||||||
printRetWrap(retWrap);
|
printRetWrap(retWrap);
|
||||||
|
|
||||||
RetWrap retWrap1 = api.decryptDEByDN(dn.getBytes("gbk"), CipherKey);
|
RetWrap retWrap1 = api.decryptDEByDN(dn, CipherKey);
|
||||||
printRetWrap(retWrap1);
|
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 dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
|
||||||
String oData = "00001111222233";
|
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 cipherKey = (String) retWrap.get(SydApi.RET_CIPHER_KEY);
|
||||||
String sessionKey = (String) retWrap.get(SydApi.RET_SESSION_KEY);
|
System.out.println("数字信封: " + cipherKey);
|
||||||
printRetWrap(retWrap);
|
|
||||||
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试通过
|
// 测试通过
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user