Deliciously poor work with OpenSSL AES / GCM on Raspberry PI 2

I developed a simple C ++ program to evaluate the performance of OpenSSL AES / GCM calls to the EVP interface. What he does is take a string with a length of 1024 bytes, encrypt it with a key, then encrypt the result with the same key and again and again. I use incremental 4-byte initialization vectors.

When I tested it on my Macbook Pro (Intel i7), the result was very impressive: it took exactly one second to start 1048576 iterations of the above procedure on a single core. This encryption speed is 1 GB / s. 8 GB / s (more or less) if we use all the cores at the same time.

Now I have ported the same tests to Raspberry PI 2. However, when I ran it, it took 0.16 seconds to complete 1024 iterations. This is more or less 6 MB / s, on one core.

Now, I obviously understand that there is a huge, huge difference between a modern, expensive i7 processor and a small ARM processor that runs on raspberries, but still 170 times faster. Therefore, before assuming that the Raspberry PI 2 is really that bad, I wanted to check if these parameters are reasonable.

Has anyone made some kind of benchmark? Is encryption width of 6 MB / s reasonable for raspberries? Or am I doing something wrong?

(I plug it in with a Macbook USB drive: maybe it is so slow because it does not get enough power? It definitely doesn’t seem reasonable. It won’t work at all, right? Or could there be a lock mechanism to save power?)

UPDATE 1 . I did openssl -evp speed aes-256-cbc on both my Macbook and raspberry.

On a Macbook:

 type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes aes-256-cbc 534591.95k 564057.62k 566522.81k 570717.87k 574876.33k 

On raspberries:

 type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes aes-256-cbc 14288.53k 16653.74k 17165.31k 17298.43k 17337.00k 

This is still a factor of 33, but the Intel processor can use hardware accelerated AES calls. However, as far as I know, GCM mode should be pretty fast than CBC. I don’t know why, but it seems that for GCM there is no opensl guideline, but even assuming that they run the same way, I miss factor 3.

UPDATE 2 Checked on this page: http://elinux.org/RPi_Performance#OpenSSL . It looks like I'm missing 10 MB / s. Total: 27 MB / s with AES / CBC (as it should be) versus 6 MB / s with AES / GCM (as it really is).

+7
benchmarking openssl aes raspberry-pi
source share
2 answers

Your Intel processor has special hardware support using the AESNI extension. If you compile without it, you will get about 250 MB / s. This performance difference sounds reasonable. (And how many GHz does any processor say nothing about performance, except that it is exactly the same type of processor with only different clocks)

+4
source share

If you have not yet taken this into account, why is factor 3 not explained by a factor of about 3 differences in processing power?

The Raspberry Pi 2 has a 900 MHz processor, and a typical i7 processor has 2.8 GHz, which means that the Pi has about a third of the processing power.

In addition, I do not know where you conclude that GCM should be faster than CBC in these conditions. CBC does not provide authentication, so one should make GCM noticeably slower (although this may not be the factor 4 you see).

Of course, this comes out of the window when you enter several cores, given that CBC cannot be parallelized and GCM can.

+1
source share

All Articles