openssl BF_cfb64_encrypt 线程安全
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据常见问题解答,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.