程序包 cn.benma666.sm
类 SM2
java.lang.Object
cn.benma666.sm.SM2
SM2公钥加密算法实现 包括 -签名,验签 -密钥交换 -公钥加密,私钥解密
- 作者:
- Potato
-
嵌套类概要
嵌套类 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明decrypt(byte[] encryptData, BigInteger privateKey) 私钥解密byte[]encrypt(byte[] inputBuffer, org.bouncycastle.math.ec.ECPoint publicKey) 公钥加密byte[]公钥加密byte[]公钥加密 * @param input 加密原文voidexportPrivateKey(BigInteger privateKey, String path) 导出私钥到本地voidexportPublicKey(org.bouncycastle.math.ec.ECPoint publicKey, String path) 导出公钥到本地生成密钥对importPrivateKey(String path) 从本地导入私钥org.bouncycastle.math.ec.ECPointimportPublicKey(String path) 从本地导入公钥booleanisDebug()static voidstatic voidprintHexString(byte[] b) 以16进制打印字节数组voidsetDebug(boolean debug) sign(String M, String IDA, SM2KeyPair keyPair) 签名booleanverify(String M, SM2.Signature signature, String IDA, org.bouncycastle.math.ec.ECPoint aPublicKey) 验签
-
构造器详细资料
-
SM2
public SM2() -
SM2
public SM2(boolean debug)
-
-
方法详细资料
-
isDebug
public boolean isDebug() -
setDebug
public void setDebug(boolean debug) -
printHexString
public static void printHexString(byte[] b) 以16进制打印字节数组- 参数:
b-
-
encrypt
公钥加密 * @param input 加密原文- 参数:
publicKey- 公钥- 返回:
-
encrypt
public byte[] encrypt(byte[] inputBuffer, org.bouncycastle.math.ec.ECPoint publicKey) 公钥加密- 参数:
inputBuffer- 加密原文publicKey- 公钥- 返回:
-
encrypt
公钥加密- 参数:
inputfile- 加密原文publicKey- 公钥- 返回:
- 抛出:
Exception
-
decrypt
私钥解密- 参数:
encryptData- 密文数据字节数组privateKey- 解密私钥- 返回:
-
generateKeyPair
生成密钥对- 返回:
-
exportPublicKey
导出公钥到本地- 参数:
publicKey-path-
-
importPublicKey
从本地导入公钥- 参数:
path-- 返回:
-
exportPrivateKey
导出私钥到本地- 参数:
privateKey-path-
-
importPrivateKey
从本地导入私钥- 参数:
path-- 返回:
-
sign
签名- 参数:
M- 签名信息IDA- 签名方唯一标识keyPair- 签名方密钥对- 返回:
- 签名
-
verify
public boolean verify(String M, SM2.Signature signature, String IDA, org.bouncycastle.math.ec.ECPoint aPublicKey) 验签- 参数:
M- 签名信息signature- 签名IDA- 签名方唯一标识aPublicKey- 签名方公钥- 返回:
- true or false
-
main
-