crypto/cipher: Unnecessary allocations when using boringcrypto's AES-GCM implementation #71139
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Go version
go1.24-20241213-RC00
Output of
go env
in your module/workspace:What did you do?
I ran the following benchmark tests for AES-GCM encryption and decryption:
What did you see happen?
I built the test target and run the benchmark tests with
the output was:
The decryption takes 5x longer than the encryption, and does 48 allocations, while the encryption only does 2 allocations.
What did you expect to see?
That the decryption is about as fast as the encryption.
I think the problem is here:
https://github.com/golang/go/blob/master/src/crypto/internal/boring/aes.go#L366
When I replace this loop by this:
The issue goes away.
The text was updated successfully, but these errors were encountered: