mirror of
https://gitee.com/dromara/hutool.git
synced 2025-07-17 10:42:00 +08:00
fix sm2 bug
This commit is contained in:
parent
b4568dd2e3
commit
8102b31373
@ -12,6 +12,7 @@
|
|||||||
### Bug修复
|
### Bug修复
|
||||||
* 【json 】 修复解析JSON字符串时配置无法传递问题
|
* 【json 】 修复解析JSON字符串时配置无法传递问题
|
||||||
* 【core 】 修复ServletUtil.readCookieMap空指针问题(issue#827@Github)
|
* 【core 】 修复ServletUtil.readCookieMap空指针问题(issue#827@Github)
|
||||||
|
* 【crypto 】 修复SM2中检查密钥导致的问题(issue#I1EC47@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -182,7 +182,6 @@ public class SM2 extends AbstractAsymmetricCrypto<SM2> {
|
|||||||
if (KeyType.PublicKey != keyType) {
|
if (KeyType.PublicKey != keyType) {
|
||||||
throw new IllegalArgumentException("Encrypt is only support by public key");
|
throw new IllegalArgumentException("Encrypt is only support by public key");
|
||||||
}
|
}
|
||||||
checkKey(keyType);
|
|
||||||
return encrypt(data, new ParametersWithRandom(getCipherParameters(keyType)));
|
return encrypt(data, new ParametersWithRandom(getCipherParameters(keyType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +228,6 @@ public class SM2 extends AbstractAsymmetricCrypto<SM2> {
|
|||||||
if (KeyType.PrivateKey != keyType) {
|
if (KeyType.PrivateKey != keyType) {
|
||||||
throw new IllegalArgumentException("Decrypt is only support by private key");
|
throw new IllegalArgumentException("Decrypt is only support by private key");
|
||||||
}
|
}
|
||||||
checkKey(keyType);
|
|
||||||
return decrypt(data, getCipherParameters(keyType));
|
return decrypt(data, getCipherParameters(keyType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,26 +448,6 @@ public class SM2 extends AbstractAsymmetricCrypto<SM2> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查对应类型的Key是否存在
|
|
||||||
*
|
|
||||||
* @param keyType key类型
|
|
||||||
*/
|
|
||||||
private void checkKey(KeyType keyType) {
|
|
||||||
switch (keyType) {
|
|
||||||
case PublicKey:
|
|
||||||
if (null == this.publicKey) {
|
|
||||||
throw new NullPointerException("No public key provided");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PrivateKey:
|
|
||||||
if (null == this.privateKey) {
|
|
||||||
throw new NullPointerException("No private key provided");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取{@link SM2Engine},此对象为懒加载模式
|
* 获取{@link SM2Engine},此对象为懒加载模式
|
||||||
*
|
*
|
||||||
|
@ -171,9 +171,7 @@ public class SM2Test {
|
|||||||
String id = "31323334353637383132333435363738";
|
String id = "31323334353637383132333435363738";
|
||||||
|
|
||||||
final SM2 sm2 = new SM2(d, x, y);
|
final SM2 sm2 = new SM2(d, x, y);
|
||||||
|
|
||||||
final String sign = sm2.signHex(data, id);
|
final String sign = sm2.signHex(data, id);
|
||||||
|
|
||||||
Assert.assertTrue(sm2.verifyHex(data, sign));
|
Assert.assertTrue(sm2.verifyHex(data, sign));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package cn.hutool.poi.excel;
|
package cn.hutool.poi.excel;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import java.util.List;
|
import cn.hutool.core.lang.Assert;
|
||||||
import java.util.Map;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFPicture;
|
import org.apache.poi.hssf.usermodel.HSSFPicture;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFPictureData;
|
import org.apache.poi.hssf.usermodel.HSSFPictureData;
|
||||||
@ -20,9 +19,9 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
|
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import java.util.HashMap;
|
||||||
import cn.hutool.core.lang.Assert;
|
import java.util.List;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel图片工具类
|
* Excel图片工具类
|
||||||
@ -87,7 +86,7 @@ public class ExcelPicUtil {
|
|||||||
* @return 图片映射,键格式:行_列,值:{@link PictureData}
|
* @return 图片映射,键格式:行_列,值:{@link PictureData}
|
||||||
*/
|
*/
|
||||||
private static Map<String, PictureData> getPicMapXlsx(XSSFWorkbook workbook, int sheetIndex) {
|
private static Map<String, PictureData> getPicMapXlsx(XSSFWorkbook workbook, int sheetIndex) {
|
||||||
final Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
|
final Map<String, PictureData> sheetIndexPicMap = new HashMap<>();
|
||||||
final XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
|
final XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
|
||||||
XSSFDrawing drawing;
|
XSSFDrawing drawing;
|
||||||
for (POIXMLDocumentPart dr : sheet.getRelations()) {
|
for (POIXMLDocumentPart dr : sheet.getRelations()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user