Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable AES-NI (hardware acceleration) for Node.js crypto on Linux?

I wrote a basic function to test the speed of the AES-256-CBC mode of the Node.js built-in crypto functions. These functions use OpenSSL, so they should support AES-NI, but when I correctly enable AES-NI and do a command-line test of OpenSSL the encryption speed is ~350MB/s on OpenSSL and only ~100MB/s on Node.js Crypto.

I used this answer to enable OpenSSL AES-NI in the command line and ran it as follows:

openssl speed -evp aes-256-cbc

My question is, how do I make the speed of the Node.js crypto functions for AES match that of OpenSSL run in the command line? I suspect the reason is failure to use AES-NI

like image 465
Philberg Avatar asked Oct 10 '13 23:10

Philberg


People also ask

How do you check if AES-NI is enabled in Linux?

Check if AES-NI is Available on CPU Processors Before proceeding, first verify that current CPUs have the AES instruction set. For this you can inspect CPU flags as follows. If the output shows aes , that means AES-NI engine is available on current CPUs.

What does enabling AES-NI do?

The Intel Advanced Encryption Standard (AES) or New Instructions (AES-NI) engine enables high-speed hardware encryption and decryption for OpenSSL, ssh, VPN, Linux/Unix/OSX full disk encryption and more.


1 Answers

It seems that this was not correctly enabled until the latest release v0.12 (that was just released publicly).

Some of the notes are available here http://strongloop.com/strongblog/performance-node-js-v-0-12-whats-new/

like image 61
Philberg Avatar answered Sep 23 '22 01:09

Philberg