修复bytehelper & VlInt中的已知bug

This commit is contained in:
ghy committed 2021-03-15 20:46:03 +08:00
1 parent 227d10a391
commit 2ad446ca2c
29 files changed
+315 -80

No files matched your search

+19 -1
View File
@@ -13,6 +13,7 @@ import minsecurity.crypto.sm2.SM2PublicKey;
*/
public class KeyUtils {
/**
* 可以理解为公钥的"构造函数"
* 返回的数据类型为PublicKeyInterface接口, 必要时调用者需要手动将类型强制转化为需要的类型
* @param bytesOfPublicKey 公钥的bytes数组
* @param algorithm 公钥类型
@@ -33,7 +34,16 @@ public class KeyUtils {
return null;
}
}
/**
* 可以理解为私钥的"构造函数"
* 返回的数据类型为PrivateKeyInterface接口, 必要时调用者需要手动将类型强制转化为需要的类型
* @param bytesOfPrivateKey 私钥的bytes数组
* @param algorithm 私钥类型
* @return minsecurity.crypto.PrivateKeyInterface
* @throws
* @author hongyu guo
* @date 2021/3/15
**/
public static PrivateKeyInterface unMarshalPrivateKey(byte[] bytesOfPrivateKey, int algorithm){
if(bytesOfPrivateKey == null || bytesOfPrivateKey.length == 0){
return null;
@@ -48,6 +58,14 @@ public class KeyUtils {
}
}
/**
* 获取一个16字节的byte数组, 可用作sm4的key
* @param passwd 密码
* @return byte[]
* @throws
* @author hongyu guo
* @date 2021/3/15
**/
public static byte[] get16bytePasswd(byte[] passwd) {
byte[] hashPasswd = HashAlgo.sm3(passwd);
if( hashPasswd.length == 32){