]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/internal/boring/fipstls: convert required to atomic type
authorcuiweixie <cuiweixie@gmail.com>
Sat, 27 Aug 2022 03:43:39 +0000 (11:43 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 1 Sep 2022 17:06:14 +0000 (17:06 +0000)
Change-Id: I73081b85e763122be1f5c0dbab25cecc9cf809df
Reviewed-on: https://go-review.googlesource.com/c/go/+/426087
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
src/crypto/internal/boring/fipstls/tls.go

index 701700e4e3ab36b5e57af7ebc0103b88c6f3248e..3bf1471fb0bce9cb6270d71c626827651f70c645 100644 (file)
@@ -11,7 +11,7 @@ package fipstls
 
 import "sync/atomic"
 
-var required uint32
+var required atomic.Bool
 
 // Force forces crypto/tls to restrict TLS configurations to FIPS-approved settings.
 // By design, this call is impossible to undo (except in tests).
@@ -19,7 +19,7 @@ var required uint32
 // Note that this call has an effect even in programs using
 // standard crypto (that is, even when Enabled = false).
 func Force() {
-       atomic.StoreUint32(&required, 1)
+       required.Store(true)
 }
 
 // Abandon allows non-FIPS-approved settings.
@@ -36,7 +36,7 @@ func Abandon() {
        if !hasSuffix(name, "_test") && !hasSuffix(name, ".test") && name != "NaClMain" && name != "" {
                panic("fipstls: invalid use of Abandon in " + name)
        }
-       atomic.StoreUint32(&required, 0)
+       required.Store(false)
 }
 
 // provided by runtime
@@ -48,5 +48,5 @@ func hasSuffix(s, t string) bool {
 
 // Required reports whether FIPS-approved settings are required.
 func Required() bool {
-       return atomic.LoadUint32(&required) != 0
+       return required.Load()
 }