PyCrypto 使用起来安全可靠吗?

发布于 2024-12-11 00:57:14 字数 93 浏览 0 评论 0原文

我正计划在一个项目中使用 PyCrypto,我想知道 PyCrypto 是否足够安全可靠。如何确保 PyCrypto 根据 RSA 和 AES 等各种加密算法正确加密数据?

I am planning on using PyCrypto for a project and I want to know whether PyCrypto is safe and reliable enough to use. How can I ensure that PyCrypto is encrypting data correctly according to the various encryption algorithms such as RSA and AES?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流年里的时光 2024-12-18 00:57:14

这取决于。

PyCrypto 的某些部分非常好。例如,Crypto.Random 的 API(在 PyCrypto 2.1 中引入)被设计得非常万无一失,它使用的底层算法(Fortuna)也被设计得非常万无一失。

其他部分只是低级加密原语的实现,因此它可以工作,但您必须知道自己在做什么才能正确使用它们。例如,Crypto.PublicKey.RSA 没有实现完整的 RSA PKCS#1 标准(这是大多数人在谈论“RSA”时所想到的)。它仅实现基本的 RSA 原语(m^e mod n 和 c^d mod n),并且您仍然必须提供自己的 PKCS#1 实现。

确保 PyCrypto 正确加密您的数据(无需阅读源代码,我鼓励每个人都这样做)的最佳方法是使用标准协议和/或消息格式,并测试您的代码是否与其他实现进行互操作。如果您正在编写自己的消息格式(无论如何您可能不应该这样做),那么您需要非常小心以确保 PyCrypto 实际上正在执行您认为它正在执行的所有操作。

免责声明:我是当前的 PyCrypto 维护者,所以我的意见不应被视为独立评论。

更新:PyCrypto v2.5 及更高版本现在包含正确的 RSA PKCS#1 加密和签名实现。有关详细信息,请参阅 Crypto.Cipher.PKCS1_OAEP 和 Crypto.Signature.PKCS1_PSS 的 API 文档。

It depends.

Some parts of PyCrypto are really good. For example, the API for Crypto.Random (introduced in PyCrypto 2.1) was designed to be pretty foolproof, and the underlying algorithm it uses (Fortuna) was also designed to be pretty foolproof.

Other parts are just implementations of low-level crypto primitives, so it works, but you have to know what you are doing to use them correctly. For example, Crypto.PublicKey.RSA doesn't implement the full RSA PKCS#1 standard (which is what most people think about when they talk about "RSA"). It only implements the basic RSA primitive (m^e mod n and c^d mod n), and you still have to provide your own PKCS#1 implementation.

The best way to ensure that PyCrypto is encrypting your data correctly (without reading the source code, which I encourage everyone to do) is to use a standard protocol and/or message format, and test that your code interoperates with other implementations. If you're making up your own message format (which you probably shouldn't do anyway), then you need to be very careful to ensure that PyCrypto is actually doing everything that you think it's doing.

Disclaimer: I'm the current PyCrypto maintainer, so my opinions shouldn't be considered an independent review.

Update: PyCrypto v2.5 and later now include proper RSA PKCS#1 encryption and signature implementations. See the API documentation for Crypto.Cipher.PKCS1_OAEP and Crypto.Signature.PKCS1_PSS for details.

绝影如岚 2024-12-18 00:57:14

不。PyCrypto 不再处于积极开发状态,应该使用密码学库。

来源:https://github.com/dlitz/pycrypto/issues/173

No. PyCrypto is no longer under active development and the cryptography library should be used instead.

Source: https://github.com/dlitz/pycrypto/issues/173

风追烟花雨 2024-12-18 00:57:14

请注意,我也不是加密货币专家。也就是说,我快速浏览了 github 上的 PyCrypto 代码及其邮件列表。让我充满信心的事情之一是,代码库中有优秀的专家贡献。开发人员承认存在不安全因素,并努力纠正这些问题。

如果您有需要安全实施的特定用例,请查看他们的代码并在他们的列表上询问。由于他们在很多情况下似乎利用 C/C++ 库来完成工作,因此您可以直接查看基础库的声誉。

Note that I am not an expert in crypto either. That said, I took a quick look at the PyCrypto code on github and at their mailing list. One of the things that gives me confidence is that there is good, expert contributions to the code base. The developers acknowledge insecurities and work to correct them.

If you have a specific use case that you need to be implemented securely, look at their code and ask on their list. Since they seem to leverage C/C++ libraries to do the work in many cases, you can check out the reputation of the base libraries directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文