| Modifier and Type | Class and Description |
|---|---|
static class |
SM2.SM2Mode
SM2算法模式
在SM2算法中,C1C2C3为旧标准模式,C1C3C2为新标准模式 |
| Modifier and Type | Field and Description |
|---|---|
protected org.bouncycastle.crypto.signers.SM2Signer |
signer |
algorithm, lock, privateKey, publicKey| Constructor and Description |
|---|
SM2()
构造,生成新的私钥公钥对
|
SM2(byte[] privateKey,
byte[] publicKey)
构造 StringUtils
私钥和公钥同时为空时生成一对新的私钥和公钥StringUtils
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(PrivateKey privateKey,
PublicKey publicKey)
构造 StringUtils
私钥和公钥同时为空时生成一对新的私钥和公钥StringUtils
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(String privateKey,
String publicKey)
构造StringUtils
私钥和公钥同时为空时生成一对新的私钥和公钥StringUtils
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
| Modifier and Type | Method and Description |
|---|---|
protected org.bouncycastle.math.ec.ECMultiplier |
createBasePointMultiplier() |
byte[] |
decrypt(byte[] data,
KeyType keyType)
解密
|
byte[] |
encrypt(byte[] data,
KeyType keyType)
加密,SM2非对称加密的结果由C1,C2,C3三部分组成,其中:
|
void |
init(boolean forEncryption,
org.bouncycastle.crypto.CipherParameters param)
初始化引擎
|
SM2 |
init(PrivateKey privateKey,
PublicKey publicKey)
初始化StringUtils
私钥和公钥同时为空时生成一对新的私钥和公钥StringUtils
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密(签名)或者解密(校验)
|
protected SM2 |
init(String algorithm,
PrivateKey privateKey,
PublicKey publicKey)
初始化
私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密(签名)或者解密(校验) |
byte[] |
processBlock(byte[] in,
int inOff,
int inLen)
处理块,包括加密和解密
|
SM2 |
setMode(SM2.SM2Mode mode)
设置加密类型
|
byte[] |
sign(byte[] data)
用私钥对信息生成数字签名
|
byte[] |
sign(byte[] data,
byte[] id)
用私钥对信息生成数字签名
|
boolean |
verify(byte[] data,
byte[] sign)
用公钥检验数字签名的合法性
|
boolean |
verify(byte[] data,
byte[] sign,
byte[] id)
用公钥检验数字签名的合法性
|
decrypt, decrypt, decryptFromBcd, decryptFromBcd, decryptStr, decryptStr, decryptStrFromBcd, decryptStrFromBcd, encrypt, encrypt, encrypt, encrypt, encryptBase64, encryptBase64, encryptBase64, encryptBase64, encryptBcd, encryptBcd, encryptHex, encryptHex, encryptHex, encryptHexgetKeyByType, getPrivateKey, getPrivateKeyBase64, getPublicKey, getPublicKeyBase64, initKeys, setPrivateKey, setPublicKeypublic SM2()
public SM2(String privateKey, String publicKey)
privateKey - 私钥Hex或Base64表示publicKey - 公钥Hex或Base64表示public SM2(byte[] privateKey,
byte[] publicKey)
privateKey - 私钥publicKey - 公钥public SM2(PrivateKey privateKey, PublicKey publicKey)
privateKey - 私钥publicKey - 公钥protected SM2 init(String algorithm, PrivateKey privateKey, PublicKey publicKey)
Keyspublic byte[] sign(byte[] data)
data - 加密数据public boolean verify(byte[] data,
byte[] sign)
data - 数据sign - 签名public SM2 init(PrivateKey privateKey, PublicKey publicKey)
privateKey - 私钥publicKey - 公钥public byte[] encrypt(byte[] data,
KeyType keyType)
C1 生成随机数的计算出的椭圆曲线点 C2 密文数据 C3 SM3的摘要值
public byte[] decrypt(byte[] data,
KeyType keyType)
public byte[] sign(byte[] data,
byte[] id)
data - 加密数据id - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()public boolean verify(byte[] data,
byte[] sign,
byte[] id)
data - 数据sign - 签名id - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()public void init(boolean forEncryption,
org.bouncycastle.crypto.CipherParameters param)
forEncryption - 是否为加密模式param - CipherParameters,此处应为ParametersWithRandom(加密时)或ECKeyParameters(解密时)public byte[] processBlock(byte[] in,
int inOff,
int inLen)
in - 数据inOff - 数据开始位置inLen - 数据长度public SM2 setMode(SM2.SM2Mode mode)
mode - SM2.SM2Modeprotected org.bouncycastle.math.ec.ECMultiplier createBasePointMultiplier()
Copyright © 2020. All rights reserved.