我正在创建一个CSR,我想知道哪个可以说是我的RSA密钥的最佳长度.
当然,384可能太弱了,16384可能太慢了.
是否应该使用密钥长度达成共识,具体取决于证书的生命周期?
编辑:像大多数人一样,我希望我的钥匙能够相当强大.我并不担心国家安全局可能会在2019年破坏我的密钥.我只想知道当一个人计划做正常业务时最好的做法是什么(例如电子商务网站)
一个比另一个更安全吗?
我在Google上看到有关如何查看RSA密钥指纹的内容,而不是ECDSA指纹.
我试图了解Java java.security.Signature类的功能.如果我计算SHA1消息摘要,然后使用RSA加密该摘要,我得到一个不同的结果,要求Signature类签署相同的东西:
// Generate new key
KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
PrivateKey privateKey = keyPair.getPrivate();
String plaintext = "This is the message being signed";
// Compute signature
Signature instance = Signature.getInstance("SHA1withRSA");
instance.initSign(privateKey);
instance.update((plaintext).getBytes());
byte[] signature = instance.sign();
// Compute digest
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
byte[] digest = sha1.digest((plaintext).getBytes());
// Encrypt digest
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
byte[] cipherText = cipher.doFinal(digest);
// Display results
System.out.println("Input data: " + plaintext);
System.out.println("Digest: " + bytes2String(digest));
System.out.println("Cipher text: " + bytes2String(cipherText)); …Run Code Online (Sandbox Code Playgroud) 我正在构建一个自定义购物车,其中CC号和Exp日期将存储在数据库中,直到处理(然后删除).我需要加密这些数据(显然).
我想使用RSACryptoServiceProvider类.
这是我创建密钥的代码.
public static void AssignNewKey(){
const int PROVIDER_RSA_FULL = 1;
const string CONTAINER_NAME = "KeyContainer";
CspParameters cspParams;
cspParams = new CspParameters(PROVIDER_RSA_FULL);
cspParams.KeyContainerName = CONTAINER_NAME;
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
cspParams.ProviderName = "Microsoft Strong Cryptographic Provider";
rsa = new RSACryptoServiceProvider(cspParams);
string publicPrivateKeyXML = rsa.ToXmlString(true);
string publicOnlyKeyXML = rsa.ToXmlString(false);
// do stuff with keys...
}
Run Code Online (Sandbox Code Playgroud)
现在计划将私钥xml存储在连接到管理器密钥链的USB驱动器上.
每当经理离开公司时,我希望能够生成新的公钥和私钥(并使用新的公钥重新加密所有当前存储的CC号).
我的问题是这段代码生成的密钥总是一样的.我每次如何生成一组独特的密钥?
UPDATE.我的测试代码如下:
注意:这里的"privatekey"参数是原始私钥.为了更改密钥,我需要验证私钥是否有效.
在Default.aspx.cs中
public void DownloadNewPrivateKey_Click(object sender, EventArgs e)
{
StreamReader reader = new StreamReader(fileUpload.FileContent);
string privateKey = reader.ReadToEnd();
Response.Clear();
Response.ContentType = "text/xml"; …Run Code Online (Sandbox Code Playgroud) 我有格式的RSA私钥PEM,是否有直接的方式从.NET读取并实例化RSACryptoServiceProvider解密用相应的公钥加密的数据?
可以为RSA私钥分配一个"密码",根据我的理解,它可以提供一些二级安全性,以防有人使用私钥文件.
如何实施密码短语安全层?
我正在研究SAML 1.1断言消费者服务的测试工具.测试必须生成签名的SAMLResponse并将其提交给Base64中编码的ACS.ACS必须能够使用X509公共证书验证签名的消息.
我能够构建SAMLResponse,添加必要的断言等.但是当我尝试签署对象时,我遇到了问题.这是我当前代码的片段:
String certPath = "mycert.pem";
File pubCertFile = new File(certPath);
BufferedInputStream bis = null;
try {
bis = new BufferedInputStream(new FileInputStream(pubCertFile));
} catch(FileNotFoundException e) {
throw new Exception("Could not locate certfile at '" + certPath + "'", e);
}
CertificateFactory certFact = null;
Certificate cert = null;
try {
certFact = CertificateFactory.getInstance("X.509");
cert = certFact.generateCertificate(bis);
} catch(CertificateException e) {
throw new Exception("Could not instantiate cert", e);
}
bis.close();
ArrayList<Certificate> certs = new ArrayList<Certificate>();
certs.add(cert);
String keyPath = "mykey.pem"; …Run Code Online (Sandbox Code Playgroud) 我在C#网上看到了大量使用System.Security.Cryptography.RSACryptoServiceProvider的加密/解密教程和示例,但我希望能够做到的是:
有人能指点我这个有用的资源吗?
之间有什么区别.pem,.cer和.der?
据我所知,.cer包含公钥.是否有任何开放式框架可用于使用此公钥加密我的数据?