_CryptoExtras provides AES CTR mode with a Swift implementation, which operates one block at a time. For encrypting larger plaintexts this can become a bottleneck. BoringSSL provides an implementation which makes use of hardware capabilities if present for parallel block processing.
Modifications:
Replace Swift implementation of _CryptoExtras.AES._CTR.encrypt and decrypt with a call to BoringSSL AES_ctr128_encrypt function.
Annotate the API as @inlinable for generic specialization.
Remove AES._CTR.Nonce.incrementCounter(), which was only used by the Swift implementation.
Result:
The runtime performance is improved by around 93% for encryption of larger plaintexts, e.g. 4k:
Motivation:
_CryptoExtras
provides AES CTR mode with a Swift implementation, which operates one block at a time. For encrypting larger plaintexts this can become a bottleneck. BoringSSL provides an implementation which makes use of hardware capabilities if present for parallel block processing.Modifications:
_CryptoExtras.AES._CTR.encrypt
anddecrypt
with a call to BoringSSLAES_ctr128_encrypt
function.@inlinable
for generic specialization.AES._CTR.Nonce.incrementCounter()
, which was only used by the Swift implementation.Result:
The runtime performance is improved by around 93% for encryption of larger plaintexts, e.g. 4k: