openssl BF_cfb64_encrypt 线程安全

发布于 2024-08-18 04:20:12 字数 73 浏览 1 评论 0原文

openssl 的 BF_cfb64_encrypt() 线程安全吗?

非常感谢使用它来加密/解密数据块的示例代码。

Is openssl's BF_cfb64_encrypt() thread safe?

A sample code to use it to encrypt / decrypt a blob of data would be much appreciated.

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

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

发布评论

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

评论(1

猫七 2024-08-25 04:20:12

根据常见问题解答,OpenSSL 例程是线程安全的。我查看了该函数的源代码,它确实看起来是线程安全的。当然,这是假设您没有将相同的输入/输出缓冲区传递给不同线程上的函数。

有关调用它的示例,您应该能够查看 OpenSSL 源代码。 openssl/crypto/bf/ 中有一个名为 bftest.c 的文件,其中包含对该函数的测试调用。

编辑 经过更多思考后,使用

According to the FAQ, the OpenSSL routines are thread safe. I looked at the source of that function, and it does indeed appear to be thread safe. Of course, that assumes you are not passing the same input/output buffers to the function on different threads.

For an example of a call to it, you should be able to look in the OpenSSL source. There is a file named bftest.c located in openssl/crypto/bf/ that has test calls to the function.

Edit After thinking about this a bit more, it is probably still wise to use the CRYPTO_set_locking_callback functionality for multi-threaded locking. The Blowfish algorithm asked about in the original question does not currently (in the version of OpenSSL I am using) use those locks, but that does not guarantee it will not in the future for some reason. Plus it saves future pain if you end up using functionality (such as RAND_bytes) that does need those locks.

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