java sm_Java国密SM2/SM3/SM4及证书

1. 使用BC库1.59版本已经可以支持国密算法SM2/SM3/SM4,某大神写的详细测试例子:https://github.com/ZZMarquis/gmhelper

2. 制作证书参考网上资料简单例子;

``` java

public static void genSM2CertBySelf() throws OperatorCreationException, IOException, CertificateException {

String dn = "CN=dfg, OU=aert, O=45y, L=sdfg, ST=fg, C=CN";

long year = 360 * 24 * 60 * 60 * 1000;

Date notBefore = new Date();

Date notAfter = new Date(notBefore.getTime() + year);

//证书的名称

String fileName = "self"+new Date().getTime()/1000;

String path  = "/test/gmhelper/";

String rootCertPath = path+fileName+".der";

AsymmetricCipherKeyPair kp = Sm2Util.generateKeyPair();

ECPrivateKeyParameters bcecPrivateKey = (ECPrivateKeyParameters)kp.getPrivate();

ECPublicKeyParamete

你可能感兴趣的:(java,sm)