1、添加QP指令对应的接口,修改E0,74,QQ等指令相关的接口。2、添加农行北分海淀支行-军队资金集中收付系统测试类。3、添加打印工具类及文件读取写入工具类
This commit is contained in:
@@ -261,6 +261,60 @@ interface SydSYMApi {
|
||||
*/
|
||||
boolean SYMDecryptDataWithFile(int nAlg, String seesionKey, String inputPath, String outputPath) throws Exception;
|
||||
|
||||
/**
|
||||
* 使用SM4算法进行加密,其中加密模式为CBC,
|
||||
* Ⅳ使用缺省值0X 00000000000000000000000000000000,
|
||||
* 补位模式为 PKCS5 PADDING 。
|
||||
* @param keyType 密钥类型 0: ZEK,1: TEK
|
||||
* @param key 密钥
|
||||
* @param inType 输入消息类型 0:二进制 1:扩展十六进制
|
||||
* @param outType 输出消息类型 0:二进制 1:扩展十六进制
|
||||
* @param inFilePath 需要加密的数据文件所在的路径
|
||||
* @param outFilePath 加密后的密文数据将要保存的文件路径
|
||||
* @return 加密是否成功。false为失败,true为成功
|
||||
*/
|
||||
boolean SM4EncryptFileDataCBC(int keyType, String key, int inType, int outType, String inFilePath, String outFilePath);
|
||||
|
||||
/**
|
||||
* 使用SM4算法进行加密,其中加密模式为CBC,
|
||||
* Ⅳ使用缺省值0X 00000000000000000000000000000000,
|
||||
* 补位模式为 PKCS5 PADDING 。
|
||||
* @param keyType 密钥类型 0: ZEK,1: TEK
|
||||
* @param key 密钥
|
||||
* @param inType 输入消息类型 0:二进制 1:扩展十六进制
|
||||
* @param outType 输出消息类型 0:二进制 1:扩展十六进制
|
||||
* @param msg 消息数据
|
||||
* @return 输出的报文密文
|
||||
*/
|
||||
byte[] SM4EncryptDataCBC(int keyType, String key, int inType, int outType, byte[] msg);
|
||||
|
||||
/**
|
||||
* 使用SM4算法进行解密,其中加密模式为CBC,
|
||||
* Ⅳ使用缺省值0X 00000000000000000000000000000000,
|
||||
* 补位模式为 PKCS5 PADDING 。
|
||||
* @param keyType 密钥类型 0: ZEK,1: TEK
|
||||
* @param key 密钥
|
||||
* @param inType 输入消息类型 0:二进制 1:扩展十六进制
|
||||
* @param outType 输出消息类型 0:二进制 1:扩展十六进制
|
||||
* @param inFilePath 加密后的密文数据将要保存的文件路径
|
||||
* @param outFilePath 解密后的数据文件所在的路径
|
||||
* @return 解密是否成功。false为失败,true为成功
|
||||
*/
|
||||
boolean SM4DecryptFileDataCBC(int keyType, String key, int inType, int outType, String inFilePath, String outFilePath);
|
||||
|
||||
/**
|
||||
* 使用SM4算法进行解密,其中加密模式为CBC,
|
||||
* Ⅳ使用缺省值0X 00000000000000000000000000000000,
|
||||
* 补位模式为 PKCS5 PADDING 。
|
||||
* @param keyType 密钥类型 0: ZEK,1: TEK
|
||||
* @param key 密钥
|
||||
* @param inType 输入消息类型 0:二进制 1:扩展十六进制
|
||||
* @param outType 输出消息类型 0:二进制 1:扩展十六进制
|
||||
* @param msg 加密后的消息数据
|
||||
* @return 输出的报文明文
|
||||
*/
|
||||
byte[] SM4DecryptDataCBC(int keyType, String key, int inType, int outType, byte[] msg);
|
||||
|
||||
/**
|
||||
* 用输入的会话密钥,对指定报文数据进行加密处理。
|
||||
*
|
||||
|
||||
@@ -47,6 +47,19 @@ interface SydNakedSVApi {
|
||||
*/
|
||||
interface SydAttachedSVApi {
|
||||
|
||||
/**
|
||||
* sm2私钥签名
|
||||
* 用户id默认为1234567812345678
|
||||
* 签名结果R/S序列串先进行der编码,再进行base64编码
|
||||
*
|
||||
* @param flag 私钥标志位,当为1时第二个参数传入存储私钥的索引,当为0时第二个参数传入私钥
|
||||
* @param privateKey 当私钥标志位为1时传入存储私钥的索引,当为0时传入私钥
|
||||
* @param publicKey 公钥
|
||||
* @param orgData 要签名的信息
|
||||
* @return 签名结果
|
||||
*/
|
||||
String SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData);
|
||||
|
||||
/**
|
||||
* SM2 私钥签名
|
||||
* @param pUserID 使用者的 ID,最大长度为 16 位数字,右对齐。
|
||||
@@ -102,6 +115,16 @@ interface SydAttachedSVApi {
|
||||
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 算法,用指定的公钥对指定的原始数据进行数字签名验证。
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.sunyard.util;
|
||||
|
||||
import com.sunyard.SydApiException;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
/**
|
||||
* 从文件中读取数据
|
||||
* @param path
|
||||
* @return
|
||||
* @throws SydApiException
|
||||
*/
|
||||
public static byte[] getDataFromFile(String path) throws SydApiException {
|
||||
|
||||
File file = new File(path);
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
throw new SydApiException("该文件不存在", -27);
|
||||
}
|
||||
|
||||
BufferedInputStream bis = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(file));
|
||||
baos = new ByteArrayOutputStream(1024);
|
||||
|
||||
byte[] buf = new byte[1024];
|
||||
|
||||
int size = 0;
|
||||
|
||||
while ((size = bis.read(buf)) != -1) {
|
||||
baos.write(buf, 0, size);
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (baos != null) {
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将字符串数据存储到文件中
|
||||
* 如果文件不存在则自动创建
|
||||
* @param path 文件路径
|
||||
* @param data 数据
|
||||
*/
|
||||
public static void printDataToFile(String path, String data) {
|
||||
OutputStreamWriter osw = null;
|
||||
try {
|
||||
osw = new OutputStreamWriter(new FileOutputStream(path));
|
||||
|
||||
osw.write(data);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (osw != null) {
|
||||
try {
|
||||
osw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user