Closed
Description
Here is a snippet to reproduce the problem:
package main
import (
"github.com/gopherjs/gopherjs/js"
"golang.org/x/crypto/chacha20poly1305"
)
func testchacha() {
key := make([]byte, chacha20poly1305.KeySize)
aead, err := chacha20poly1305.New(key)
if err != nil {
panic(err)
}
msg := []byte("Gophers, gophers, gophers everywhere!")
nonce := make([]byte, aead.NonceSize(), aead.NonceSize()+len(msg)+aead.Overhead())
_ = aead.Seal(nonce, nonce, msg, nil)
}
func main() {
js.Global.Set("gojs", map[string]interface{}{
"testchacha": testchacha,
})
}
Compile with gopherjs build -o test.js
.
Load in a browser:
<script src="test.js"></script>
Execute in console:
gojs.testchacha()
You will see this error:
test.js:1452 Uncaught Error: chacha20poly1305: invalid buffer overlap
at $callDeferred (test.js:1452)
at $panic (test.js:1495)
at Object.$packages.golang.org/x/crypto/chacha20poly1305.chacha20poly1305.ptr.sealGeneric (chacha20poly1305_generic.go:34)
at Object.$packages.golang.org/x/crypto/chacha20poly1305.chacha20poly1305.ptr.seal (chacha20poly1305_noasm.go:11)
at Object.$packages.golang.org/x/crypto/chacha20poly1305.chacha20poly1305.ptr.Seal (chacha20poly1305.go:62)
at testchacha (snippet.go:17)
at Object.v.$externalizeWrapper [as testchacha] (test.js:1908)
at <anonymous>:1:6
This regression comes from this change in x/crypto, where the build tags were changed for internal/subtle/aliasing.go
:
golang/crypto@be400ae#diff-31568a1efa7b47a907232185869dcbb02a8607ace0bc64690535af232284bfadR5
Before that change, aliasing.go was built by gopherjs, and everything worked fine. After this change, aliasing_purego.go is being built by gopherjs, causing the above problem.
Metadata
Metadata
Assignees
Labels
No labels