gpt4 book ai didi

java - Java 的 RSA 实现,BC 的替代方案

转载 作者:行者123 更新时间:2023-11-29 06:25:13 25 4
gpt4 key购买 nike

The RSA implementation that ships with Bouncy Castle only allows the encrypting of a single block of data. The RSA algorithm is not suited to streaming data and should not be used that way. In a situation like this you should encrypt the data using a randomly generated key and a symmetric cipher, after that you should encrypt the randomly generated key using RSA, and then send the encrypted data and the encrypted random key to the other end where they can reverse the process (ie. decrypt the random key using their RSA private key and then decrypt the data).

我无法使用使用对称 key 的解决方法。那么,除了 Bouncy CaSTLe 之外,还有其他 RSA 实现吗?

最佳答案

此限制不仅仅是 Bouncy CaSTLe 随机发明的东西,并且使用对称 key 不是“解决方法”:它是正确的做法。

RSA 算法本质上不适合加密大量数据。如果你真的真的真的真的真的真的真的想在大量数据上使用它,那么你可以将数据分成足够小的 block ,然后对每个 block 进行加密。但这不是标准做法,您可能会遇到您没有想到的安全问题,而 AES 等分组密码具有处理您可能遇到的问题的标准方法(请参阅 block modes - 本质上有一个安全问题例如使用相同 key 多次加密相同数据的问题, block 模式是处理此问题的内置方式)。

我真的只是坚持使用对称加密进行流式传输并使用 RSA 加密对称 key (基本上没有其他任何东西)的标准做法。

关于java - Java 的 RSA 实现,BC 的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2899626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com