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 java.security.spec.EllipticCurve |
JDK_CURVE |
static java.security.spec.ECParameterSpec |
JDK_EC_SPEC |
static java.security.spec.ECPoint |
JDK_G_POINT |
static java.math.BigInteger |
SM2_ECC_A |
static java.math.BigInteger |
SM2_ECC_B |
static java.math.BigInteger |
SM2_ECC_GX |
static java.math.BigInteger |
SM2_ECC_GY |
static java.math.BigInteger |
SM2_ECC_H |
static java.math.BigInteger |
SM2_ECC_N |
static java.math.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(java.lang.String srcData,
java.lang.String publicKey)
加密数据
|
static java.security.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 java.math.BigInteger SM2_ECC_P
public static final java.math.BigInteger SM2_ECC_A
public static final java.math.BigInteger SM2_ECC_B
public static final java.math.BigInteger SM2_ECC_N
public static final java.math.BigInteger SM2_ECC_H
public static final java.math.BigInteger SM2_ECC_GX
public static final java.math.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 java.security.spec.EllipticCurve JDK_CURVE
public static final java.security.spec.ECPoint JDK_G_POINT
public static final java.security.spec.ECParameterSpec JDK_EC_SPEC
public static byte[] encrypt(java.lang.String srcData,
java.lang.String publicKey)
throws java.lang.Exception
srcData - publicKey - java.lang.Exceptionpublic static org.bouncycastle.crypto.AsymmetricCipherKeyPair generateKeyPairParameter()
public static java.security.KeyPair generateKeyPair()
throws java.security.NoSuchProviderException,
java.security.NoSuchAlgorithmException,
java.security.InvalidAlgorithmParameterException
java.security.NoSuchProviderExceptionjava.security.NoSuchAlgorithmExceptionjava.security.InvalidAlgorithmParameterExceptionpublic 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 © 2019. All Rights Reserved.