From b483f382a2e0d11871b3e38f0c3c1831f5941599 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Wed, 20 Nov 2024 23:50:46 +1100 Subject: [PATCH] crypto/subtle: unbreak DIT test on openbsd/arm64 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 Reviewed-by: Roland Shoemaker Run-TryBot: Joel Sing LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek TryBot-Result: Gopher Robot --- src/crypto/subtle/dit_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/crypto/subtle/dit_test.go b/src/crypto/subtle/dit_test.go index 8753ed623fd..29779683b57 100644 --- a/src/crypto/subtle/dit_test.go +++ b/src/crypto/subtle/dit_test.go @@ -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") } }()