Skip to content

x/crypto/chacha20poly1305: overlap of dst and additionalData should panic #75968

@n2vi

Description

@n2vi

Go version

go1.25.2

Output of go env in your module/workspace:

specific version of Go or env is not relevant; comment has been unchanged for a long time.

What did you do?

I would like to be able to write:

aead, err := chacha20poly1305.NewX()
plaintext := []byte("hello, world")
dst := make([]byte, 0, 26+len(plaintext)+16)
dst[0] = 'a'
dst[1] = 'D'
rand.Read(dst[2:26])
dst = aead.Seal(dst, dst[2:26], plaintext, dst[0:2])

What did you see happen?

This does seem to work for the library AEAD versions.

What did you expect to see?

But the comment in type AEAD says dst and additionalData may not overlap.

Ok to change this to On input, dst[len(dst):cap(dst)] and additionalData may not overlap.?

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions