CloudFlare 發佈了自己版本的 Go,修改了其中的 crypto subsystem:「Go crypto: bridging the performance gap」。
文章花了不少篇幅介紹 AEAD (Authenticated Encryption with Associated Data),而目前 CloudFlare 支援的是 AES-GCM 與 ChaCha20-Poly1305,也是兩大主流,分別佔了 60% 與 10% 的 HTTPS 流量:
As such today more than 60% of our client facing traffic is encrypted with AES-GCM, and about 10% is encrypted with ChaCha20-Poly1305.
CloudFlare 提供的改進使得速度快很多,並且有考慮到 side-channel attack 的問題:
Both implementations are constant-time and side-channel protected.
CloudFlare Go 1.4.2 Speedup AES-128-GCM 2,138.4 MB/sec 91.4 MB/sec 23.4X P256 operations: Base Multiply 26,249 ns/op 737,363 ns/op 28.1X Multiply/ECDH comp 110,003 ns/op 1,995,365 ns/op 18.1X Generate Key/ECDH gen 31,824 ns/op 753,174 ns/op 23.7X ECDSA Sign 48,741 ns/op 1,015,006 ns/op 20.8X ECDSA Verify 146,991 ns/op 3,086,282 ns/op 21.0X RSA2048: Sign 3,733,747 ns/op 7,979,705 ns/op 2.1X Sign 3-prime 1,973,009 ns/op 5,035,561 ns/op 2.6X
AES-GCM 與 EC 的改善主要是利用 CPU 指令集加速:
[T]herefore we created assembly implementations of Elliptic Curves and AES-GCM for Go on the amd64 architecture, supporting the AES and CLMUL NI to bring performance up to par with the OpenSSL implementation we use for Universal SSL.
不過 RSA 的部份雖然幅度也不小 (比起 AES 與 EC 的部份是不大,不過純就數字來看,快了一倍多也不少),不過沒提到怎麼改善,只稍微帶過:
In addition the fork includes small improvements to Go's RSA implementation.