修正SydAttachedSVApi

This commit is contained in:
yihzhou
2022-11-08 17:36:45 +08:00
parent 9fd5d5dc8e
commit 9ab25d4899
2 changed files with 40 additions and 221 deletions
@@ -1,11 +1,14 @@
package com.sunyard.inf.sva;
package com.sunyard.inf;
import com.sunyard.RetWrap;
import com.sunyard.cert.X509;
import java.io.UnsupportedEncodingException;
/**
* 带原文的签名验签
*/
public interface SydAttachedSVApi {
interface SydAttachedSVApi {
/**
* sm2私钥签名
@@ -18,8 +21,8 @@ public interface SydAttachedSVApi {
* @param orgData 要签名的信息
* @return 签名结果
*/
String SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData);
String SM2SignC(int flag, String pUserID, String privateKey, byte[] publicKey, byte[] orgData);
byte[] SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData);
byte[] SM2SignC(int flag, String pUserID, String privateKey, byte[] publicKey, byte[] orgData);
/**
* SM2 私钥签名
* @param pUserID 使用者的 ID,最大长度为 16 位数字,右对齐。
@@ -100,7 +103,7 @@ public interface SydAttachedSVApi {
int nOrgDataType,
byte[] publicKey,
byte[] orgData,
String sign
byte[] sign
);
@@ -137,7 +140,21 @@ public interface SydAttachedSVApi {
* @return
* 符合PKCS7标准的签名结果
*/
String attachedSign(byte[] orgData, String sCertDN);
String attachedSign(byte[] orgData, String sCertDN) throws UnsupportedEncodingException;
byte[] attachedSignC(byte[] orgData, String sCertDN);
/**
* 人行项目需要需要支持RSA
* 带公钥证书与原始数据的数字签名(遵循 PKCS#7)
* 使用指定的证书 DN,从加密设备获取对应的私钥证书,对指定的原始数据编制带公钥证书的数字签名(遵循 PKCS#7)。
*
* @param orgData 待签名数据
* @param sCertDN 证书DN
* @return
* 符合PKCS7标准的签名结果
*/
String attachedSign(int rFlag,byte[] orgData, String sCertDN) throws UnsupportedEncodingException;
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
@@ -148,6 +165,18 @@ public interface SydAttachedSVApi {
*/
boolean attachedVerify(String sign);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
*
* @param sign 已签名数据
* @return true 验签通过 false 验签失败
*/
boolean attachedVerify(int rFlag,String sign);
boolean attachedVerify(byte[] sign);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
@@ -155,7 +184,8 @@ public interface SydAttachedSVApi {
* @param sign 已签名数据
* @return 成功返回签名的原数据,失败则报错
*/
String attachedVerifyRD(String sign);
byte[] attachedVerifyRD(byte[] sign);
byte[] attachedVerifyRD(String sign);
/**
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
@@ -166,6 +196,7 @@ public interface SydAttachedSVApi {
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
*/
X509 attachedVerifyAndGetX509(byte[] sign);
X509 attachedVerifyAndGetX509(String sign);
/**
@@ -177,5 +208,5 @@ public interface SydAttachedSVApi {
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
*/
RetWrap attachedVerifyAndGetAll(String sign);
}
RetWrap attachedVerifyAndGetAll(byte[] sign);
}