diff --git a/src/crypto/internal/boring/aes.go b/src/crypto/internal/boring/aes.go index d18ed5cdc5..a2aa7eb2df 100644 --- a/src/crypto/internal/boring/aes.go +++ b/src/crypto/internal/boring/aes.go @@ -48,6 +48,7 @@ import ( "crypto/cipher" "errors" "runtime" + "slices" "strconv" "unsafe" ) @@ -323,9 +324,7 @@ func (g *aesGCM) Seal(dst, nonce, plaintext, additionalData []byte) []byte { // Make room in dst to append plaintext+overhead. n := len(dst) - for cap(dst) < n+len(plaintext)+gcmTagSize { - dst = append(dst[:cap(dst)], 0) - } + dst = slices.Grow(dst, len(plaintext)+gcmTagSize) dst = dst[:n+len(plaintext)+gcmTagSize] // Check delayed until now to make sure len(dst) is accurate.