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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.sunyard.proto.section.SectionValue;
|
||||
import com.sunyard.proto.value.Str;
|
||||
import com.sunyard.trans.PacketSN;
|
||||
import com.sunyard.util.CoderUtil;
|
||||
import com.sunyard.util.FileUtil;
|
||||
import com.sunyard.util.MyUtil;
|
||||
import com.sunyard.util.SYMUtil;
|
||||
import racal.sunyard.main.dto.*;
|
||||
@@ -2727,6 +2728,49 @@ public class SydApi4j implements SydApi {
|
||||
return Util.bytes2HexString(((PacketSection) ret.get("publicKey")).getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过密钥索引获得 SM2 公钥(DER 编码)。
|
||||
* @param privateKeyTag 指示用户密钥存储区的27位地址,27位的索引号:16位机构号+3位密钥类型+8位密钥索引号
|
||||
* @return 公钥数据的der编码
|
||||
*/
|
||||
// 测试通过
|
||||
public String SM2GetPublicKeyC(String privateKeyTag) {
|
||||
|
||||
ProtoQQ proto = new ProtoQQ();
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
packet.put("data", data);
|
||||
PacketSN sn = PacketSN.gen();
|
||||
packet.put("header", sn.getSn().array());
|
||||
data.put("privateKeyTag", privateKeyTag);
|
||||
// 渲染发送
|
||||
ByteBuffer bb = proto.rend(packet);
|
||||
//System.out.println(Util.bytes2HexString(Util.toArray(bb)));
|
||||
synchronized (this) {
|
||||
// 响应解析
|
||||
bb = syncRead(syncSend(bb));
|
||||
}
|
||||
|
||||
//ProtocolParser parser = pset.getProtocolResParse();
|
||||
Packet p = proto.parse(bb);
|
||||
Map<String, Object> ret = p.toMap();
|
||||
if (
|
||||
!Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes())
|
||||
) {
|
||||
throw new SydApiException("包序号不匹配", -4);
|
||||
}
|
||||
ret = (Map<String, Object>) ret.get("data");
|
||||
PacketSection error = (PacketSection) ret.get("error");
|
||||
if (!"00".equals(error.getString())) {
|
||||
throw new SydApiException(error.getInfo(), error.autoInt());
|
||||
}
|
||||
int len = Integer.parseInt(((PacketSection) ret.get("publicLen")).getString());
|
||||
if (len == 128) {
|
||||
return "03420004" + ((PacketSection) ret.get("publicKey")).getString();
|
||||
}
|
||||
|
||||
return ((PacketSection) ret.get("publicKey")).getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String SM2GetPublicKeyC(String userId, int nKeyType) {
|
||||
@@ -2768,6 +2812,53 @@ public class SydApi4j implements SydApi {
|
||||
return ((PacketSection) ret.get("publicKey")).getString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出一个SM2私钥。
|
||||
* @param privateKeyTag 要导出密钥的索引,27位的索引号:16位机构号+3位密钥类型+8位密钥索引号
|
||||
* @return LMK下加密的私钥
|
||||
*/
|
||||
// 测试通过
|
||||
public String SM2GetPrivateKeyC(String privateKeyTag) {
|
||||
|
||||
ProtoQP proto = new ProtoQP();
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
packet.put("data", data);
|
||||
PacketSN sn = PacketSN.gen();
|
||||
packet.put("header", sn.getSn().array());
|
||||
data.put("privateKeyTag", privateKeyTag);
|
||||
// 渲染发送
|
||||
ByteBuffer bb = proto.rend(packet);
|
||||
//System.out.println(Util.bytes2HexString(Util.toArray(bb)));
|
||||
synchronized (this) {
|
||||
// 响应解析
|
||||
bb = syncRead(syncSend(bb));
|
||||
}
|
||||
|
||||
//ProtocolParser parser = pset.getProtocolResParse();
|
||||
Packet p = proto.parse(bb);
|
||||
Map<String, Object> ret = p.toMap();
|
||||
if (
|
||||
!Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes())
|
||||
) {
|
||||
throw new SydApiException("包序号不匹配", -4);
|
||||
}
|
||||
ret = (Map<String, Object>) ret.get("data");
|
||||
PacketSection error = (PacketSection) ret.get("error");
|
||||
if (!"00".equals(error.getString())) {
|
||||
throw new SydApiException(error.getInfo(), error.autoInt());
|
||||
}
|
||||
|
||||
// 模长
|
||||
String mod = "00010000";
|
||||
|
||||
// 填充
|
||||
String fill = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
return mod + ((PacketSection) ret.get("privateKey")).getString() + fill;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过私钥获取公钥
|
||||
*
|
||||
@@ -2933,6 +3024,120 @@ public class SydApi4j implements SydApi {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sm2私钥签名
|
||||
* 用户id默认为1234567812345678
|
||||
* 签名结果R/S序列串先进行der编码,再进行base64编码
|
||||
*
|
||||
* @param flag 私钥标志位,当为1时第二个参数传入存储私钥的索引,当为0时第二个参数传入私钥
|
||||
* @param privateKey 当私钥标志位为1时传入存储私钥的索引,当为0时传入私钥
|
||||
* @param publicKey 公钥
|
||||
* @param orgData 要签名的信息
|
||||
* @return 签名结果
|
||||
*/
|
||||
// 测试通过
|
||||
@Override
|
||||
public String SM2SignC(int flag, String privateKey, byte[] publicKey, byte[] orgData) {
|
||||
|
||||
Proto74 proto = new Proto74();
|
||||
|
||||
// 填充数据
|
||||
HashMap<String, Object> packet = new HashMap<>();
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
packet.put("data", data);
|
||||
|
||||
PacketSN sn = PacketSN.gen();
|
||||
packet.put("header", sn.getSn().array());
|
||||
data.put("signatureDataType$option", 1);
|
||||
data.put("userId", "1234567812345678".getBytes());
|
||||
data.put("publicKey", publicKey);
|
||||
data.put("infoData", orgData);
|
||||
data.put("privateKeyTag", flag == 1 ? privateKey : "999999999999999999999999999");
|
||||
data.put("privateKey", Util.hexString2Bytes(privateKey));
|
||||
|
||||
// 渲染发送
|
||||
ByteBuffer bb = proto.rend(packet);
|
||||
//System.out.println(Util.bytes2HexString(Util.toArray(bb)));
|
||||
synchronized (this) {
|
||||
// 响应解析
|
||||
bb = syncRead(syncSend(bb));
|
||||
}
|
||||
|
||||
|
||||
SectionValue sv = new SectionValue();
|
||||
sv.setValue(new byte[]{bb.get(12), bb.get(13)});
|
||||
PacketSection error = new PacketSection(sv);
|
||||
if (0 != error.autoInt()) {
|
||||
throw new SydApiException(error.getInfo(), error.autoInt());
|
||||
}
|
||||
|
||||
bb.position(14);
|
||||
byte[] v = new byte[4];
|
||||
bb.get(v, 0, v.length);
|
||||
int a = Util.a2i(v, 10);
|
||||
byte[] s = new byte[a];
|
||||
bb.get(s, 0, a);
|
||||
|
||||
return SYMUtil.derSign2Base64Sign(s);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* sm2验签
|
||||
* 用户id默认为1234567812345678
|
||||
*
|
||||
* @param publicKey 公钥的 DER 编码
|
||||
* @param orgData 签名信息
|
||||
* @param base64Sign 计算的签名,签名结果R/S序列串先进行der编码,再进行base64编码后的结果
|
||||
* @return true 验签成功,false 验签失败
|
||||
*/
|
||||
// 测试通过
|
||||
@Override
|
||||
public boolean SM2Verify(byte[] publicKey, byte[] orgData, String base64Sign) {
|
||||
|
||||
Proto75 proto = new Proto75(); //pset.getProtocolReqRender("75");
|
||||
|
||||
byte[] sign = SYMUtil.base64Sign2DerSign(base64Sign);
|
||||
|
||||
// 填充数据
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
packet.put("data", data);
|
||||
PacketSN sn = PacketSN.gen();
|
||||
packet.put("header", sn.getSn().array());
|
||||
data.put("signatureDataType$option", 1);
|
||||
data.put("signature", sign);
|
||||
data.put("userId", "1234567812345678".getBytes());
|
||||
data.put("infoData", orgData);
|
||||
data.put("publicKey", publicKey);
|
||||
// 渲染发送
|
||||
ByteBuffer bb = proto.rend(packet);
|
||||
|
||||
long b = System.currentTimeMillis();
|
||||
|
||||
synchronized (this) {
|
||||
// 响应解析
|
||||
bb = syncRead(syncSend(bb));
|
||||
}
|
||||
|
||||
Packet p = proto.parse(bb);
|
||||
Map<String, Object> ret = p.toMap();
|
||||
|
||||
if (
|
||||
!Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes())
|
||||
) {
|
||||
throw new SydApiException("包序号不匹配", -4);
|
||||
}
|
||||
ret = (Map<String, Object>) ret.get("data");
|
||||
PacketSection error = (PacketSection) ret.get("error");
|
||||
if (!"00".equals(error.getString())) {
|
||||
|
||||
throw new SydApiException(error.getInfo(), error.autoInt());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 测试通过
|
||||
@Override
|
||||
public String SM2SignC(String pUserID, String certNo, int nOrgDataType, byte[] publicKey, byte[] orgData) {
|
||||
@@ -4030,6 +4235,149 @@ public class SydApi4j implements SydApi {
|
||||
return rw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用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为成功
|
||||
*/
|
||||
// 测试通过
|
||||
@Override
|
||||
public boolean SM4EncryptFileDataCBC(int keyType, String key, int inType, int outType, String inFilePath, String outFilePath) {
|
||||
|
||||
byte[] msg = FileUtil.getDataFromFile(inFilePath);
|
||||
|
||||
if (msg == null || msg.length == 0) {
|
||||
throw new SydApiException("数据为空", -27);
|
||||
}
|
||||
|
||||
// 调用加密接口将数据加密
|
||||
byte[] result = SM4EncryptDataCBC(keyType, key, inType, outType, msg);
|
||||
String str = Util.bytes2HexString(result);
|
||||
|
||||
FileUtil.printDataToFile(outFilePath, str);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用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 输出的报文密文
|
||||
*/
|
||||
// 测试通过
|
||||
@Override
|
||||
public byte[] SM4EncryptDataCBC(int keyType, String key, int inType, int outType, byte[] msg) {
|
||||
|
||||
// 填充数据
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
byte[] iv = new byte[32];
|
||||
Arrays.fill(iv, (byte) 0x30);
|
||||
|
||||
data.put("alg$option", 0x8);
|
||||
data.put("roundModel$option", 1);
|
||||
data.put("iv", iv);
|
||||
data.put("keyType$option", keyType);
|
||||
data.put("key", key.getBytes());
|
||||
data.put("inType$option", inType);
|
||||
data.put("outType$option", outType);
|
||||
data.put("fullMode$option", 1);
|
||||
data.put("fullChar$option", 0);
|
||||
data.put("fullType$option", 2);
|
||||
data.put("msg", msg);
|
||||
|
||||
packet.put("data", data);
|
||||
|
||||
return repackEncrypt(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用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为成功
|
||||
*/
|
||||
// 测试通过
|
||||
@Override
|
||||
public boolean SM4DecryptFileDataCBC(int keyType, String key, int inType, int outType, String inFilePath, String outFilePath) {
|
||||
|
||||
byte[] msg = FileUtil.getDataFromFile(inFilePath);
|
||||
|
||||
if (msg == null || msg.length == 0) {
|
||||
throw new SydApiException("数据为空", -27);
|
||||
}
|
||||
|
||||
// 调用加密接口将数据加密
|
||||
byte[] result = SM4DecryptDataCBC(keyType, key, inType, outType, Util.hexString2Bytes(new String(msg)));
|
||||
|
||||
String str = new String(Util.hexString2Bytes(Util.bytes2HexString(result)));
|
||||
|
||||
FileUtil.printDataToFile(outFilePath, str);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用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 输出的报文明文
|
||||
*/
|
||||
// 测试通过
|
||||
@Override
|
||||
public byte[] SM4DecryptDataCBC(int keyType, String key, int inType, int outType, byte[] msg) {
|
||||
|
||||
byte[] iv = new byte[32];
|
||||
Arrays.fill(iv, (byte) 0x30);
|
||||
|
||||
// 填充数据
|
||||
PacketSN sn = PacketSN.gen();
|
||||
HashMap<String, Object> packet = new HashMap<String, Object>();
|
||||
packet.put("header", sn.getSn().array());
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
|
||||
data.put("alg$option", 0x9);
|
||||
|
||||
data.put("roundModel$option", 1);
|
||||
data.put("iv", iv);
|
||||
data.put("keyType$option", keyType);
|
||||
data.put("key", key.getBytes());
|
||||
data.put("inType$option", inType);
|
||||
data.put("outType$option", outType);
|
||||
data.put("fullMode$option", 1);
|
||||
data.put("fullChar$option", 0);
|
||||
data.put("fullType$option", 2);
|
||||
data.put("msg", msg);
|
||||
|
||||
packet.put("data", data);
|
||||
|
||||
return repackEncrypt(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] SYMEncryptDataCBC(int nAlg, String seesionKey, byte[] pInData) {
|
||||
return SYMEncryptDataCBC(nAlg, seesionKey, 1, pInData);
|
||||
@@ -6188,6 +6536,7 @@ public class SydApi4j implements SydApi {
|
||||
* @return DK: LMK14-15 加密下的密钥
|
||||
* keyCheck: 密钥校验值
|
||||
*/
|
||||
// 测试通过
|
||||
public RetWrap getTransmissionKey() {
|
||||
// 获取协议
|
||||
Proto60 proto = new Proto60();
|
||||
|
||||
Reference in New Issue
Block a user