类 Sm2
java.lang.Object
cn.dinodev.spring.commons.crypto.Sm2
- 作者:
- Cody Lu
-
字段概要
字段修饰符和类型字段说明static final org.bouncycastle.math.ec.custom.gm.SM2P256V1Curvestatic final intstatic final org.bouncycastle.math.ec.ECPointstatic final EllipticCurvestatic final ECParameterSpecstatic final ECPointstatic final org.bouncycastle.crypto.params.ECDomainParametersstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigIntegerstatic final BigInteger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static org.bouncycastle.crypto.params.ECPrivateKeyParametersbuildECPrivateKeyParameters(byte[] privateKey) 构建私钥参数static org.bouncycastle.crypto.params.ECPublicKeyParametersbuildECPublicKeyParameters(byte[] publicKey) 构建公钥参数static byte[]decrypt(byte[] input, byte[] privateKey) 私钥解密, 默认使用SM2Engine.Mode.C1C2C3static byte[]decrypt(byte[] input, byte[] privateKey, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) 私钥解密static byte[]decrypt(byte[] input, org.bouncycastle.crypto.params.ECPrivateKeyParameters ecPrivateKeyParameters, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) 私钥解密static byte[]encrypt(byte[] input, byte[] publicKey) 公钥加密, 默认使用SM2Engine.Mode.C1C2C3static byte[]encrypt(byte[] input, byte[] publicKey, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) 公钥加密static byte[]encrypt(byte[] input, org.bouncycastle.crypto.params.ECPublicKeyParameters ecPublicKeyParameters, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) 公钥加密static KeyPair生成密钥对static intgetCurveLength(org.bouncycastle.crypto.params.ECDomainParameters domainParams) 计算椭圆曲线的长度static byte[]getRawPrivateKey(org.bouncycastle.crypto.params.ECPrivateKeyParameters privateKey) 取私钥里的d值static byte[]getRawPublicKey(org.bouncycastle.crypto.params.ECPublicKeyParameters publicKey) 取公钥里的XY分量static Sm2Signaturesign(byte[] input, byte[] privateKey, byte[] ID) 私钥签名static Sm2Signaturesign(byte[] input, org.bouncycastle.crypto.params.ECPrivateKeyParameters ecPrivateKeyParameters, byte[] ID) 私钥签名static booleanverifySign(byte[] input, Sm2Signature signature, byte[] publicKey, byte[] ID) 公钥验证签名static booleanverifySign(byte[] input, Sm2Signature signature, org.bouncycastle.crypto.params.ECPublicKeyParameters ecPublicKeyParameters, byte[] ID) 公钥验证签名
-
字段详细资料
-
CURVE
public static final org.bouncycastle.math.ec.custom.gm.SM2P256V1Curve CURVE -
SM2_ECC_P
-
SM2_ECC_A
-
SM2_ECC_B
-
SM2_ECC_N
-
SM2_ECC_H
-
SM2_ECC_GX
-
SM2_ECC_GY
-
G_POINT
public static final org.bouncycastle.math.ec.ECPoint G_POINT -
SM2_DOMAIN
public static final org.bouncycastle.crypto.params.ECDomainParameters SM2_DOMAIN -
CURVE_LEN
public static final int CURVE_LEN -
JDK_CURVE
-
JDK_G_POINT
-
JDK_EC_SPEC
-
-
构造器详细资料
-
Sm2
public Sm2()
-
-
方法详细资料
-
getCurveLength
public static int getCurveLength(org.bouncycastle.crypto.params.ECDomainParameters domainParams) 计算椭圆曲线的长度- 参数:
domainParams-- 返回:
-
generateKeyPair
生成密钥对- 返回:
-
buildECPublicKeyParameters
public static org.bouncycastle.crypto.params.ECPublicKeyParameters buildECPublicKeyParameters(byte[] publicKey) 构建公钥参数- 参数:
publicKey-- 返回:
-
buildECPrivateKeyParameters
public static org.bouncycastle.crypto.params.ECPrivateKeyParameters buildECPrivateKeyParameters(byte[] privateKey) 构建私钥参数- 参数:
privateKey-- 返回:
-
getRawPrivateKey
public static byte[] getRawPrivateKey(org.bouncycastle.crypto.params.ECPrivateKeyParameters privateKey) 取私钥里的d值- 参数:
privateKey-- 返回:
- Curve长度的字节数组
-
getRawPublicKey
public static byte[] getRawPublicKey(org.bouncycastle.crypto.params.ECPublicKeyParameters publicKey) 取公钥里的XY分量- 参数:
publicKey-- 返回:
- 2倍Curve长度的字节数组
-
encrypt
public static byte[] encrypt(byte[] input, org.bouncycastle.crypto.params.ECPublicKeyParameters ecPublicKeyParameters, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) throws org.bouncycastle.crypto.InvalidCipherTextException 公钥加密- 参数:
input- 待加密数据ecPublicKeyParameters- 公钥参数mode- 加密方式- 返回:
- 抛出:
org.bouncycastle.crypto.InvalidCipherTextException
-
encrypt
public static byte[] encrypt(byte[] input, byte[] publicKey, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) throws org.bouncycastle.crypto.InvalidCipherTextException 公钥加密- 参数:
input- 待加密数据publicKey- 公钥参数mode- 加密方式- 返回:
- 抛出:
org.bouncycastle.crypto.InvalidCipherTextException
-
encrypt
public static byte[] encrypt(byte[] input, byte[] publicKey) throws org.bouncycastle.crypto.InvalidCipherTextException 公钥加密, 默认使用SM2Engine.Mode.C1C2C3- 参数:
input- 待加密数据publicKey- 公钥参数- 返回:
- 抛出:
org.bouncycastle.crypto.InvalidCipherTextException
-
decrypt
public static byte[] decrypt(byte[] input, org.bouncycastle.crypto.params.ECPrivateKeyParameters ecPrivateKeyParameters, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) throws org.bouncycastle.crypto.InvalidCipherTextException 私钥解密- 参数:
input- 待解密数据ecPrivateKeyParameters- 私钥参数mode- 加密方式- 返回:
- 抛出:
org.bouncycastle.crypto.InvalidCipherTextException
-
decrypt
public static byte[] decrypt(byte[] input, byte[] privateKey, org.bouncycastle.crypto.engines.SM2Engine.Mode mode) throws org.bouncycastle.crypto.InvalidCipherTextException 私钥解密- 参数:
input- 待解密数据privateKey- 私钥参数mode- 加密方式- 返回:
- 抛出:
org.bouncycastle.crypto.InvalidCipherTextException
-
decrypt
public static byte[] decrypt(byte[] input, byte[] privateKey) throws org.bouncycastle.crypto.InvalidCipherTextException 私钥解密, 默认使用SM2Engine.Mode.C1C2C3- 参数:
input- 待解密数据privateKey- 私钥参数- 返回:
- 抛出:
org.bouncycastle.crypto.InvalidCipherTextException
-
sign
public static Sm2Signature sign(byte[] input, org.bouncycastle.crypto.params.ECPrivateKeyParameters ecPrivateKeyParameters, byte[] ID) throws org.bouncycastle.crypto.CryptoException 私钥签名- 参数:
input- 待签名数据ecPrivateKeyParameters- 私钥数据ID- 用户标识- 返回:
- 抛出:
org.bouncycastle.crypto.CryptoException
-
sign
public static Sm2Signature sign(byte[] input, byte[] privateKey, byte[] ID) throws org.bouncycastle.crypto.CryptoException 私钥签名- 参数:
input- 待签名数据privateKey- 私钥数据ID- 用户标识- 返回:
- 抛出:
org.bouncycastle.crypto.CryptoException
-
verifySign
public static boolean verifySign(byte[] input, Sm2Signature signature, org.bouncycastle.crypto.params.ECPublicKeyParameters ecPublicKeyParameters, byte[] ID) throws IOException 公钥验证签名- 参数:
input- 原始数据SM2SignResult- 签名ecPublicKeyParameters- 公钥参数ID- 用户标识- 返回:
- 抛出:
IOException
-
verifySign
public static boolean verifySign(byte[] input, Sm2Signature signature, byte[] publicKey, byte[] ID) throws IOException 公钥验证签名- 参数:
input- 原始数据SM2SignResult- 签名publicKey- 公钥参数ID- 用户标识- 返回:
- 抛出:
IOException
-