erlang/otp — pull request #372 by RoadRunnr (2014-05-18 14:09:36+00:00)
Title: ssl: add aes gcm cipher

This adds support for the AES GCM cipher suites. AES-GCM is much faster than normal AES+MAC. On Intel CPU's with AES-NI it is comparable to RC4 in terms of throughput.

The cipher support in crypto is based on OpenSSL's EVP contexts. The EVP context where chosen over the more generic CRYPTO_gcm128_xxx functions for performance. The CRYPTO_gcm128_xxx functions use a generic implementation while the EVP context can use hardware optimized variants (AES-NI or padlock instructions) on supported CPUs'

Some benchmarks on an Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz:
```
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes

openssl speed aes-128-cbc (generic functions):
aes-128 cbc 105336.34k 112751.42k 114742.10k 115345.41k 113988.95k

openssl speed -evp aes-128-cbc (EVP with AES-NI):
aes-128-cbc 615445.91k 660332.93k 670884.44k 665051.48k 669777.92k

openssl speed -evp rc4:
rc4 348612.51k 609902.38k 748361.73k 782705.19k 788460.89k

openssl speed -evp aes-128-gcm (EVP with AES-NI):
aes-128-gcm 310758.55k 785113.43k 1156720.81k 1277712.38k 1323431.25k
```