Prefer AES when hardware acceleration is available

ChaCha20-Poly1305 is more efficient in software, but many modern CPUs
have acceleration for AES which makes AES-GCM the more preferable choice
in terms of throughput and battery consumption (i.e., less CPU cycles
per byte).

Use the CPU features as reported by BoringSSL to determine when to
prioritize AES-GCM over ChaCha20-Poly1305. This should be good enough to
say when the trade-off should be made.

Bug: 26945889
Change-Id: I7ae2f3e422e30e83324c08514509cb3e9a506d97
2 files changed