Yep.
I have a function that (also thanks to inlining) I'd expect not to allocate anything to the heap.
Total: 6340801 13065057 (flat, cum) 49.99%
26 . . binary.LittleEndian.PutUint64(buf[:], uint64(n))
27 . . p.Write(buf[:])
28 . . }
29 . .
30 . . func (c *chacha20poly1305) sealGeneric(dst, nonce, plaintext, additionalData []byte) []byte {
31 . 740 ret, out := sliceForAppend(dst, len(plaintext)+poly1305.TagSize)
32 . . ciphertext, tag := out[:len(plaintext)], out[len(plaintext):]
33 . . if subtle.InexactOverlap(out, plaintext) {
34 . . panic("chacha20poly1305: invalid buffer overlap")
35 . . }
36 . .
37 6340801 6340801 var polyKey [32]byte
38 . . s, _ := chacha20.NewUnauthenticatedCipher(c.key[:], nonce)
39 . . s.XORKeyStream(polyKey[:], polyKey[:])
40 . . s.Advance(1) // set the counter to 1, skipping 32 bytes
41 . . s.XORKeyStream(ciphertext, plaintext)
42 . .
43 . 6723516 p := poly1305.New(&polyKey)
44 . . writeWithPadding(p, additionalData)
45 . . writeWithPadding(p, ciphertext)
46 . . writeUint64(p, len(additionalData))
47 . . writeUint64(p, len(plaintext))
48 . . p.Sum(tag[:0])
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yep.
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
I have a function that (also thanks to inlining) I'd expect not to allocate anything to the heap.
https://go.googlesource.com/crypto/+/c8d9389ed30fa12bbe2123256b81a26dd5cbe7b8/chacha20poly1305/chacha20poly1305_generic.go (from CL 206977)
What did you see instead?
-gcflags=-mhas nothing about neitherpolyKeynorp.