资源简介
大宝CA完整地实现了国密SM2、SM3、SM4算法和JKS功能,可加密、解密、数字签名、验证、摘要计算,可存储和应用SM2软证书和软密钥。可惜没有源码,只有详细的测试和应用样例代码。
代码片段和文件信息
/**
*
*/
package com.doubleca.sample.pki.jce;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.KeyStore.Entry;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Enumeration;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import com.doubleca.b146.c16.util.encoders.base64;
import doubleca.security.provider.DoubleCA;
import doubleca.security.provider.jdk7.sm4.SM4KeySpec;
/**
* @author
*
*/
public class Test
{
private static final String SIGNATURE_KEY_ALGORITHM = “SM2“;
private static final String SIGNATURE_ALGORITHM = “SM3withSM2“;
private static final int SIGNATURE_KEY_SIZE = 256;
private static final String DIGEST_ALGORITHM = “SM3“;
private static final String CIPHER_KEY_ALGORITHM = “SM4“;
// private static final String CIPHER_ALGORITHM = “SM4/ECB/PKCS5Padding“;
private static final String CIPHER_ALGORITHM = “SM4/CBC/PKCS5Padding“;
// private static final String CIPHER_ALGORITHM = “SM4/ECB/NOPadding“;
// private static final String CIPHER_ALGORITHM = “SM4/CBC/NOPadding“;
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
/**
* 说明:JDK7版本及以上,JDK需要使用无限制的策略文件 UnlimitedJCEPolicy
* 否则,SM2密钥长度为256位,JCE无法调用成功
*/
try
{
Security.addProvider(new DoubleCA());
System.out.println(““);
System.out.println(“TestSM2KeyPairGenerator“);
KeyPair key = TestSM2KeyPairGenerator();
System.out.println(““);
System.out.println(“TestSM2KeyFactory“);
TestSM2KeyFactory(key.getPublic().getEncoded() key.getPrivate().getEncoded());
System.out.println(““);
System.out.println(“TestSM3Digest“);
TestSM3Digest();
System.out.println(““);
System.out.println(“TestSM4Cipher“);
SecretKey sm4key = TestSM4Cipher();
System.out.println(““);
System.out.println(“TestSM2AsymmetricCipher“);
TestSM2AsymmetricCipher(key);
System.out.println(““);
System.out.println(“TestSM2Signature“);
TestSM2Signature(key);
System.out.println(““);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-05 20:12 jce-doubleca-sample\
文件 376 2018-03-05 11:44 jce-doubleca-sample\.classpath
文件 395 2018-03-05 11:28 jce-doubleca-sample\.project
目录 0 2018-03-05 20:12 jce-doubleca-sample\.settings\
文件 598 2018-03-05 11:28 jce-doubleca-sample\.settings\org.eclipse.jdt.core.prefs
目录 0 2018-03-05 22:52 jce-doubleca-sample\bin\
目录 0 2018-03-05 20:12 jce-doubleca-sample\lib\
文件 918584 2018-03-05 11:31 jce-doubleca-sample\lib\doubleca-jce-0.9.2-SNAPSHOT.jar
目录 0 2018-03-05 21:43 jce-doubleca-sample\resources\
文件 3429 2018-03-05 21:29 jce-doubleca-sample\resources\1E7A9FA952485DBD8452B1B7BDBB8DF4.dcks
文件 590 2018-03-05 21:33 jce-doubleca-sample\resources\sm2cert.cer
文件 1377 2018-03-05 22:44 jce-doubleca-sample\resources\SM2SigningCert.dcks
目录 0 2018-03-05 20:12 jce-doubleca-sample\src\
目录 0 2018-03-05 20:12 jce-doubleca-sample\src\com\
目录 0 2018-03-05 20:12 jce-doubleca-sample\src\com\doubleca\
目录 0 2018-03-05 20:12 jce-doubleca-sample\src\com\doubleca\sample\
目录 0 2018-03-05 20:12 jce-doubleca-sample\src\com\doubleca\sample\pki\
目录 0 2018-03-05 20:12 jce-doubleca-sample\src\com\doubleca\sample\pki\jce\
文件 12823 2018-03-05 22:48 jce-doubleca-sample\src\com\doubleca\sample\pki\jce\Test.java
- 上一篇:Main.java
- 下一篇:多种设计模式综合练习
相关资源
- JAVA国密算法pnc,sm2,sm3,sm4,jar包直
- 阿里、jcenter安全证书.zip
- Java Cryptography Extension (JCE) 无限强度
- 国密算法SM4加解密算法JAVA
- 真正国密SM2SM3SM4的前后台配套js和ja
- java实现国密SM3算法
- JAVA数据加密jar包之sunjce_provider.rar
- SMS4国密封装接口直接可用java.zip
- jar.zip sunjce_provider.jar包
- js+java实现国密算法SM2
- 国密算法SM3_SM4.zip
- 基于国密SM2加解密(JAVA版)
- 国密算法sm4的java实现
- SM 国密算法Java+JS
- JCE无限制权限策略文件jdk67
- sm4国密算法 java实现
- SM2&SM3&SM4国密规范及Java软算法实现
- zipkin-server-2.12.9.jar
- java 国密算法实现包含SM2 SM3 SM4和数字
- 基于Java的SM2_SM3_SM4国密算法java源代码
- SM2_SM3_SM4国密算法java源码+PC工具
- sm2-sm4国密算法工具包及工具类
- SM2、SM3、SM4国密算法Java实现(含详细
- 国密SM3,JS版,粘贴即用,适用于前端
- jce 1.8 download
- 国密sm2,sm3,sm4计算小工具
- UnlimitedJCEPolicy --JCE策略文件包含适用
- JCE_Policy_8
- 加密解密字符串找不到 com.sun.crypto.
- sunjce_provider.jar
评论
共有 条评论