loadrunner 脚本
This commit is contained in:
@@ -58,8 +58,8 @@ 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 位数字,右对齐。
|
||||
@@ -140,7 +140,7 @@ interface SydAttachedSVApi {
|
||||
int nOrgDataType,
|
||||
byte[] publicKey,
|
||||
byte[] orgData,
|
||||
String sign
|
||||
byte[] sign
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -117,13 +117,13 @@ public interface SydHAApi {
|
||||
* @param nOrgDataType 签名数据类型,SydApi.DATA_ORIGIN(1) 原始数据 SydApi.DATA_HASH(0) : hash 后的类型
|
||||
* @param publicKey 公钥串,DER编码,HEX格式
|
||||
* @param orgData 待签名的原始数据,“签名数据类型”为 0 时:HASH 值。“签名数据类型”为 1 时:要签名的信息
|
||||
* @param base64Sign 签名数据 (DER 编码 + Base64 编码)
|
||||
* @param sign S+R
|
||||
* @return 验签是否通过
|
||||
*/
|
||||
public boolean SM2Verify(
|
||||
int nOrgDataType,
|
||||
byte[] publicKey,
|
||||
byte[] orgData,
|
||||
String base64Sign
|
||||
byte[] sign
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3347,6 +3347,13 @@ public class SydApi4j implements SydApi {
|
||||
// 测试通过
|
||||
public String SM2GetPrivateKeyC(String privateKeyTag) {
|
||||
|
||||
if ( privateKeyTag.length() < 16 ) {
|
||||
privateKeyTag = "0000000000000000" + privateKeyTag;
|
||||
privateKeyTag = privateKeyTag.substring( privateKeyTag.length() -16 );
|
||||
privateKeyTag += "00000000001";
|
||||
}
|
||||
|
||||
|
||||
ProtoQP proto = new ProtoQP();
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
@@ -3591,12 +3598,12 @@ public class SydApi4j implements SydApi {
|
||||
* @param orgData 要签名的信息
|
||||
* @return 签名结果
|
||||
*/
|
||||
public String SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData) {
|
||||
public byte[] SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData) {
|
||||
return SM2SignC( flag, "1234567812345678", privateKey, publicKey, orgData);
|
||||
}
|
||||
// 测试通过
|
||||
@Override
|
||||
public String SM2SignC(int flag, String uid, String privateKey, byte[] publicKey, byte[] orgData) {
|
||||
public byte[] SM2SignC(int flag, String uid, String privateKey, byte[] publicKey, byte[] orgData) {
|
||||
|
||||
Proto74 proto = new Proto74();
|
||||
|
||||
@@ -3637,7 +3644,7 @@ public class SydApi4j implements SydApi {
|
||||
byte[] s = new byte[a];
|
||||
bb.get(s, 0, a);
|
||||
|
||||
return SYMUtil.derSign2Base64Sign(s);
|
||||
return Util.decodeBase64( SYMUtil.derSign2Base64Sign(s) );
|
||||
|
||||
}
|
||||
|
||||
@@ -3813,10 +3820,10 @@ public class SydApi4j implements SydApi {
|
||||
int nOrgDataType,
|
||||
byte[] publicKey,
|
||||
byte[] orgData,
|
||||
String base64Sign
|
||||
byte[] sign
|
||||
){
|
||||
String certNo = "1234567812345678";
|
||||
return SM2Verify(certNo, nOrgDataType, publicKey, orgData, base64Sign);
|
||||
return SM2Verify(certNo, nOrgDataType, publicKey, orgData, sign);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3915,7 +3922,7 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
// 测试通过
|
||||
@Override
|
||||
public boolean SM2Verify(String certNo, int nOrgDataType, byte[] publicKey, byte[] orgData, String base64Sign) {
|
||||
public boolean SM2Verify(String certNo, int nOrgDataType, byte[] publicKey, byte[] orgData, byte[] sign) {
|
||||
|
||||
if (certNo.length() > 32) {
|
||||
certNo = certNo.substring(0, 32);
|
||||
@@ -3923,7 +3930,7 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
Proto75 proto = new Proto75(); //pset.getProtocolReqRender("75");
|
||||
|
||||
byte[] sign = SYMUtil.base64Sign2DerSign(base64Sign);
|
||||
sign = SYMUtil.base64Sign2DerSign( Util.encodeBase64(sign) );
|
||||
|
||||
// 填充数据
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
|
||||
Reference in New Issue
Block a user