DN reverse bug fix

This commit is contained in:
cheney
2022-06-21 18:14:28 +08:00
parent 15124bf487
commit 3cd9e78990
10 changed files with 2824 additions and 2867 deletions
+3 -3
View File
@@ -226,7 +226,7 @@ public interface SydGenApi {
* SessionKey 本地LMK 加密的会话密钥,HEX 格式, 本地 LMK 加密的会话密钥长度,HEX 格式(不包括第 1 个字符),一般为 33 个 Bytes。默认输入值为缓冲区的大小。
* KCV 会话密钥的检验值,HEX 格式,长度为 32H。
*/
RetWrap generateDEByDn(String certSerial, String oData);
RetWrap generateDEByDn(String certSerial, byte[] oData);
/**
* 产生对称密钥,通过公钥加密生成网联格式的数字信封。
@@ -240,7 +240,7 @@ public interface SydGenApi {
* SessionKey 本地LMK 加密的会话密钥,HEX 格式, 本地 LMK 加密的会话密钥长度,HEX 格式(不包括第 1 个字符),一般为 33 个 Bytes。默认输入值为缓冲区的大小。
* KCV 会话密钥的检验值,HEX 格式,长度为 32H。
*/
RetWrap generateDE(byte[] certSerial, int alg, int model, String oData);
RetWrap generateDE(byte[] certSerial, int alg, int model, byte[] oData);
/**
* 产生对称密钥,通过公钥加密生成网联格式的数字信封。
@@ -308,7 +308,7 @@ public interface SydGenApi {
* KCV 会话密钥的检验值,HEX 格式,长度为 36H。
* orgCode 如果有机构码的话会返回机构码
*/
RetWrap decryptDEByDN(String certSerial, String pCipherKey);
RetWrap decryptDEByDN(String certSerial, byte[] pCipherKey);
/**
* 接收用私钥解密数字信封,还原对称密钥。
+5 -5
View File
@@ -177,7 +177,7 @@ interface SydAttachedSVApi {
* @return
* 符合PKCS7标准的签名结果
*/
String attachedSign(byte[] orgData, String sCertDN);
byte[] attachedSign(byte[] orgData, String sCertDN);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
@@ -186,7 +186,7 @@ interface SydAttachedSVApi {
* @param sign 已签名数据
* @return true 验签通过 false 验签失败
*/
boolean attachedVerify(String sign);
boolean attachedVerify(byte[] sign);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
@@ -195,7 +195,7 @@ interface SydAttachedSVApi {
* @param sign 已签名数据
* @return 成功返回签名的原数据,失败则报错
*/
String attachedVerifyRD(String sign);
byte[] attachedVerifyRD(byte[] sign);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
@@ -206,7 +206,7 @@ interface SydAttachedSVApi {
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
*/
X509 attachedVerifyAndGetX509(String sign);
X509 attachedVerifyAndGetX509(byte[] sign);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
@@ -217,7 +217,7 @@ interface SydAttachedSVApi {
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
*/
RetWrap attachedVerifyAndGetAll(String sign);
RetWrap attachedVerifyAndGetAll(byte[] sign);
}
+10 -3
View File
@@ -1,6 +1,7 @@
package com.sunyard.util;
import java.util.LinkedHashMap;
import java.util.List;
public class DnUtil {
@@ -20,14 +21,20 @@ public class DnUtil {
return dn;
}
// 反转顺序
LinkedHashMap<String, String> map = dnToMap( dn );
String[] kvs = dn.split(",");
StringBuilder sb = new StringBuilder();
for ( String key : map.keySet() ) {
for ( String kv : kvs ) {
if ( sb.length() > 0 ) {
sb.insert(0, ",");
}
sb.insert(0, key + "=" + map.get( key ));
sb.insert(0, kv );
// if ( sb.length() > 0 ) {
// sb.append(",");
// }
// sb.append( key + "=" + map.get( key ) );
}
return sb.toString();