public class SM2Util extends GMBaseUtil
| Modifier and Type | Field and Description |
|---|---|
static org.bouncycastle.math.ec.custom.gm.SM2P256V1Curve |
CURVE |
static int |
CURVE_LEN |
static org.bouncycastle.crypto.params.ECDomainParameters |
DOMAIN_PARAMS |
static org.bouncycastle.math.ec.ECPoint |
G_POINT |
static EllipticCurve |
JDK_CURVE |
static ECParameterSpec |
JDK_EC_SPEC |
static ECPoint |
JDK_G_POINT |
static BigInteger |
SM2_ECC_A |
static BigInteger |
SM2_ECC_B |
static BigInteger |
SM2_ECC_GX |
static BigInteger |
SM2_ECC_GY |
static BigInteger |
SM2_ECC_H |
static BigInteger |
SM2_ECC_N |
static BigInteger |
SM2_ECC_P |
| Constructor and Description |
|---|
SM2Util() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decrypt(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey priKey,
byte[] sm2Cipher) |
static byte[] |
decrypt(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKeyParameters,
byte[] sm2Cipher)
ECC私钥解密
|
static byte[] |
encrypt(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey pubKey,
byte[] srcData) |
static byte[] |
encrypt(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKeyParameters,
byte[] srcData)
ECC公钥加密
|
static byte[] |
encrypt(String srcData,
String publicKey)
加密数据
|
static KeyPair |
generateKeyPair() |
static org.bouncycastle.crypto.AsymmetricCipherKeyPair |
generateKeyPairParameter()
生成ECC密钥对
|
static byte[] |
getRawPrivateKey(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey privateKey)
只获取私钥里的d,32字节
|
static byte[] |
getRawPublicKey(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey publicKey)
只获取公钥里的XY分量,64字节
|
public static final org.bouncycastle.math.ec.custom.gm.SM2P256V1Curve CURVE
public static final BigInteger SM2_ECC_P
public static final BigInteger SM2_ECC_A
public static final BigInteger SM2_ECC_B
public static final BigInteger SM2_ECC_N
public static final BigInteger SM2_ECC_H
public static final BigInteger SM2_ECC_GX
public static final BigInteger SM2_ECC_GY
public static final org.bouncycastle.math.ec.ECPoint G_POINT
public static final org.bouncycastle.crypto.params.ECDomainParameters DOMAIN_PARAMS
public static final int CURVE_LEN
public static final EllipticCurve JDK_CURVE
public static final ECPoint JDK_G_POINT
public static final ECParameterSpec JDK_EC_SPEC
public static byte[] encrypt(String srcData, String publicKey) throws Exception
srcData - publicKey - Exceptionpublic static org.bouncycastle.crypto.AsymmetricCipherKeyPair generateKeyPairParameter()
public static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static byte[] getRawPrivateKey(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey privateKey)
privateKey - public static byte[] getRawPublicKey(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey publicKey)
publicKey - public static byte[] encrypt(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey pubKey,
byte[] srcData)
throws org.bouncycastle.crypto.InvalidCipherTextException
org.bouncycastle.crypto.InvalidCipherTextExceptionpublic static byte[] encrypt(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKeyParameters,
byte[] srcData)
throws org.bouncycastle.crypto.InvalidCipherTextException
pubKeyParameters - ECC公钥srcData - 源数据org.bouncycastle.crypto.InvalidCipherTextExceptionpublic static byte[] decrypt(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey priKey,
byte[] sm2Cipher)
throws org.bouncycastle.crypto.InvalidCipherTextException
org.bouncycastle.crypto.InvalidCipherTextExceptionpublic static byte[] decrypt(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKeyParameters,
byte[] sm2Cipher)
throws org.bouncycastle.crypto.InvalidCipherTextException
priKeyParameters - ECC私钥sm2Cipher - SM2密文,实际包含三部分:ECC公钥、真正的密文、公钥和原文的SM3-HASH值org.bouncycastle.crypto.InvalidCipherTextExceptionCopyright © 2021. All rights reserved.