我写了一个基本函数来测试Node.js内置加密函数的AES-256-CBC模式的速度.这些函数使用OpenSSL,因此它们应该支持AES-NI,但是当我正确启用AES-NI并对OpenSSL进行命令行测试时,OpenSSL上的加密速度约为350MB/s,而Node.js上的加密速度仅为~100MB/s加密.
我使用此答案在命令行中启用OpenSSL AES-NI并按如下方式运行:
openssl speed -evp aes-256-cbc
我的问题是,如何使AES的Node.js加密函数的速度与命令行中运行的OpenSSL的速度相匹配?我怀疑原因是没有使用AES-NI
有没有办法在 Python 中使用 AES-NI?我确实希望通过利用我对 AES-NI 的硬件支持来使 HMAC 更快。谢谢。
我想通过使用AES-NI加速我的应用程序,我正在努力找到任何适用于GCC或随附的汇编程序的示例.我对使用SSL或任何其他库不感兴趣.
我尝试使用Intel的AES新指令集以C语言进行加密/解密,更具体地说,我尝试在CBC模式下进行256位AES。
我在以下英特尔的白皮书中找到了C代码:https://www.intel.com/content/dam/doc/white-paper/advanced-encryption-standard-new-instructions-set-paper.pdf
这是来自英特尔白皮书pdf(aes.h
)的代码:
#ifndef AES_H
#define AES_H
#include <stdio.h>
#include <stdint.h> //for int8_t
#include <string.h> //for memcmp
#include <wmmintrin.h> //for intrinsics for AES-NI
//compile using gcc and following arguments: -g;-O0;-Wall;-msse2;-msse;-march=native;-maes
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(unsigned char))
inline void KEY_256_ASSIST_1(__m128i* temp1, __m128i * temp2)
{
__m128i temp4;
*temp2 = _mm_shuffle_epi32(*temp2, 0xff);
temp4 = _mm_slli_si128 (*temp1, 0x4);
*temp1 = _mm_xor_si128 (*temp1, temp4);
temp4 = _mm_slli_si128 (temp4, 0x4);
*temp1 = _mm_xor_si128 (*temp1, temp4);
temp4 = _mm_slli_si128 (temp4, 0x4); …
Run Code Online (Sandbox Code Playgroud) 我刚刚听说指令集扩展 AES-NI。如果可以提高性能,Java 的 JIT 编译器是否会编译应用程序以使用 AES-NI?
如果是,如果不确定是否会使用 AES(例如使用 TLS 时),它也会这样做吗?
我使用引擎AES-NI提高openssl速度(硬件加速)的性能,我的芯片支持引擎AES-NI(Intel(R)Xeon(R)CPU E5620 @ 2.40GHz)。
我尝试安装 openssl 版本1.0.2-chacha和1.0.1l
版本 1.0.2 chacha 测试速度 openssl 时使用命令:
openssl speed aes-256-cbc
Run Code Online (Sandbox Code Playgroud)
然后错误:
错误:错误的选项或值
版本 1.0.1 使用 nginx 配置时出错:
nginx: [warn] ENGINE_by_id("aesni") failed (SSL: error:25066067:DSO supportroutines:DLFCN_LOAD:could not load the shared library:filename(/usr/lib/x86_64-linux-gnu/openssl-1.0.1) /engines/libaesni.so):/usr/lib/x86_64-linux-gnu/openssl-1.0.1/engines/libaesni.so:无法打开共享对象文件:没有此类文件或目录错误:25070067:DSO 支持例程: DSO_load:could not load the shared library error:260B6084:engineroutines:DYNAMIC_LOAD:dso not found error:2606A074:engineroutines:ENGINE_by_id:no such engine:id=aesni)
我知道对于 openssl >= 1.0.1 的版本,AES-NI 不能通过引擎工作,也不会出现在 openssl 引擎命令中。默认情况下,它在支持的硬件上处于活动状态。
我在https://www.ruby-forum.com/topic/6873426#1168394 中看到一个命令说“没有配置选项,只要你的 CPU 支持它就可以工作”。
但我没有找到官方消息来源。
请建议使用版本 openssl 和 nginx 配置的解决方案。