public class SM2Util extends GMBaseUtil
DEFAULT_ENCODING, INIT_SM4_KEY, SERIALIZE_KEY_PAIR, SM2KEY_PRIVATE_KEY, SM2KEY_PUBLIC_KEY, SM4_GROUP_BYTES, SM4KEY| 构造器和说明 |
|---|
SM2Util() |
| 限定符和类型 | 方法和说明 |
|---|---|
static org.bouncycastle.crypto.params.ECPrivateKeyParameters |
convertPrivateKeyToParameters(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey ecPriKey)
获取ECC模式私钥
|
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 KeyPair |
generateKeyPair()
获取密钥
|
static byte[] |
sign(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey priKey,
byte[] srcData) |
static byte[] |
sign(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKeyParameters,
byte[] withId,
byte[] srcData)
ECC私钥签名
|
static boolean |
verify(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey pubKey,
byte[] withId,
byte[] srcData,
byte[] sign) |
static boolean |
verify(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKeyParameters,
byte[] srcData,
byte[] sign) |
static boolean |
verify(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKeyParameters,
byte[] withId,
byte[] srcData,
byte[] sign)
ECC公钥验签
|
decryptString, decryptToken, encryptString, getSign, getToken, initSmKeyValue, pwToCipherPassword, verifyBySignpublic static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException
NoSuchProviderExceptionNoSuchAlgorithmExceptionInvalidAlgorithmParameterExceptionpublic static byte[] encrypt(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey pubKey,
byte[] srcData)
throws org.bouncycastle.crypto.InvalidCipherTextException
pubKey - 公钥加密srcData - 原文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.InvalidCipherTextExceptionpublic static byte[] sign(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey priKey,
byte[] srcData)
throws org.bouncycastle.crypto.CryptoException
org.bouncycastle.crypto.CryptoExceptionpublic static byte[] sign(org.bouncycastle.crypto.params.ECPrivateKeyParameters priKeyParameters,
byte[] withId,
byte[] srcData)
throws org.bouncycastle.crypto.CryptoException
priKeyParameters - ECC私钥withId - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()srcData - 源数据org.bouncycastle.crypto.CryptoExceptionpublic static boolean verify(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKeyParameters,
byte[] srcData,
byte[] sign)
public static boolean verify(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey pubKey,
byte[] withId,
byte[] srcData,
byte[] sign)
public static boolean verify(org.bouncycastle.crypto.params.ECPublicKeyParameters pubKeyParameters,
byte[] withId,
byte[] srcData,
byte[] sign)
pubKeyParameters - ECC公钥withId - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()srcData - 原文sign - 签名public static org.bouncycastle.crypto.params.ECPrivateKeyParameters convertPrivateKeyToParameters(org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey ecPriKey)
ecPriKey - 私钥Copyright © 2019-Now–2021. All rights reserved.