diff --git a/_ertgo b/_ertgo index d6ef3b2d..dc254557 160000 --- a/_ertgo +++ b/_ertgo @@ -1 +1 @@ -Subproject commit d6ef3b2de824bc10397fff61d7380bfd31324a22 +Subproject commit dc2545578365cbd6afb0af852c1c6af1d51c45d3 diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index c639a63e..5c98c3bf 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get install -y --no-install-recommends \ ARG erttag=v0.5.1 ARG egotag=v1.8.1 -RUN wget -qO- https://go.dev/dl/go1.25.6.linux-amd64.tar.gz | tar -C /usr/local -xz \ +RUN wget -qO- https://go.dev/dl/go1.26.1.linux-amd64.tar.gz | tar -C /usr/local -xz \ && git clone -b $erttag --depth=1 https://github.com/edgelesssys/edgelessrt \ && git clone -b $egotag --depth=1 https://github.com/edgelesssys/ego \ && mkdir ertbuild egobuild diff --git a/dockerfiles/Dockerfile.focal b/dockerfiles/Dockerfile.focal index 99a0d7ad..e85b2bb2 100644 --- a/dockerfiles/Dockerfile.focal +++ b/dockerfiles/Dockerfile.focal @@ -13,7 +13,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ARG erttag=v0.5.1 ARG egotag=v1.8.1 -RUN wget -qO- https://go.dev/dl/go1.25.6.linux-amd64.tar.gz | tar -C /usr/local -xz \ +RUN wget -qO- https://go.dev/dl/go1.26.1.linux-amd64.tar.gz | tar -C /usr/local -xz \ && git clone -b $erttag --depth=1 https://github.com/edgelesssys/edgelessrt \ && git clone -b $egotag --depth=1 https://github.com/edgelesssys/ego \ && mkdir ertbuild egobuild diff --git a/ego/cmd/integration-test/main.go b/ego/cmd/integration-test/main.go index 12b01a78..d70fbe6e 100644 --- a/ego/cmd/integration-test/main.go +++ b/ego/cmd/integration-test/main.go @@ -7,8 +7,10 @@ package main import ( + "crypto/rand" "io" "log" + "math" "os" "github.com/edgelesssys/ego/ego/test" @@ -28,6 +30,7 @@ func main() { testFileSystemMounts(assert, require) testEnvVars(assert, require) testCpuid(assert, require) + testRand(assert, require) } func testFileSystemMounts(assert *assert.Assertions, require *require.Assertions) { @@ -104,3 +107,32 @@ func testEnvVars(assert *assert.Assertions, require *require.Assertions) { func testCpuid(assert *assert.Assertions, require *require.Assertions) { assert.True(cpuid.CPU.Has(cpuid.CMOV)) } + +func testRand(assert *assert.Assertions, require *require.Assertions) { + // This test + // - does a sanity check of returned randomness + // - implicitly verifies that FIPS entropy initialization succeeds when built with GOFIPS140 + buf := make([]byte, 8192) + n, err := rand.Read(buf) + require.NoError(err) + require.Equal(8192, n) + assert.Greater(entropy(buf), 7.9) +} + +func entropy(data []byte) float64 { + var freq [256]int + for _, b := range data { + freq[b]++ + } + + lenData := float64(len(data)) + var entropy float64 + for _, n := range freq { + if n > 0 { + p := float64(n) / lenData + entropy -= p * math.Log2(p) + } + } + + return entropy +} diff --git a/ego/test/t.go b/ego/test/t.go index ba183434..0aaa0797 100644 --- a/ego/test/t.go +++ b/ego/test/t.go @@ -31,6 +31,12 @@ func (t *T) FailNow() { // Exit exits the program with an appropriate exit code. func (t *T) Exit() { + // This func is usually run deferred, so repanic on panic + // because otherwise the test would be marked as passed. + if e := recover(); e != nil { + panic(e) + } + var msg string if t.exitCode == 0 { msg = "passed"