加密文件与AES,加密密钥与RSA - 我是在正确的轨道? [英] Encrypting Files with AES, Encrypting Key with RSA - Am I on the right track?

查看:202
本文介绍了加密文件与AES,加密密钥与RSA - 我是在正确的轨道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

概述: 我试图设计,将加密文件安全地发送到蜗牛邮件(大型数据集)的应用程序。我打算使用AES / RijndaelManaged的加密从.net到最初的文件进行加密,使用使用 RNGCryptoServiceProvider 随机产生的密钥。我则加密此随机AES密钥与RSA公钥。数据的接收器是国内唯一一家拥有RSA私钥进行解密。

Overview: I'm trying to design an application that will encrypt files to safely send through Snail Mail (LARGE sets of data). I'm planning on using AES/RijndaelManaged encryption from .Net to encrypt the files initially, using a randomly generated key using RNGCryptoServiceProvider. I'm then encrypting this random AES key with a RSA Public key. The receiver of the data is the only one with the RSA Private key to decrypt it.

我的问题:这是正确的方式做这样的事情?如果是这样,它是安全发送此RSA加密密钥和数据,因为它需要的私钥解密?

My question: Is this the proper way to do something like this? If so, is it safe to send this RSA-Encrypted key with the data since it requires the private key to decrypt?

修改 - 根据的答案,这的确是正确的方式去

EDIT - According to the Answers, this is indeed the proper way to go.

编辑 - 感谢您的答复。现在,我真正想知道的:
当具有最终用户生成的公钥/私钥对,什么是保存私钥的最好方法是什么?我不希望它是从一台计算机才能访问,所以我尽量避免使用用户的密钥存储。但是, MSDN 说,这是不是安全的到关键保存到一个文件中,这样怎么回事你能做到这一点?

EDIT - Thanks for the replies. Now what I really want to know:
When having the end user generate their Public/Private key pair, what is the best way to save the Private key? I do not want it to be only accessible from one machine, so I am trying to avoid using the user's key store. But MSDN says it is not safe to save the key to a file, so how else can you accomplish this?

推荐答案

使用 PGP 除非有一个很好的理由不这样做。 PGP是电子邮件通常使用一个开放的和无处不在的标准混合加密。有PGP的多种实现。唯一的.NET一个我知道的是 BouncyCastle的加密项目的C#库。 PGP实际上提供了您所描述的功能的超集;例如,PGP还可以进行数字签名的消息。

Use PGP unless there's a good reason not to. PGP is an open and ubiquitous standard for hybrid crypto commonly used in email. There are many implementations of PGP. The only .NET one I know is the BouncyCastle crypto project's C# library. PGP actually provides a superset of the functionality you describe; for instance, PGP can also digitally sign messages.

关于私有密钥存储。典型的解决方案是将其写入磁盘之前,对称地进行加密私钥。只有私钥的真正所有人知道密码的秘密,他们没有告诉任何人。这样一来,即使攻击者得到私钥文件,他们仍然有妥协的秘密或蛮力对称密码。所有的PGP实现我知道做到这一点。

Regarding private key storage. The typical solution is to symmetrically encipher the private key before writing it to disk. Only the true owner of the private key knows the cipher secret, and they don't tell anyone. That way, even if an attacker gets the private key file, they still have to compromise the secret or brute force the symmetric cipher. All the PGP implementations I know of do this.

请不要重新实现PGP如果你想要做什么。 PGP是pretty的广泛支持。此外,凡人像我这样的(和presumably自己)几乎都站不住获得的一切权利的机会。

Please don't reimplement PGP if it does what you want. PGP is pretty widely supported. Furthermore, mere mortals like myself (and presumably yourself) hardly stand a chance of getting everything right.

这篇关于加密文件与AES,加密密钥与RSA - 我是在正确的轨道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆