- 浏览: 524000 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
宋贝贝:
您好,能麻烦您把这个包fisher.man.jce.PKCS1 ...
生成基于RSA与SM2数字证书的请求PKCS10CertificationRequest -
upset_ming:
DoubleCA的JCE实现了SM2算法的密钥协商,国密SM2 ...
生成基于RSA与SM2数字证书的请求PKCS10CertificationRequest -
stormlyf:
您好,能麻烦您把这个包fisher.man.jce.PKCS1 ...
生成基于RSA与SM2数字证书的请求PKCS10CertificationRequest -
kris_zhang:
CPU型号怎么弄?
Java获取电脑CPU个数及系统信息 -
linxinlong11007:
你好,我需要FishermanJCE,请问能发份这个包给我么? ...
生成基于RSA与SM2数字证书的请求PKCS10CertificationRequest
申请证书时生成的req文件需要:主题 密钥对 签名加密算法
写道
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.SignatureException;
import javax.security.auth.x500.X500Principal;
import sun.misc.BASE64Encoder;
/**
* @param algorithm签名算法 1.SHA1withRSA 2.SM3WITHSM2
* @param dn主题
* @param keyPair密钥对
* @param keyType密钥类型 SM2|RSA
* @return 返回p10请求的字符串
* @throws SignatureException
* @throws NoSuchProviderException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws KeyPairException
*/
private static String getP10ReqestBC(String algorithm, String dn, KeyPair keyPair,String keyType) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException
{
String p10RequestString = null;
byte[] p10buffer = null;
if(keyType.equals("SM2")){
fisher.man.jce.PKCS10CertificationRequest p10Request;
p10Request = new fisher.man.jce.PKCS10CertificationRequest(
algorithm, new X500Principal(dn), keyPair.getPublic(),
null, keyPair.getPrivate());
p10buffer = p10Request.getDEREncoded();
}else{
org.bouncycastle.jce.PKCS10CertificationRequest p10Request;
p10Request = new org.bouncycastle.jce.PKCS10CertificationRequest(
algorithm, new X500Principal(dn), keyPair.getPublic(),
null, keyPair.getPrivate());
p10buffer = p10Request.getDEREncoded();
}
p10RequestString = new BASE64Encoder().encode(p10buffer);
return p10RequestString;
}
public static void main(String[] args) throws IOException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException {
// algorithm签名算法 SM2
String algorithm = "SM3WITHSM2";
// dn主题
String dn = "CN=dfg, OU=aert, O=45y, L=sdfg, ST=fg, C=CN";
KeyPairGenerator ecPair = null;
SecureRandom rand = null;
rand = SecureRandom.getInstance("TrueRandom", "FishermanJCE");
ecPair = KeyPairGenerator.getInstance("SM2", "FishermanJCE");
ecPair.initialize(256, new SecureRandom());
// keyPair密钥对
KeyPair keyPair = ecPair.generateKeyPair();
String requestReq = getP10ReqestBC(algorithm,dn,keyPair,"SM2");
System.out.println("SM2 私钥=" + keyPair.getPrivate());
System.out.println("SM2 公钥=" + keyPair.getPublic());
System.out.println("SM2 p10请求的字符串=" + requestReq);
System.err.println("************************************");
System.err.println("************************************");
System.err.println("************************************");
// algorithm签名算法 RSA
String algorithm2 = "SHA1withRSA";
// dn主题
String dn2 = "CN=zdfg, OU=ert, O=er, L=fgj, ST=vfgh, C=CN";
rand = SecureRandom.getInstance("TrueRandom", "FishermanJCE");
ecPair = KeyPairGenerator.getInstance("RSA", "BC");
ecPair.initialize(1024, new SecureRandom());
// keyPair密钥对
KeyPair keyPair2 = ecPair.generateKeyPair();
String requestReq2 = getP10ReqestBC(algorithm2,dn2,keyPair2,"RSA");
System.out.println("RSA 私钥=" + keyPair.getPrivate());
System.out.println("RSA 公钥=" + keyPair.getPublic());
System.out.println("RSA p10请求的字符串=" + requestReq2);
}
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.SignatureException;
import javax.security.auth.x500.X500Principal;
import sun.misc.BASE64Encoder;
/**
* @param algorithm签名算法 1.SHA1withRSA 2.SM3WITHSM2
* @param dn主题
* @param keyPair密钥对
* @param keyType密钥类型 SM2|RSA
* @return 返回p10请求的字符串
* @throws SignatureException
* @throws NoSuchProviderException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws KeyPairException
*/
private static String getP10ReqestBC(String algorithm, String dn, KeyPair keyPair,String keyType) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException
{
String p10RequestString = null;
byte[] p10buffer = null;
if(keyType.equals("SM2")){
fisher.man.jce.PKCS10CertificationRequest p10Request;
p10Request = new fisher.man.jce.PKCS10CertificationRequest(
algorithm, new X500Principal(dn), keyPair.getPublic(),
null, keyPair.getPrivate());
p10buffer = p10Request.getDEREncoded();
}else{
org.bouncycastle.jce.PKCS10CertificationRequest p10Request;
p10Request = new org.bouncycastle.jce.PKCS10CertificationRequest(
algorithm, new X500Principal(dn), keyPair.getPublic(),
null, keyPair.getPrivate());
p10buffer = p10Request.getDEREncoded();
}
p10RequestString = new BASE64Encoder().encode(p10buffer);
return p10RequestString;
}
public static void main(String[] args) throws IOException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException {
// algorithm签名算法 SM2
String algorithm = "SM3WITHSM2";
// dn主题
String dn = "CN=dfg, OU=aert, O=45y, L=sdfg, ST=fg, C=CN";
KeyPairGenerator ecPair = null;
SecureRandom rand = null;
rand = SecureRandom.getInstance("TrueRandom", "FishermanJCE");
ecPair = KeyPairGenerator.getInstance("SM2", "FishermanJCE");
ecPair.initialize(256, new SecureRandom());
// keyPair密钥对
KeyPair keyPair = ecPair.generateKeyPair();
String requestReq = getP10ReqestBC(algorithm,dn,keyPair,"SM2");
System.out.println("SM2 私钥=" + keyPair.getPrivate());
System.out.println("SM2 公钥=" + keyPair.getPublic());
System.out.println("SM2 p10请求的字符串=" + requestReq);
System.err.println("************************************");
System.err.println("************************************");
System.err.println("************************************");
// algorithm签名算法 RSA
String algorithm2 = "SHA1withRSA";
// dn主题
String dn2 = "CN=zdfg, OU=ert, O=er, L=fgj, ST=vfgh, C=CN";
rand = SecureRandom.getInstance("TrueRandom", "FishermanJCE");
ecPair = KeyPairGenerator.getInstance("RSA", "BC");
ecPair.initialize(1024, new SecureRandom());
// keyPair密钥对
KeyPair keyPair2 = ecPair.generateKeyPair();
String requestReq2 = getP10ReqestBC(algorithm2,dn2,keyPair2,"RSA");
System.out.println("RSA 私钥=" + keyPair.getPrivate());
System.out.println("RSA 公钥=" + keyPair.getPublic());
System.out.println("RSA p10请求的字符串=" + requestReq2);
}
输出结果:
写道
SM2 私钥=EC Private Key
S: a40ed786b2867685507a4abad7264dbff72341f79503e6ff5366703789a2a7d7
SM2 公钥=EC Public Key
X: c337bb8017d572bcbc03b42280e43114fbefdff1d9a4e08866afb8ebecfe0547
Y: ae5d3c580e5d348be7a1db7d079983f9a4a59866267d951ddbbdcc45775ed82a
SM2 p10请求的字符串=MIIB5jCCAZECAQAwVDELMAkGA1UEBhMCQ04xCzAJBgNVBAgTAmZnMQ0wCwYDVQQHEwRzZGZnMQww
CgYDVQQKEwM0NXkxDTALBgNVBAsTBGFlcnQxDDAKBgNVBAMTA2RmZzCCATQwge0GCCqBHIFFAYIt
MIHgAgEBMCwGByqGSM49AQECIQCFQtaeTARPGOi5JDW/b/feRXKDkVxFUX1yLtuLCPHfwzBEBCB4
eWi0+jLD/SQXhC5zu/7/LzyEi2gx1+DsZSKLOTfkmAQgY+TG07I7DISc+EJBSEv+SPYdWaWxa6Bu
bhLR2ifFJJoEQQRCHevWG2LqtnRkNOvDzDFeMiILO63VC9xMTmwUf+3UPQaAUSvLtCwH1HNJ0hU7
cMTl1/38v6NuoahYQbnkbgmiAiEAhULWnkwETxjouSQ1v2/33Sl3IGMEhWKNWudO58MuebcCAQED
QgAEwze7gBfVcry8A7QigOQxFPvv3/HZpOCIZq+46+z+BUeuXTxYDl00i+eh230HmYP5pKWYZiZ9
lR3bvcxFd17YKjAMBggqgRyBRQGDdQUAA0EAhneSdWonUMXL0Sk4vpzPtqZvUddbYo/Bb7o3a+Te
k4+v/kp8q7hvA+2BubXpTSAE2AjE0qytc4THB++vmI75Lg==
************************************
************************************
************************************
RSA 私钥=EC Private Key
S: a40ed786b2867685507a4abad7264dbff72341f79503e6ff5366703789a2a7d7
RSA 公钥=EC Public Key
X: c337bb8017d572bcbc03b42280e43114fbefdff1d9a4e08866afb8ebecfe0547
Y: ae5d3c580e5d348be7a1db7d079983f9a4a59866267d951ddbbdcc45775ed82a
RSA p10请求的字符串=MIIBkTCB+wIBADBUMQswCQYDVQQGEwJDTjENMAsGA1UECBMEdmZnaDEMMAoGA1UEBxMDZmdqMQsw
CQYDVQQKEwJlcjEMMAoGA1UECxMDZXJ0MQ0wCwYDVQQDEwR6ZGZnMIGfMA0GCSqGSIb3DQEBAQUA
A4GNADCBiQKBgQCPE+/QiaeKTWc/vZueZ6j8D1YaPdW8Hmgq1dJBwKPhGmWpEwbDxMwNpDalHeax
JXnNFVPwtDhzTOGTm9QBLsnhM0/YxrLD/sK5RYD0T8786/HQrRat1n5xg3rnHKntM3QoWbw4iW7h
T62Yrro62xP8hnWArrbOc5dUpDAD/twNIwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAGN8AhMQMToq
IyRlkF3LCkCMT9CKnn4p+qIn3u0WMWIkm7S80/WDBhXMoUSQH2ZK1wcjErCIJwGXmiPmuFU9sD/V
euwF0ul/WxjuQUzU9VHYuNyYajC2xVyVl+rE0Zc8SDMyU80V1/eAAp2fPIcKvET4pKzhYh4n3iDh
Gb0U57Iq
评论
10 楼
宋贝贝
2018-10-17
您好,能麻烦您把这个包fisher.man.jce.PKCS10CertificationRequest发一下么。谢谢!我的邮箱是songbeibei99@163.com
9 楼
upset_ming
2018-06-04
DoubleCA的JCE实现了SM2算法的密钥协商,国密SM2、SM3、SM4算法全套都实现了,包括JAVA KeyStore,叫dcks,实现了SM2密钥对的存储,包括国密SSL,可以实现Tomcat的国密SSL功能。包括各种国密数字证书都可以免费制作。
可在Android和各JAVA平台上使用。
可在Android和各JAVA平台上使用。
8 楼
stormlyf
2018-05-03
您好,能麻烦您把这个包fisher.man.jce.PKCS10CertificationRequest发一下么。谢谢!我的邮箱是stormlyf@163.com
7 楼
linxinlong11007
2017-03-23
你好,我需要FishermanJCE,请问能发份这个包给我么?328997553@qq.com
6 楼
candyo75
2016-10-11
你好,我也需要这个例子的依赖的FishermanJCE相关的包 我百度都没有找到相关jar,请帮忙把相关jar发给我邮箱: 347043354@qq.com
5 楼
linpz
2013-05-13
FishermanJCE 是山东渔翁公司加密卡提供调用加密机/加密卡的Jar包来的。。。
4 楼
lishifu2009
2012-04-11
好像要用起来还需好多包啊。。。。。
我设置了
Security.addProvider(new fisher.man.jce.provider.FishermanJCE());
结果还报这个错误。。。
Exception in thread "main" java.lang.NoClassDefFoundError: com/fmjnicard/fm_jni_api
at fisher.man.jce.provider.FishermanJCE.<init>(FishermanJCE.java:90)
com/fmjnicard/fm_jni_api
能否再发下包哈哈。。。
多谢。。。
我设置了
Security.addProvider(new fisher.man.jce.provider.FishermanJCE());
结果还报这个错误。。。
Exception in thread "main" java.lang.NoClassDefFoundError: com/fmjnicard/fm_jni_api
at fisher.man.jce.provider.FishermanJCE.<init>(FishermanJCE.java:90)
com/fmjnicard/fm_jni_api
能否再发下包哈哈。。。
多谢。。。
3 楼
lishifu2009
2012-04-11
哈哈 好像还是不行。。。。。。。
Exception in thread "main" java.security.NoSuchProviderException: no such provider: FishermanJCE
at sun.security.jca.GetInstance.getService(GetInstance.java:66)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
at java.security.SecureRandom.getInstance(SecureRandom.java:293)
at testli.ww.main(ww.java:58)
麻烦帮我看看喽,谢了
Exception in thread "main" java.security.NoSuchProviderException: no such provider: FishermanJCE
at sun.security.jca.GetInstance.getService(GetInstance.java:66)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
at java.security.SecureRandom.getInstance(SecureRandom.java:293)
at testli.ww.main(ww.java:58)
麻烦帮我看看喽,谢了
2 楼
lishifu2009
2012-04-09
您好,fisher.man.jce.PKCS10CertificationRequest 这个包给我发吧,我的邮箱:lishifu2009@qq.com 谢谢。
1 楼
ggh666
2012-02-29
请问 假如有“a40ed786b2867685507a4abad7264dbff72341f79503e6ff5366703789a2a7d7” 这样的 数据 如何能还原成 privateKey 私钥的对象呢
发表评论
-
java实现斐波那契数列
2017-04-13 15:16 1097public class FibTest { pub ... -
java 堆栈的区别
2015-07-13 21:32 785Java把内存分成两种, ... -
使用StringBuffer的好处是什么?在什么时候使用?
2015-07-13 21:27 753字符串内容较长的时候,特别是这个字符串是动态拼接的时候,用 ... -
ActiveMQ的queue以及topic两种消息处理机制
2015-04-14 10:57 5658JMS:Java Message Server JMS消 ... -
Date数据精度问题
2015-03-30 17:04 1288Java数据精度比Oracle精度大,在java端设置Date ... -
springmvc定时任务配置
2015-02-10 11:19 9191.xml配置头中添加 http://www.spring ... -
计算当日剩余时间
2015-02-09 14:06 990//计算当日剩余时间 private long getCurr ... -
org.springframework.util.StringUtils的应用
2014-07-18 13:40 1375FROM:http://www.myexception.c ... -
CopyOnWriteArrayList理解与理解[转]
2014-05-29 17:18 815FROM:http://www.cnblogs.com/al ... -
sha1withRSA md5withRSA分析
2014-05-16 11:25 6694source:http://m.blog.csdn.net ... -
java的concurrent用法详解
2014-02-24 14:32 898我们都知道,在JDK1.5之前,Java中要进行业务并发时, ... -
Java获取电脑CPU个数及系统信息
2014-02-20 17:49 17551FROM:http://bingoffice.blog.16 ... -
线程池ExecutorService
2014-02-19 17:57 1176声明:本人所有摘抄作者原文只是为方便学习,收藏所用。 为防 ... -
Sola java搜索引擎服务器
2014-01-26 15:56 2284Sola http://www.open-searc ... -
单例模式
2014-01-07 15:50 527/** * 懒汉式 * @author lihongy ... -
Collections.frequency用法实例
2014-01-07 15:31 8006Collections.frequency(Collecti ... -
java Collections工具类用法
2014-01-07 14:54 1003原文:http://www.cnblogs.com/nayi ... -
经典的java中return和finally问题![转]
2013-11-14 15:45 922原文:http://blog.sina.com.cn/s/ ... -
HashMap、LinkedHashMap、TreeMap 差别[转]
2013-10-31 15:24 946HashMap、LinkedHashMap、TreeMap ... -
java compareTo Comparator
2013-07-24 15:25 611compareTo 只是比较2个字符串,不能进行排序Str ...
相关推荐
通过go语言,在线生成、解析pkcs10格式的X509证书请求文件,支持rsa,sm2算法,底层使用openssl开源库。
基于数字证书的文件数字信封加解密工具(支持RSA算法与SM2算法)
int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, const unsigned char *from, int flen); int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, const unsigned char *from, int ...
基于RSA算法的数字签名系统,C#实现。毕设的题目,上传给大家分享。
本资源包含:RSA签名算法,格式为PKCS7。RSA签名算法,格式为PKCS7。RSA签名算法,格式为PKCS7。RSA签名算法,格式为PKCS7。 RSA加密算法是一种非对称加密算法。在公开密钥加密和电子商业中RSA被广泛使用。RSA是1977...
Java RSA私钥 pkcs1转pkcs8;适用于Java与C#程序交互时使用
提供RSA 及 SM2密钥生成、RSA公钥运算、RSA私钥运算、SM2签名、SM2验签、SM2加密、SM2解密 SM2点乘 SM2点加运算的测试工具。
pkcs证书生成, rsa, rsa2, MD5签名, 加密, aes加密等 pkcs证书生成, rsa, rsa2, MD5签名, 加密, aes加密等
【delphiRSA加解密】支持RSA公钥加密私钥解密,RSA私钥加密公钥解密,秘钥格式支持PKCS8和PKCS1,D7~XE10可用
加密 RSA 数字签名 数字证书。顾名思义 我这个项目里面 有6个加密方法。自己看着下,绝对金典。分高的是有理由的。
PKCS #10 v1.7: Certification Request Syntax Standard PKCS #10: Certification Request Syntax Standard PKCS #11 v2.20: Cryptographic Token Interface Standard PKCS #11 v2.11: Cryptographic Token ...
SM2数字证书,充分借鉴与吸收了X509数字证书的格式与优点,在考虑RSA算法的优缺点之后,推出的基于商密公钥算法的SM2证书规范,至此,商密算法的数字证书在商用密码应用安全性评估中成为了必须要检测的一个重要环节...
资源名字:基于MD5+RSA的数字签名设计与实现(源码+文档)_RSA_数字签名.zip 资源内容:项目全套源码+完整文档 源码说明: 全部项目源码都是经过测试校正后百分百成功运行。 适合场景:相关项目设计 项目详细介绍可...
通过javascript实现RSA加密,使用了标准的国际PKCS1填充,支持UTF-8编码
毕业设计:python基于RSA算法的数字签名生成(源码 + 数据库 + 说明文档) 第2章 数字加密技术与数字签名概述 8 2.1 密码体制构成 8 2.2 公钥密码体制 8 2.3数字签名的概念 10 2.4数字签名的原理 10 第3章 RSA的数字...
国密SM2、RSA证书签发工具(CA),https://blog.csdn.net/zweib730/article/details/50972837#comments
PKCS #1: RSA Cryptography Specifications Version 2.2 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1. Requirements Language . . . . . . . . . . . . . . . . . ...
证书生成工具(支持SM2证书、RSA1024、RSA2048,仅供测试)
基于python的基于RSA算法的数字签名生成软件.zip