修正SydAttachedSVApi
This commit is contained in:
parent
9fd5d5dc8e
commit
9ab25d4899
@ -1,212 +0,0 @@
|
|||||||
package com.sunyard.inf;
|
|
||||||
|
|
||||||
import com.sunyard.RetWrap;
|
|
||||||
import com.sunyard.cert.X509;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 带原文的签名验签
|
|
||||||
*/
|
|
||||||
interface SydAttachedSVApi {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sm2私钥签名
|
|
||||||
* 用户id默认为1234567812345678
|
|
||||||
* 签名结果R/S序列串先进行der编码,再进行base64编码
|
|
||||||
*
|
|
||||||
* @param flag 私钥标志位,当为1时第二个参数传入存储私钥的索引,当为0时第二个参数传入私钥
|
|
||||||
* @param privateKey 当私钥标志位为1时传入存储私钥的索引,当为0时传入私钥
|
|
||||||
* @param publicKey 公钥
|
|
||||||
* @param orgData 要签名的信息
|
|
||||||
* @return 签名结果
|
|
||||||
*/
|
|
||||||
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 位数字,右对齐。
|
|
||||||
* @param certNo 证书号
|
|
||||||
* @param nOrgDataType 原始数据类型 0 : hash 1 : 原数据
|
|
||||||
* @param publicKey 公钥的 DER 编码
|
|
||||||
* @param orgData 原始数据
|
|
||||||
* @return 签名的 base64 编码
|
|
||||||
*/
|
|
||||||
String SM2SignC(
|
|
||||||
String pUserID,
|
|
||||||
String certNo,
|
|
||||||
int nOrgDataType,
|
|
||||||
byte[] publicKey,
|
|
||||||
byte[] orgData
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RSA 私钥签名
|
|
||||||
* @param HashMark 哈希标识 指示用于哈希证书数据的哈希算法的标识。0: SHA1 1: SHA256 2: MD5。
|
|
||||||
* @param privateKeyTag 私钥标记 指示私钥位置的标记。数字为存储私钥的索引,除了全9表示使用由命令中提供的密钥。
|
|
||||||
* 27位的索引号:16位机构号+3位密钥类型+8位密钥索引号
|
|
||||||
* @param nOrgDataType 原始数据类型 0 : hash 1 : 原数据
|
|
||||||
* @param orgData 原始数据
|
|
||||||
* @return 签名的 base64 编码
|
|
||||||
*/
|
|
||||||
byte[] RSASignC(
|
|
||||||
String privateKeyTag,
|
|
||||||
int HashMark,
|
|
||||||
int nOrgDataType,
|
|
||||||
byte[] orgData);
|
|
||||||
|
|
||||||
|
|
||||||
byte[] RSASign(
|
|
||||||
String privateKey,
|
|
||||||
int HashMark,
|
|
||||||
int nOrgDataType,
|
|
||||||
byte[] orgData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 采用 RSA 算法,用指定的公钥对指定的原始数据进行数字签名验证。
|
|
||||||
* @param HashMark 哈希标识
|
|
||||||
* @param nOrgDataType 签名方式
|
|
||||||
* @param publicKey 公钥
|
|
||||||
* @param orgData 原始数据
|
|
||||||
* @param sign base64 格式的签名
|
|
||||||
* @return true 验签通过 false 验签失败
|
|
||||||
*/
|
|
||||||
boolean RSAVerify(
|
|
||||||
int HashMark,
|
|
||||||
int nOrgDataType,
|
|
||||||
byte[] publicKey,
|
|
||||||
byte[] orgData,
|
|
||||||
byte[] sign);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sm2验签
|
|
||||||
* 用户id默认为1234567812345678
|
|
||||||
*
|
|
||||||
* @param publicKey 公钥的 DER 编码
|
|
||||||
* @param orgData 要签名的信息
|
|
||||||
* @param base64Sign 计算的签名,签名结果R/S序列串先进行der编码,再进行base64编码后的结果
|
|
||||||
* @return true 验签成功,false 验签失败
|
|
||||||
*/
|
|
||||||
boolean SM2Verify(byte[] publicKey, byte[] orgData, String base64Sign);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 采用 SM2 算法,用指定的公钥对指定的原始数据进行数字签名验证。
|
|
||||||
* @param certNo id 用于计算SM3-HASH
|
|
||||||
* @param nOrgDataType 原始数据类型 0 : hash 1 : 原数据,用1.2.3章节限定符亦可
|
|
||||||
* @param publicKey 公钥
|
|
||||||
* @param orgData 原始数据
|
|
||||||
* @param sign base64 格式的签名
|
|
||||||
* @return true 验签通过 false 验签失败
|
|
||||||
*/
|
|
||||||
boolean SM2Verify(
|
|
||||||
String certNo,
|
|
||||||
int nOrgDataType,
|
|
||||||
byte[] publicKey,
|
|
||||||
byte[] orgData,
|
|
||||||
byte[] sign
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SM2 私钥签名
|
|
||||||
* @param certNo 证书号
|
|
||||||
* @param orgData 原始数据
|
|
||||||
* @return 签名的 base64 编码
|
|
||||||
*/
|
|
||||||
String SM2SignCustomized(
|
|
||||||
String certNo,
|
|
||||||
byte[] orgData
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 采用 SM2 算法,用指定的公钥对指定的原始数据进行数字签名验证。
|
|
||||||
* @param certNo 证书号
|
|
||||||
* @param orgData 原始数据
|
|
||||||
* @param sign base64 格式的签名
|
|
||||||
* @return true 验签通过 false 验签失败
|
|
||||||
*/
|
|
||||||
boolean SM2VerifyCustomized(
|
|
||||||
String certNo,
|
|
||||||
byte[] orgData,
|
|
||||||
String sign
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 带公钥证书与原始数据的数字签名(遵循 PKCS#7)
|
|
||||||
* 使用指定的证书 DN,从加密设备获取对应的私钥证书,对指定的原始数据编制带公钥证书的数字签名(遵循 PKCS#7)。
|
|
||||||
*
|
|
||||||
* @param orgData 待签名数据
|
|
||||||
* @param sCertDN 证书DN
|
|
||||||
* @return
|
|
||||||
* 符合PKCS7标准的签名结果
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
|
||||||
*
|
|
||||||
* @param sign 已签名数据
|
|
||||||
* @return true 验签通过 false 验签失败
|
|
||||||
*/
|
|
||||||
boolean attachedVerify(String sign);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
|
||||||
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
|
||||||
*
|
|
||||||
* @param sign 已签名数据
|
|
||||||
* @return true 验签通过 false 验签失败
|
|
||||||
*/
|
|
||||||
boolean attachedVerify(int rFlag,String sign);
|
|
||||||
|
|
||||||
|
|
||||||
boolean attachedVerify(byte[] sign);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
|
||||||
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
|
||||||
*
|
|
||||||
* @param sign 已签名数据
|
|
||||||
* @return 成功返回签名的原数据,失败则报错
|
|
||||||
*/
|
|
||||||
byte[] attachedVerifyRD(byte[] sign);
|
|
||||||
byte[] attachedVerifyRD(String sign);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
|
||||||
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
|
||||||
*
|
|
||||||
* @param sign 已签名数据
|
|
||||||
* @return
|
|
||||||
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
|
|
||||||
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
|
|
||||||
*/
|
|
||||||
X509 attachedVerifyAndGetX509(byte[] sign);
|
|
||||||
X509 attachedVerifyAndGetX509(String sign);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
|
||||||
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
|
||||||
*
|
|
||||||
* @param sign 已签名数据
|
|
||||||
* @return
|
|
||||||
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
|
|
||||||
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
|
|
||||||
*/
|
|
||||||
RetWrap attachedVerifyAndGetAll(byte[] sign);
|
|
||||||
}
|
|
||||||
@ -1,11 +1,14 @@
|
|||||||
package com.sunyard.inf.sva;
|
package com.sunyard.inf;
|
||||||
|
|
||||||
import com.sunyard.RetWrap;
|
import com.sunyard.RetWrap;
|
||||||
import com.sunyard.cert.X509;
|
import com.sunyard.cert.X509;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带原文的签名验签
|
* 带原文的签名验签
|
||||||
*/
|
*/
|
||||||
public interface SydAttachedSVApi {
|
interface SydAttachedSVApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sm2私钥签名
|
* sm2私钥签名
|
||||||
@ -18,8 +21,8 @@ public interface SydAttachedSVApi {
|
|||||||
* @param orgData 要签名的信息
|
* @param orgData 要签名的信息
|
||||||
* @return 签名结果
|
* @return 签名结果
|
||||||
*/
|
*/
|
||||||
String SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData);
|
byte[] 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 pUserID, String privateKey, byte[] publicKey, byte[] orgData);
|
||||||
/**
|
/**
|
||||||
* SM2 私钥签名
|
* SM2 私钥签名
|
||||||
* @param pUserID 使用者的 ID,最大长度为 16 位数字,右对齐。
|
* @param pUserID 使用者的 ID,最大长度为 16 位数字,右对齐。
|
||||||
@ -100,7 +103,7 @@ public interface SydAttachedSVApi {
|
|||||||
int nOrgDataType,
|
int nOrgDataType,
|
||||||
byte[] publicKey,
|
byte[] publicKey,
|
||||||
byte[] orgData,
|
byte[] orgData,
|
||||||
String sign
|
byte[] sign
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +140,21 @@ public interface SydAttachedSVApi {
|
|||||||
* @return
|
* @return
|
||||||
* 符合PKCS7标准的签名结果
|
* 符合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)
|
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
||||||
@ -148,6 +165,18 @@ public interface SydAttachedSVApi {
|
|||||||
*/
|
*/
|
||||||
boolean attachedVerify(String sign);
|
boolean attachedVerify(String sign);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
||||||
|
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
||||||
|
*
|
||||||
|
* @param sign 已签名数据
|
||||||
|
* @return true 验签通过 false 验签失败
|
||||||
|
*/
|
||||||
|
boolean attachedVerify(int rFlag,String sign);
|
||||||
|
|
||||||
|
|
||||||
|
boolean attachedVerify(byte[] sign);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
||||||
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
* 对指定的原始数据核验其带公钥证书签名。如签名有效(含证书无效)且需返回签名者公钥证书信息时,同时返回签名者公钥证书信息。
|
||||||
@ -155,7 +184,8 @@ public interface SydAttachedSVApi {
|
|||||||
* @param sign 已签名数据
|
* @param sign 已签名数据
|
||||||
* @return 成功返回签名的原数据,失败则报错
|
* @return 成功返回签名的原数据,失败则报错
|
||||||
*/
|
*/
|
||||||
String attachedVerifyRD(String sign);
|
byte[] attachedVerifyRD(byte[] sign);
|
||||||
|
byte[] attachedVerifyRD(String sign);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
* 带公钥证书与原始数据的数字签名验签(遵循 PKCS#7)
|
||||||
@ -166,6 +196,7 @@ public interface SydAttachedSVApi {
|
|||||||
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
|
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
|
||||||
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
|
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
|
||||||
*/
|
*/
|
||||||
|
X509 attachedVerifyAndGetX509(byte[] sign);
|
||||||
X509 attachedVerifyAndGetX509(String sign);
|
X509 attachedVerifyAndGetX509(String sign);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -177,5 +208,5 @@ public interface SydAttachedSVApi {
|
|||||||
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
|
* 若发送报文返回证书信息标志位为0,则返回已签名数据,
|
||||||
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
|
* 若发送报文返回证书信息标志位为1,则返回CERT_INFO结构的证书数据
|
||||||
*/
|
*/
|
||||||
RetWrap attachedVerifyAndGetAll(String sign);
|
RetWrap attachedVerifyAndGetAll(byte[] sign);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user