Merge pull request #2149 from CherryRum/v5-dev

1.修复 SM2.getD前导0问题
This commit is contained in:
Golden Looly 2022-02-21 01:13:49 +08:00 committed by GitHub
commit e8885395f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ import org.bouncycastle.crypto.signers.PlainDSAEncoding;
import org.bouncycastle.crypto.signers.SM2Signer;
import org.bouncycastle.crypto.signers.StandardDSAEncoding;
import org.bouncycastle.util.BigIntegers;
import org.bouncycastle.util.encoders.Hex;
import java.math.BigInteger;
import java.security.PrivateKey;
@ -521,7 +522,7 @@ public class SM2 extends AbstractAsymmetricCrypto<SM2> {
* @since 5.5.9
*/
public byte[] getD() {
return BigIntegers.asUnsignedByteArray(getDBigInteger());
return BigIntegers.asUnsignedByteArray(32,getDBigInteger());
}
/**
@ -531,7 +532,7 @@ public class SM2 extends AbstractAsymmetricCrypto<SM2> {
* @since 5.7.17
*/
public String getDHex() {
return String.format("%064x", new BigInteger(1, getD()));
return new String(Hex.encode(getD()));
}
/**