mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
修复bytehelper & VlInt中的已知bug
This commit is contained in:
1 parent
227d10a391
commit
2ad446ca2c
29 files changed
+315
-80
No files matched your search
@@ -165,7 +165,7 @@ public class Certificate {
|
||||
"version=" + version +
|
||||
", serialNumber=" + serialNumber +
|
||||
", publicKey=" + publicKey +
|
||||
", signature=" + ByteUtils.toHexString(signature) +
|
||||
", signature=" + (signature != null ? ByteUtils.toHexString(signature) : "null") +
|
||||
", signatureAlgorithm=" + signatureAlgorithm +
|
||||
", publicKeyAlgorithm=" + publicKeyAlgorithm +
|
||||
", issueTo='" + issueTo + '\'' +
|
||||
|
||||
@@ -46,7 +46,7 @@ public class InnerCertificate {
|
||||
return "InnerCertificate{" +
|
||||
"tbsCertificate=" + tbsCertificate.toString() +
|
||||
", signatureAlgorithm=" + signatureAlgorithm +
|
||||
", signatureValue=" + ByteUtils.toHexString(signatureValue) +
|
||||
", signatureValue=" + (signatureValue != null ? ByteUtils.toHexString(signatureValue) : "null") +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class TbsCertificate {
|
||||
return "TbsCertificate{" +
|
||||
"version=" + version +
|
||||
", serialNumber=" + serialNumber +
|
||||
", publicKey=" + ByteUtils.toHexString(publicKey) +
|
||||
", publicKey=" + (publicKey != null ?ByteUtils.toHexString(publicKey) : "null") +
|
||||
", signatureAlgorithm=" + signatureAlgorithm +
|
||||
", publicKeyAlgorithm=" + publicKeyAlgorithm +
|
||||
", issueTo='" + issueTo + '\'' +
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -29,6 +29,14 @@ public class SM4 {
|
||||
*/
|
||||
public static final int DEFAULT_KEY_SIZE = 128;
|
||||
|
||||
/**
|
||||
* 生成16字节的sm4 key
|
||||
* @param
|
||||
* @return byte[]
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @author hongyu guo
|
||||
* @date 2021/3/15
|
||||
**/
|
||||
public static byte[] generateKey() throws NoSuchAlgorithmException, NoSuchProviderException {
|
||||
return generateKey(DEFAULT_KEY_SIZE);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,14 @@ public class SM2Base {
|
||||
parameterSpec.getN(), parameterSpec.getH());
|
||||
return new ECPublicKeyParameters(ecPubKey.getQ(), domainParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一对sm2公私钥
|
||||
* @param
|
||||
* @return minsecurity.crypto.sm2.SM2KeyPair
|
||||
* @throws
|
||||
* @author hongyu guo
|
||||
* @date 2021/3/15
|
||||
**/
|
||||
public static SM2KeyPair generateSM2KeyPair(){
|
||||
return SM2KeyPair.generateKeyPair();
|
||||
}
|
||||
|
||||
@@ -336,8 +336,8 @@ public class Identity {
|
||||
"Name='" + Name + '\'' +
|
||||
", KeyParam.signAlgo=" + KeyParam.SignatureAlgorithm +
|
||||
", KeyParam.pubAlgo=" + KeyParam.PublicKeyAlgorithm +
|
||||
", Prikey=" + ByteUtils.toHexString(Prikey.getBytes()) +
|
||||
", pubKey=" + ByteUtils.toHexString(Pubkey.getBytes()) +
|
||||
", Prikey=" + (Prikey != null ? ByteUtils.toHexString(Prikey.getBytes()) : "null") +
|
||||
", pubKey=" + (Pubkey != null ? ByteUtils.toHexString(Pubkey.getBytes()) : "null") +
|
||||
", PrikeyRawByte=" + (PrikeyRawByte == null ? "null":ByteUtils.toHexString(PrikeyRawByte)) +
|
||||
", Pubkey=" + Pubkey +
|
||||
", Passwd='" + Passwd + '\'' +
|
||||
|
||||
@@ -81,7 +81,8 @@ public class InnerIdentity {
|
||||
public String toString() {
|
||||
return "InnerIdentity{" +
|
||||
"Name='" + Name + '\'' +
|
||||
", KeyParam=" + KeyParam +
|
||||
", KeyParam.PublicKeyAlgorithm=" + KeyParam.PublicKeyAlgorithm +
|
||||
", KeyParam.SignatureAlgorithm=" + KeyParam.SignatureAlgorithm +
|
||||
", Prikey=" + (Prikey == null ? "null" : ByteUtils.toHexString(Prikey)) +
|
||||
", Pubkey=" + (Pubkey == null ? "null" : ByteUtils.toHexString(Pubkey)) +
|
||||
", Passwd='" + Passwd + '\'' +
|
||||
|
||||
Reference in new issue
Block a user