mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
crypto/internal/fips140/entropy: move to crypto/internal/entropy/v1.0.0
The lab confirmed the that entropy source doesn't have to be inside the module boundary, although changing the entropy source of a module does require recertification. Move the v1.0.0 entropy source out of crypto/internal/fips140, to a versioned path that lets us keep multiple versions (which would be used by different modules) if we wish to. Change-Id: I6a6a69647e9dfca1c375650a0869bdc001d65173 Reviewed-on: https://go-review.googlesource.com/c/go/+/710057 Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
99cf4d671c
commit
8539691d0c
7 changed files with 16 additions and 15 deletions
|
|
@ -4,8 +4,10 @@
|
||||||
|
|
||||||
// Package entropy provides the passive entropy source for the FIPS 140-3
|
// Package entropy provides the passive entropy source for the FIPS 140-3
|
||||||
// module. It is only used in FIPS mode by [crypto/internal/fips140/drbg.Read]
|
// module. It is only used in FIPS mode by [crypto/internal/fips140/drbg.Read]
|
||||||
// from the FIPS 140-3 Go Cryptographic Module v1.0.0. Later versions of the
|
// from the FIPS 140-3 Go Cryptographic Module v1.0.0.
|
||||||
// module have an internal CPU jitter-based entropy source.
|
//
|
||||||
|
// Later versions of the module use the CPU jitter-based entropy source in the
|
||||||
|
// crypto/internal/entropy/v1.0.0 sub-package.
|
||||||
//
|
//
|
||||||
// This complied with IG 9.3.A, Additional Comment 12, which until January 1,
|
// This complied with IG 9.3.A, Additional Comment 12, which until January 1,
|
||||||
// 2026 allows new modules to meet an [earlier version] of Resolution 2(b):
|
// 2026 allows new modules to meet an [earlier version] of Resolution 2(b):
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
package drbg
|
package drbg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
entropy "crypto/internal/entropy/v1.0.0"
|
||||||
"crypto/internal/fips140"
|
"crypto/internal/fips140"
|
||||||
"crypto/internal/fips140/entropy"
|
|
||||||
"crypto/internal/randutil"
|
"crypto/internal/randutil"
|
||||||
"crypto/internal/sysrand"
|
"crypto/internal/sysrand"
|
||||||
"io"
|
"io"
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,10 @@ import (
|
||||||
//
|
//
|
||||||
// DO NOT add new packages here just to make the tests pass.
|
// DO NOT add new packages here just to make the tests pass.
|
||||||
var AllowedInternalPackages = map[string]bool{
|
var AllowedInternalPackages = map[string]bool{
|
||||||
// entropy.Depleted is the external passive entropy source, and sysrand.Read
|
// entropy.Depleted/Seed is the entropy source, and sysrand.Read
|
||||||
// is the actual (but uncredited!) random bytes source.
|
// is the actual (but uncredited!) random bytes source.
|
||||||
"crypto/internal/entropy": true,
|
"crypto/internal/entropy": true,
|
||||||
|
"crypto/internal/entropy/v1.0.0": true,
|
||||||
"crypto/internal/sysrand": true,
|
"crypto/internal/sysrand": true,
|
||||||
|
|
||||||
// impl.Register is how the packages expose their alternative
|
// impl.Register is how the packages expose their alternative
|
||||||
|
|
@ -88,8 +89,7 @@ func TestImports(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that all packages except check, check's dependencies, and the
|
// Ensure that all packages except check and check's dependencies import check.
|
||||||
// entropy source (which is used only from .../fips140/drbg) import check.
|
|
||||||
for pkg := range allPackages {
|
for pkg := range allPackages {
|
||||||
switch pkg {
|
switch pkg {
|
||||||
case "crypto/internal/fips140/check":
|
case "crypto/internal/fips140/check":
|
||||||
|
|
@ -100,7 +100,6 @@ func TestImports(t *testing.T) {
|
||||||
case "crypto/internal/fips140/sha3":
|
case "crypto/internal/fips140/sha3":
|
||||||
case "crypto/internal/fips140/sha256":
|
case "crypto/internal/fips140/sha256":
|
||||||
case "crypto/internal/fips140/sha512":
|
case "crypto/internal/fips140/sha512":
|
||||||
case "crypto/internal/fips140/entropy":
|
|
||||||
default:
|
default:
|
||||||
if !importCheck[pkg] {
|
if !importCheck[pkg] {
|
||||||
t.Errorf("package %s does not import crypto/internal/fips140/check", pkg)
|
t.Errorf("package %s does not import crypto/internal/fips140/check", pkg)
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ package fipstest
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/internal/cryptotest"
|
"crypto/internal/cryptotest"
|
||||||
|
entropy "crypto/internal/entropy/v1.0.0"
|
||||||
"crypto/internal/fips140/drbg"
|
"crypto/internal/fips140/drbg"
|
||||||
"crypto/internal/fips140/entropy"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
|
|
@ -217,7 +217,7 @@ func TestEntropyUnchanged(t *testing.T) {
|
||||||
testenv.MustHaveSource(t)
|
testenv.MustHaveSource(t)
|
||||||
|
|
||||||
h := sha256.New()
|
h := sha256.New()
|
||||||
root := os.DirFS("../fips140/entropy")
|
root := os.DirFS("../entropy/v1.0.0")
|
||||||
if err := fs.WalkDir(root, ".", func(path string, d fs.DirEntry, err error) error {
|
if err := fs.WalkDir(root, ".", func(path string, d fs.DirEntry, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -237,13 +237,13 @@ func TestEntropyUnchanged(t *testing.T) {
|
||||||
t.Fatalf("WalkDir: %v", err)
|
t.Fatalf("WalkDir: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The crypto/internal/fips140/entropy package is certified as a FIPS 140-3
|
// The crypto/internal/entropy/v1.0.0 package is certified as a FIPS 140-3
|
||||||
// entropy source through the Entropy Source Validation program,
|
// entropy source through the Entropy Source Validation program,
|
||||||
// independently of the FIPS 140-3 module. It must not change even across
|
// independently of the FIPS 140-3 module. It must not change even across
|
||||||
// FIPS 140-3 module versions, in order to reuse the ESV certificate.
|
// FIPS 140-3 module versions, in order to reuse the ESV certificate.
|
||||||
exp := "2541273241ae8aafe55026328354ed3799df1e2fb308b2097833203a42911b53"
|
exp := "2541273241ae8aafe55026328354ed3799df1e2fb308b2097833203a42911b53"
|
||||||
if got := hex.EncodeToString(h.Sum(nil)); got != exp {
|
if got := hex.EncodeToString(h.Sum(nil)); got != exp {
|
||||||
t.Errorf("hash of crypto/internal/fips140/entropy = %s, want %s", got, exp)
|
t.Errorf("hash of crypto/internal/entropy/v1.0.0 = %s, want %s", got, exp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -490,13 +490,13 @@ var depsRules = `
|
||||||
time, internal/syscall/windows < crypto/internal/fips140deps/time;
|
time, internal/syscall/windows < crypto/internal/fips140deps/time;
|
||||||
|
|
||||||
crypto/internal/fips140deps/time, errors, math/bits, sync/atomic, unsafe
|
crypto/internal/fips140deps/time, errors, math/bits, sync/atomic, unsafe
|
||||||
< crypto/internal/fips140/entropy;
|
< crypto/internal/entropy/v1.0.0;
|
||||||
|
|
||||||
STR, hash,
|
STR, hash,
|
||||||
crypto/internal/impl,
|
crypto/internal/impl,
|
||||||
crypto/internal/entropy,
|
crypto/internal/entropy,
|
||||||
crypto/internal/randutil,
|
crypto/internal/randutil,
|
||||||
crypto/internal/fips140/entropy,
|
crypto/internal/entropy/v1.0.0,
|
||||||
crypto/internal/fips140deps/byteorder,
|
crypto/internal/fips140deps/byteorder,
|
||||||
crypto/internal/fips140deps/cpu,
|
crypto/internal/fips140deps/cpu,
|
||||||
crypto/internal/fips140deps/godebug
|
crypto/internal/fips140deps/godebug
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue