ProtonMail / go-crypto

Fork of go/x/crypto, providing an up-to-date OpenPGP implementation
https://pkg.go.dev/github.com/ProtonMail/go-crypto
BSD 3-Clause "New" or "Revised" License
328 stars 99 forks source link

Tests fail on 32bit architectures. #177

Closed mdosch closed 1 year ago

mdosch commented 1 year ago

Dear go-crypto devs,

I realized that building a current go-crypto (3fbb1f1) for debian fails checks on armel, armhf and i386. I checked out the current master on my amd64 laptop running debian stable and could reproduce it:

~/build/go-crypto/openpgp/s2k (git)-[main] % GOARCH=386 go test
--- FAIL: TestParseIntoParams (0.12s)
panic: runtime error: makeslice: len out of range [recovered]
    panic: runtime error: makeslice: len out of range

goroutine 301 [running]:
testing.tRunner.func1.2({0x8162f60, 0x81a547c})
    /usr/lib/go-1.19/src/testing/testing.go:1396 +0x2ab
testing.tRunner.func1()
    /usr/lib/go-1.19/src/testing/testing.go:1399 +0x41f
panic({0x8162f60, 0x81a547c})
    /usr/lib/go-1.19/src/runtime/panic.go:884 +0x1c3
golang.org/x/crypto/argon2.initBlocks(0x9116000, 0x400000, 0x4)
    /home/martin/build/go/pkg/mod/golang.org/x/crypto@v0.7.0/argon2/argon2.go:158 +0x49
golang.org/x/crypto/argon2.deriveKey(0x2, {0x9018290, 0x5, 0x8}, {0x909c13a, 0x10, 0x10}, {0x0, 0x0, 0x0}, ...)
    /home/martin/build/go/pkg/mod/golang.org/x/crypto@v0.7.0/argon2/argon2.go:113 +0x183
golang.org/x/crypto/argon2.IDKey(...)
    /home/martin/build/go/pkg/mod/golang.org/x/crypto@v0.7.0/argon2/argon2.go:97
github.com/ProtonMail/go-crypto/openpgp/s2k.Argon2({0x9018288, 0x4, 0x4}, {0x9018290, 0x5, 0x8}, {0x909c13a, 0x10, 0x10}, 0x3, ...)
    /home/martin/build/go-crypto/openpgp/s2k/s2k.go:178 +0xb9
github.com/ProtonMail/go-crypto/openpgp/s2k.(*Params).Function.func4({0x9018288, 0x4, 0x4}, {0x9018290, 0x5, 0x8})
    /home/martin/build/go-crypto/openpgp/s2k/s2k.go:352 +0xae
github.com/ProtonMail/go-crypto/openpgp/s2k.TestParseIntoParams(0xd201c20)
    /home/martin/build/go-crypto/openpgp/s2k/s2k_test.go:172 +0x50d
testing.tRunner(0xd201c20, 0x8182ae4)
    /usr/lib/go-1.19/src/testing/testing.go:1446 +0x113
created by testing.(*T).Run
    /usr/lib/go-1.19/src/testing/testing.go:1493 +0x374
exit status 2
FAIL    github.com/ProtonMail/go-crypto/openpgp/s2k 2.156s
twiss commented 1 year ago

(Thanks for the report!)

mdosch commented 1 year ago

Thank you for the quick fix. :)