From 6226fba0004b68c81e6bac7b574f7762e76d9e88 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Wed, 17 Aug 2022 22:31:21 +0200 Subject: [PATCH] crypto: add better support for alternative backends --- .github/workflows/go-crypto.yml | 42 +++++++++++++++++++++++++++++++++ core/crypto/bench_test.go | 4 ++-- go.mod | 3 ++- go.sum | 6 +++-- 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/go-crypto.yml diff --git a/.github/workflows/go-crypto.yml b/.github/workflows/go-crypto.yml new file mode 100644 index 0000000000..77818b529e --- /dev/null +++ b/.github/workflows/go-crypto.yml @@ -0,0 +1,42 @@ +# Workflow to test different crypto backends +# Don't test std go as this is already tested by the other testsuite + +on: [push, pull_request] +name: Go Crypto + +jobs: + unit: + strategy: + fail-fast: false + matrix: + os: [ "ubuntu" ] + go: [ "1.19.x" ] + backend: [ "boringcrypto", "openssl" ] + env: + COVERAGES: "" + runs-on: ${{ format('{0}-latest', matrix.os) }} + name: ${{ matrix.os }} ${{ matrix.backend }} (go ${{ matrix.go }}) + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Go information + run: | + go version + go env + - name: Run repo-specific setup + uses: ./.github/actions/go-test-setup + if: hashFiles('./.github/actions/go-test-setup') != '' + - name: Run tests + run: | + if [[ "$backend" == "boringcrypto" ]]; then export GOEXPERIMENT="boringcrypto"; fi + if [[ "$backend" == "openssl" ]]; then export GOTAGS="-tags=openssl"; fi + go test $GOTAGS -v -shuffle=on ./... + cd core/crypto + # ensure that the boringcrypto build do infact contains boringcrypto symbols + if [[ "$backend" == "boringcrypto" ]]; then go test -c . && objdump -x crypto.test | grep goboringcrypto -q; fi + env: + backend: ${{ matrix.backend }} diff --git a/core/crypto/bench_test.go b/core/crypto/bench_test.go index 1001fe39af..e1ed4b76fe 100644 --- a/core/crypto/bench_test.go +++ b/core/crypto/bench_test.go @@ -39,7 +39,7 @@ func RunBenchmarkSignEd25519(b *testing.B, numBytes int) { } func runBenchmarkSign(b *testing.B, numBytes int, t int) { - secret, _, err := GenerateKeyPair(t, 1024) + secret, _, err := GenerateKeyPair(t, 2048) if err != nil { b.Fatal(err) } @@ -62,7 +62,7 @@ func RunBenchmarkVerifyEd25519(b *testing.B, numBytes int) { } func runBenchmarkVerify(b *testing.B, numBytes int, t int) { - secret, public, err := GenerateKeyPair(t, 1024) + secret, public, err := GenerateKeyPair(t, 2048) if err != nil { b.Fatal(err) } diff --git a/go.mod b/go.mod index 15f490a9d3..62c9c2b5a0 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/libp2p/go-msgio v0.2.0 github.com/libp2p/go-nat v0.1.0 github.com/libp2p/go-netroute v0.2.0 - github.com/libp2p/go-openssl v0.0.7 + github.com/libp2p/go-openssl v0.1.0 github.com/libp2p/go-reuseport v0.2.0 github.com/libp2p/go-yamux/v3 v3.1.2 github.com/libp2p/zeroconf/v2 v2.1.1 @@ -87,6 +87,7 @@ require ( github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect github.com/marten-seemann/qtls-go1-19 v0.1.0-beta.1 // indirect github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-pointer v0.0.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/miekg/dns v1.1.50 // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect diff --git a/go.sum b/go.sum index 37e6b43da1..aa1095a8fd 100644 --- a/go.sum +++ b/go.sum @@ -309,8 +309,8 @@ github.com/libp2p/go-nat v0.1.0/go.mod h1:X7teVkwRHNInVNWQiO/tAiAVRwSr5zoRz4YSTC github.com/libp2p/go-netroute v0.1.2/go.mod h1:jZLDV+1PE8y5XxBySEBgbuVAXbhtuHSdmLPL2n9MKbk= github.com/libp2p/go-netroute v0.2.0 h1:0FpsbsvuSnAhXFnCY0VLFbJOzaK0VnP0r1QT/o4nWRE= github.com/libp2p/go-netroute v0.2.0/go.mod h1:Vio7LTzZ+6hoT4CMZi5/6CpY3Snzh2vgZhWgxMNwlQI= -github.com/libp2p/go-openssl v0.0.7 h1:eCAzdLejcNVBzP/iZM9vqHnQm+XyCEbSSIheIPRGNsw= -github.com/libp2p/go-openssl v0.0.7/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= +github.com/libp2p/go-openssl v0.1.0 h1:LBkKEcUv6vtZIQLVTegAil8jbNpJErQ9AnT+bWV+Ooo= +github.com/libp2p/go-openssl v0.1.0/go.mod h1:OiOxwPpL3n4xlenjx2h7AwSGaFSC/KZvf6gNdOBQMtc= github.com/libp2p/go-reuseport v0.2.0 h1:18PRvIMlpY6ZK85nIAicSBuXXvrYoSw3dsBAR7zc560= github.com/libp2p/go-reuseport v0.2.0/go.mod h1:bvVho6eLMm6Bz5hmU0LYN3ixd3nPPvtIlaURZZgOY4k= github.com/libp2p/go-sockaddr v0.0.2/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k= @@ -336,6 +336,8 @@ github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8 github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= +github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=