]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/subtle: unbreak DIT test on openbsd/arm64
authorJoel Sing <joel@sing.id.au>
Wed, 20 Nov 2024 12:50:46 +0000 (23:50 +1100)
committerRoland Shoemaker <roland@golang.org>
Wed, 20 Nov 2024 16:31:41 +0000 (16:31 +0000)
OpenBSD already enables DIT on arm64 in both kernel and userland.
As such, if DIT is already enabled, do not expect that it can be
disabled.

Change-Id: If7aae2ace40d97109beefa71c03e0c138a0995ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/629995
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/crypto/subtle/dit_test.go

index 8753ed623fd4389e798d13380650ebc9aecb1297..29779683b57c06b2c5cd86721b84a2ac74afbf03 100644 (file)
@@ -15,6 +15,8 @@ func TestWithDataIndependentTiming(t *testing.T) {
                t.Skip("CPU does not support DIT")
        }
 
+       ditAlreadyEnabled := sys.DITEnabled()
+
        WithDataIndependentTiming(func() {
                if !sys.DITEnabled() {
                        t.Fatal("dit not enabled within WithDataIndependentTiming closure")
@@ -31,7 +33,7 @@ func TestWithDataIndependentTiming(t *testing.T) {
                }
        })
 
-       if sys.DITEnabled() {
+       if !ditAlreadyEnabled && sys.DITEnabled() {
                t.Fatal("dit not unset after returning from WithDataIndependentTiming closure")
        }
 }
@@ -41,12 +43,14 @@ func TestDITPanic(t *testing.T) {
                t.Skip("CPU does not support DIT")
        }
 
+       ditAlreadyEnabled := sys.DITEnabled()
+
        defer func() {
                e := recover()
                if e == nil {
                        t.Fatal("didn't panic")
                }
-               if sys.DITEnabled() {
+               if !ditAlreadyEnabled && sys.DITEnabled() {
                        t.Error("DIT still enabled after panic inside of WithDataIndependentTiming closure")
                }
        }()