mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
feature: 修复sm2构造方法NullPointerException
Closes https://gitee.com/dromara/hutool/issues/I66OCK
This commit is contained in:
parent
ecde508346
commit
988e59eafd
@ -244,6 +244,9 @@ public class ECKeyUtil {
|
|||||||
* @return ECPrivateKeyParameters
|
* @return ECPrivateKeyParameters
|
||||||
*/
|
*/
|
||||||
public static ECPrivateKeyParameters toPrivateParams(String d, ECDomainParameters domainParameters) {
|
public static ECPrivateKeyParameters toPrivateParams(String d, ECDomainParameters domainParameters) {
|
||||||
|
if (null == d) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return toPrivateParams(BigIntegers.fromUnsignedByteArray(SecureUtil.decode(d)), domainParameters);
|
return toPrivateParams(BigIntegers.fromUnsignedByteArray(SecureUtil.decode(d)), domainParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +219,17 @@ public class SM2Test {
|
|||||||
Assert.assertTrue(sm2.verifyHex(data, sign));
|
Assert.assertTrue(sm2.verifyHex(data, sign));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sm2WithNullPriPointTest() {
|
||||||
|
String x = "9EF573019D9A03B16B0BE44FC8A5B4E8E098F56034C97B312282DD0B4810AFC3";
|
||||||
|
String y = "CC759673ED0FC9B9DC7E6FA38F0E2B121E02654BF37EA6B63FAF2A0D6013EADF";
|
||||||
|
String q = "04" + x + y;
|
||||||
|
final SM2 sm1 = new SM2(null, x, y);
|
||||||
|
final SM2 sm2 = new SM2(null, q);
|
||||||
|
Assert.assertNotNull(sm1);
|
||||||
|
Assert.assertNotNull(sm2);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sm2PlainWithPointTest() {
|
public void sm2PlainWithPointTest() {
|
||||||
// 测试地址:https://i.goto327.top/CryptTools/SM2.aspx?tdsourcetag=s_pctim_aiomsg
|
// 测试地址:https://i.goto327.top/CryptTools/SM2.aspx?tdsourcetag=s_pctim_aiomsg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user