支持 AES-NI 的 EVP 接口 [英] EVP Interface with AES-NI support
问题描述
在 C/C++ 中使用 OpenSSL 加密库时,EVP 接口是否自动支持 AES-NI 硬件加速(假设处理器支持)?参考 这个,看来命令行 OpenSSL 确实有支持.我想知道是否必须使用特定的函数调用来利用这种支持.
When using the OpenSSL crypto libraries in C/C++, does the EVP interface automatically support AES-NI hardware acceleration (assuming processor support)? Referring to this, it appears command-line OpenSSL does have support. I was wondering if there were specific function calls that I had to use to take advantage of this support.
例如,如果我使用 EVP_EncryptInit_ex(ctx, type, imp, key, iv)
,这些参数中的任何一个都必须指定 NI 加速吗?IE.EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv)
会起作用吗?
For instance, if I use EVP_EncryptInit_ex(ctx, type, imp, key, iv)
, do any of these parameters have to specify NI acceleration? I.e. will EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv)
do the trick?
谢谢!
推荐答案
在 C/C++ 中使用 OpenSSL 加密库时,EVP 接口是否自动支持 AES-NI
When using the OpenSSL crypto libraries in C/C++, does the EVP interface automatically support AES-NI
是的.EVP_*
是确保使用 AES-NI(如果可用)的官方/支持方式.实际上,一般来说,EVP 是访问硬件加速的唯一途径.
Yes. EVP_*
is the official/supported way to ensure AES-NI is used (if available). In fact, EVP is the only way to access hardware acceleration in general.
EVP_*
也是获得其他硬件加速的唯一途径,比如在Skylark下使用Intel的ia32的SHA加速;ARM 的 Crypto 扩展在 ARMv8 中可用;以及威盛处理器上的 ia32 挂锁扩展.
EVP_*
is also the only way to obtain other hardware accelerations, like engaging Intel's ia32's SHA acceleration under Skylark; ARM's Crypto extensions available in ARMv8; and VIA's ia32 Padlock extensions on their processors.
使用低级 AES 例程(如 AES_encrypt
和 AES_decrypt
)是纯软件实现,它们永远不会像 AES-NI 那样使用硬件加速.另请参阅 在运行时验证 AES-NI 的使用?.
Using low level AES routines (like AES_encrypt
and AES_decrypt
) are software only-implementations, and they will never use hardware acceleration like AES-NI. Also see Dr. Henson's response on the OpenSSL mailing list at Verify AES-NI use at runtime?.
相关问题是(1)如何判断是否使用了AES-NI;(2) 基准测试结果是什么.为此,请参阅如何检查 OpenSSL 是否支持/使用英特尔 AES-NI?
Related questions are (1) how to determine if AES-NI is being used; and (2) what are the benchmarking results. For that, see How can I check if OpenSSL is support/use the Intel AES-NI?
这篇关于支持 AES-NI 的 EVP 接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!