EO指令新增通过索引去就行sm4加解密的接口
This commit is contained in:
@@ -246,6 +246,16 @@ interface SydSYMApi {
|
||||
*/
|
||||
byte[] SYMEncryptData(int nAlg, String seesionKey, byte[] pINdata);
|
||||
|
||||
/**
|
||||
* 对指定报文数据进行SM4加密
|
||||
* @param type 密钥类型。0: ZEK,1: TEK
|
||||
* @param userId 生成密钥时的机构号。
|
||||
* @param index 密钥索引
|
||||
* @param data 待加密的数据
|
||||
* @return
|
||||
*/
|
||||
byte[] SYMSM4EncDataByIndex(int type, String userId, String index, byte[] data);
|
||||
|
||||
/**
|
||||
* 用输入的会话密钥,对指定报文数据进行加密处理。
|
||||
*
|
||||
|
||||
@@ -1911,6 +1911,25 @@ public class SydApi4j implements SydApi {
|
||||
return retWrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对指定报文数据进行SM4加密
|
||||
* @param type 密钥类型。0: ZEK,1: TEK
|
||||
* @param userId 生成密钥时的机构号。
|
||||
* @param index 密钥索引
|
||||
* @param data 待加密的数据
|
||||
* @return
|
||||
*/
|
||||
public byte[] SYMSM4EncDataByIndex(int type, String userId, String index, byte[] data) {
|
||||
|
||||
if (userId.length() > 16 || index.length() > 8) {
|
||||
throw new SydApiException("机构号或索引长度不匹配", -27);
|
||||
}
|
||||
|
||||
String indexN = "0000000000000000" + index;
|
||||
indexN = indexN.substring(indexN.length() - 8);
|
||||
|
||||
return SYMEncryptData(SydApi.NALG_SM4, "XK" + SYMUtil.genPrivateKeyMark(userId, 0 == type ? "00A" : "00B", indexN), 1, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] SYMEncryptData(int nAlg, String seesionKey, int fullMode, byte[] pInData) {
|
||||
@@ -2033,6 +2052,26 @@ public class SydApi4j implements SydApi {
|
||||
return SYMDecryptData(nAlg, seesionKey, 1, pInData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对指定报文数据进行SM4解密
|
||||
* @param type 密钥类型。0: ZEK,1: TEK
|
||||
* @param userId 生成密钥时的机构号
|
||||
* @param index 密钥索引
|
||||
* @param pINdata 要解密的报文密文。长度必须是8 或16 的倍数
|
||||
* @return
|
||||
*/
|
||||
public byte[] SYMSM4DecDataByIndex (int type, String userId, String index, byte[] pINdata) {
|
||||
|
||||
if (userId.length() > 16 || index.length() > 8) {
|
||||
throw new SydApiException("机构号或索引长度不匹配", -27);
|
||||
}
|
||||
|
||||
String indexN = "00000000" + index;
|
||||
indexN = indexN.substring(indexN.length() - 8);
|
||||
|
||||
return SYMDecryptData(SydApi4j.NALG_SM4, "XK" + SYMUtil.genPrivateKeyMark(userId, 0 == type ? "00A" : "00B", indexN), 1, pINdata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] SYMDecryptData(int nAlg, String seesionKey, int fullmode, byte[] pInData) {
|
||||
if (2 == nAlg && 'L' != seesionKey.charAt(0)) {
|
||||
|
||||
Reference in New Issue
Block a user