| Modifier and Type | Field and Description |
|---|---|
protected org.bouncycastle.crypto.engines.SM2Engine |
engine |
protected org.bouncycastle.crypto.signers.SM2Signer |
signer |
algorithm, lock, privateKey, publicKey| Constructor and Description |
|---|
SM2()
构造,生成新的私钥公钥对
|
SM2(byte[] privateKey,
byte[] publicKey)
构造
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(byte[] privateKey,
byte[] publicKeyPointX,
byte[] publicKeyPointY)
构造
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(org.bouncycastle.crypto.params.ECPrivateKeyParameters privateKeyParams,
org.bouncycastle.crypto.params.ECPublicKeyParameters publicKeyParams)
构造
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(PrivateKey privateKey,
PublicKey publicKey)
构造
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(String privateKeyStr,
String publicKeyStr)
构造
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
SM2(String privateKeyHex,
String publicKeyPointXHex,
String publicKeyPointYHex)
构造
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] data,
KeyType keyType)
解密
|
byte[] |
encrypt(byte[] data,
KeyType keyType)
加密,SM2非对称加密的结果由C1,C2,C3三部分组成,其中:
|
SM2 |
init()
初始化
私钥和公钥同时为空时生成一对新的私钥和公钥
私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密(签名)或者解密(校验)
|
SM2 |
initKeys()
生成公钥和私钥
|
SM2 |
setDigest(org.bouncycastle.crypto.Digest digest)
设置Hash算法
|
SM2 |
setEncoding()
设置DSA signatures的编码为PlainDSAEncoding
|
SM2 |
setEncoding(org.bouncycastle.crypto.signers.DSAEncoding encoding)
设置DSA signatures的编码
|
SM2 |
setMode(org.bouncycastle.crypto.engines.SM2Engine.Mode mode)
设置加密类型
|
SM2 |
setPrivateKey(PrivateKey privateKey)
设置私钥
|
SM2 |
setPrivateKeyParams(org.bouncycastle.crypto.params.ECPrivateKeyParameters privateKeyParams)
设置私钥参数
|
SM2 |
setPublicKey(PublicKey publicKey)
设置公钥
|
SM2 |
setPublicKeyParams(org.bouncycastle.crypto.params.ECPublicKeyParameters publicKeyParams)
设置公钥参数
|
byte[] |
sign(byte[] data)
用私钥对信息生成数字签名
|
byte[] |
sign(byte[] data,
byte[] id)
用私钥对信息生成数字签名
|
String |
sign(String dataHex)
用私钥对信息生成数字签名
|
String |
sign(String dataHex,
String idHex)
用私钥对信息生成数字签名
|
boolean |
verify(byte[] data,
byte[] sign)
用公钥检验数字签名的合法性
|
boolean |
verify(byte[] data,
byte[] sign,
byte[] id)
用公钥检验数字签名的合法性
|
boolean |
verify(String dataHex,
String signHex)
用公钥检验数字签名的合法性
|
boolean |
verify(String dataHex,
String signHex,
String idHex)
用公钥检验数字签名的合法性
|
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, init, setKeyprotected org.bouncycastle.crypto.engines.SM2Engine engine
protected org.bouncycastle.crypto.signers.SM2Signer signer
public SM2()
public SM2(String privateKeyStr, String publicKeyStr)
privateKeyStr - 私钥Hex或Base64表示publicKeyStr - 公钥Hex或Base64表示public SM2(byte[] privateKey,
byte[] publicKey)
privateKey - 私钥publicKey - 公钥public SM2(PrivateKey privateKey, PublicKey publicKey)
privateKey - 私钥publicKey - 公钥public SM2(String privateKeyHex, String publicKeyPointXHex, String publicKeyPointYHex)
privateKeyHex - 私钥16进制publicKeyPointXHex - 公钥X16进制publicKeyPointYHex - 公钥Y16进制public SM2(byte[] privateKey,
byte[] publicKeyPointX,
byte[] publicKeyPointY)
privateKey - 私钥publicKeyPointX - 公钥XpublicKeyPointY - 公钥Ypublic SM2(org.bouncycastle.crypto.params.ECPrivateKeyParameters privateKeyParams,
org.bouncycastle.crypto.params.ECPublicKeyParameters publicKeyParams)
privateKeyParams - 私钥publicKeyParams - 公钥public SM2 init()
public byte[] encrypt(byte[] data,
KeyType keyType)
throws org.aoju.bus.core.lang.exception.InstrumentException
C1 生成随机数的计算出的椭圆曲线点 C2 密文数据 C3 SM3的摘要值
public byte[] decrypt(byte[] data,
KeyType keyType)
public byte[] sign(byte[] data)
data - 加密数据public String sign(String dataHex, String idHex)
dataHex - 被签名的数据数据idHex - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()public byte[] sign(byte[] data,
byte[] id)
data - 被签名的数据数据id - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()public boolean verify(String dataHex, String signHex)
dataHex - 数据签名后的数据signHex - 签名public boolean verify(byte[] data,
byte[] sign)
data - 签名后的数据sign - 签名public boolean verify(String dataHex, String signHex, String idHex)
dataHex - 数据签名后的数据的Hex值signHex - 签名的Hex值idHex - ID的Hex值public boolean verify(byte[] data,
byte[] sign,
byte[] id)
data - 数据签名后的数据sign - 签名id - 可以为null,若为null,则默认withId为字节数组:"1234567812345678".getBytes()public SM2 setPrivateKey(PrivateKey privateKey)
KeyssetPrivateKey in class Keys<SM2>privateKey - 私钥public SM2 setPrivateKeyParams(org.bouncycastle.crypto.params.ECPrivateKeyParameters privateKeyParams)
privateKeyParams - 私钥参数public SM2 setPublicKey(PublicKey publicKey)
KeyssetPublicKey in class Keys<SM2>publicKey - 公钥public SM2 setPublicKeyParams(org.bouncycastle.crypto.params.ECPublicKeyParameters publicKeyParams)
publicKeyParams - 公钥参数public SM2 setMode(org.bouncycastle.crypto.engines.SM2Engine.Mode mode)
mode - SM2Engine.Modepublic SM2 setEncoding()
public SM2 setEncoding(org.bouncycastle.crypto.signers.DSAEncoding encoding)
encoding - DSAEncoding实现public SM2 setDigest(org.bouncycastle.crypto.Digest digest)
digest - Digest实现Copyright © 2021. All rights reserved.