Commit ad935b611a for golang
commit ad935b611ab877a95127715e540dd8612cbea190
Author: Nicholas S. Husin <nsh@golang.org>
Date: Mon Nov 30 17:41:43 2026 -0500
all: update to x/mod@dd05bf97a6a5
This is to bring in ML-DSA-44 support to cmd/go.
For #83639
Change-Id: Ic4061cedba3bf9cc372912b1b5a7eb5a6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/868905
Reviewed-by: Neal Patel <neal@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/src/cmd/go.mod b/src/cmd/go.mod
index 10ff008825..8995e225a4 100644
--- a/src/cmd/go.mod
+++ b/src/cmd/go.mod
@@ -6,7 +6,7 @@ require (
github.com/google/pprof v0.0.0-20261118010117-084b33a85f63
golang.org/x/arch v0.33.1-0.20261125042448-08f54687881f
golang.org/x/build v0.0.0-20261119205413-41b438ee44b1
- golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf
+ golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5
golang.org/x/sync v0.25.0
golang.org/x/sys v0.50.1-0.20261120131340-d4690d67735d
golang.org/x/telemetry v0.0.0-20261124234621-1402bdb29cb5
diff --git a/src/cmd/go.sum b/src/cmd/go.sum
index 80b9d2c851..037fa68fc3 100644
--- a/src/cmd/go.sum
+++ b/src/cmd/go.sum
@@ -10,8 +10,8 @@ golang.org/x/arch v0.33.1-0.20261125042448-08f54687881f h1:E3aYC61+fmNh2qzHIkLgo
golang.org/x/arch v0.33.1-0.20261125042448-08f54687881f/go.mod h1:yelN722/RE0EdL5KBgAqvVqP++p/dn8sL4UaLD8n8As=
golang.org/x/build v0.0.0-20261119205413-41b438ee44b1 h1:cqZR/7vWX6cRca9yj1SCk7odm7YBfdJW3ninO/ioJ28=
golang.org/x/build v0.0.0-20261119205413-41b438ee44b1/go.mod h1:DOKivSdemrobpP+uz+8ayH3p2t2tLE+IwRPpOfUxL+Q=
-golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf h1:lJCJXanKWPoCLOjHWfHVDUMFfVmQaHnt8TO1IF3YBw0=
-golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY=
+golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5 h1:u6LG13Y7xtpSEjTHcR10buvRpeKP4a0p1pN9pIGMJFc=
+golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY=
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.50.1-0.20261120131340-d4690d67735d h1:BnUHpJIYQMlea9tRBlnq96cb2l/I3eiJNgnLVf5zm04=
diff --git a/src/cmd/vendor/golang.org/x/mod/sumdb/note/mldsa.go b/src/cmd/vendor/golang.org/x/mod/sumdb/note/mldsa.go
new file mode 100644
index 0000000000..a3980d54a8
--- /dev/null
+++ b/src/cmd/vendor/golang.org/x/mod/sumdb/note/mldsa.go
@@ -0,0 +1,232 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build go1.27 && !fips140v1.0
+
+// The implementation is adapted from filippo.io/torchwood v0.10.0.
+
+package note
+
+import (
+ "crypto/mldsa"
+ "crypto/sha256"
+ "encoding/base64"
+ "encoding/binary"
+ "errors"
+ "fmt"
+ "io"
+ "math"
+ "strconv"
+ "strings"
+ "time"
+
+ "golang.org/x/mod/sumdb/tlog"
+)
+
+func mldsa44Verify(name string, key []byte) (func(msg, sig []byte) bool, error) {
+ pub, err := mldsa.NewPublicKey(mldsa.MLDSA44(), key)
+ if err != nil {
+ return nil, errVerifierID
+ }
+ return func(msg, sig []byte) bool {
+ if len(sig) != 8+mldsa.MLDSA44SignatureSize {
+ return false
+ }
+ t := binary.BigEndian.Uint64(sig)
+ if t > math.MaxInt64 {
+ return false
+ }
+ sig = sig[8:]
+ m, err := formatSubtreeV1(name, t, msg)
+ if err != nil {
+ return false
+ }
+ return mldsa.Verify(pub, m, sig, nil) == nil
+ }, nil
+}
+
+func mldsa44Sign(name string, key []byte) ([]byte, func(msg []byte) ([]byte, error), error) {
+ priv, err := mldsa.NewPrivateKey(mldsa.MLDSA44(), key)
+ if err != nil {
+ return nil, nil, errSignerID
+ }
+ pubkey := append([]byte{algMLDSA44}, priv.PublicKey().Bytes()...)
+ sign := func(msg []byte) ([]byte, error) {
+ t := uint64(time.Now().Unix())
+ m, err := formatSubtreeV1(name, t, msg)
+ if err != nil {
+ return nil, err
+ }
+ s, err := priv.Sign(nil, m, nil)
+ if err != nil {
+ return nil, err
+ }
+ // The signature itself is encoded as timestamp || signature.
+ sig := make([]byte, 0, 8+mldsa.MLDSA44SignatureSize)
+ sig = binary.BigEndian.AppendUint64(sig, t)
+ sig = append(sig, s...)
+ return sig, nil
+ }
+ return pubkey, sign, nil
+}
+
+func formatSubtreeV1(name string, t uint64, msg []byte) ([]byte, error) {
+ c, err := parseCheckpoint(string(msg))
+ if err != nil {
+ return nil, fmt.Errorf("message being signed is not a valid checkpoint: %w", err)
+ }
+ // Unsigned extension lines are dangerous, for now don't support them,
+ // unless and until someone suggests a good/safe use case.
+ if c.extension != "" {
+ return nil, errors.New("ML-DSA cosignatures do not support checkpoints with extension lines")
+ }
+ if string(msg) != c.String() {
+ return nil, errors.New("message being signed does not match parsed checkpoint")
+ }
+ return subtreeCosignedMessage(name, t, c.origin, 0, c.N, c.Hash)
+}
+
+// emptyHash is the hash of the empty tree and of empty subtrees, per
+// RFC 6962, Section 2.1. It is the hash of the empty string.
+var emptyHash = tlog.Hash(sha256.Sum256(nil))
+
+func subtreeCosignedMessage(name string, t uint64, origin string, start, end int64, hash tlog.Hash) ([]byte, error) {
+ // The signed message is in the following format
+ //
+ // struct {
+ // uint8 label[12] = "subtree/v1\n\0";
+ // opaque cosigner_name<1..2^8-1>;
+ // uint64 timestamp;
+ // opaque log_origin<1..2^8-1>;
+ // uint64 start;
+ // uint64 end;
+ // uint8 hash[32];
+ // } cosigned_message;
+ if len(name) == 0 || len(name) > 255 {
+ return nil, errors.New("cosigner name must be 1-255 bytes")
+ }
+ if t > math.MaxInt64 {
+ return nil, errors.New("timestamp is too large")
+ }
+ if t != 0 && start != 0 {
+ return nil, errors.New("timestamp must be zero for non-root subtrees")
+ }
+ if len(origin) == 0 || len(origin) > 255 {
+ return nil, errors.New("log origin must be 1-255 bytes")
+ }
+ if start == end && hash != emptyHash {
+ return nil, errors.New("the hash of an empty subtree must be the hash of the empty string")
+ }
+
+ b := make([]byte, 0, 12+1+len(name)+8+1+len(origin)+8+8+tlog.HashSize)
+ b = append(b, "subtree/v1\n\x00"...)
+ b = append(b, byte(len(name)))
+ b = append(b, name...)
+ b = binary.BigEndian.AppendUint64(b, t)
+ b = append(b, byte(len(origin)))
+ b = append(b, origin...)
+ b = binary.BigEndian.AppendUint64(b, uint64(start))
+ b = binary.BigEndian.AppendUint64(b, uint64(end))
+ b = append(b, hash[:]...)
+ return b, nil
+}
+
+const maxCheckpointSize = 1e6
+
+// A checkpoint is a tree head to be formatted according to c2sp.org/tlog-checkpoint.
+//
+// A checkpoint looks like this:
+//
+// example.com/origin
+// 923748
+// nND/nri/U0xuHUrYSy0HtMeal2vzD9V4k/BO79C+QeI=
+//
+// It can be followed by extra extension lines.
+type checkpoint struct {
+ origin string
+ tlog.Tree
+
+ // Extension is empty or a sequence of non-empty lines,
+ // each terminated by a newline character.
+ extension string
+}
+
+// parseCheckpoint parses a c2sp.org/tlog-checkpoint payload without signatures.
+func parseCheckpoint(text string) (checkpoint, error) {
+ // This is an extended version of tlog.ParseTree.
+
+ if strings.Count(text, "\n") < 3 || len(text) > maxCheckpointSize {
+ return checkpoint{}, errors.New("malformed checkpoint")
+ }
+ if !strings.HasSuffix(text, "\n") {
+ return checkpoint{}, errors.New("malformed checkpoint")
+ }
+
+ lines := strings.SplitN(text, "\n", 4)
+
+ n, err := strconv.ParseInt(lines[1], 10, 64)
+ if err != nil || n < 0 || lines[1] != strconv.FormatInt(n, 10) {
+ return checkpoint{}, errors.New("malformed checkpoint")
+ }
+
+ h, err := base64.StdEncoding.DecodeString(lines[2])
+ if err != nil || len(h) != tlog.HashSize {
+ return checkpoint{}, errors.New("malformed checkpoint")
+ }
+
+ rest := lines[3]
+ for rest != "" {
+ before, after, found := strings.Cut(rest, "\n")
+ if before == "" || !found {
+ return checkpoint{}, errors.New("malformed checkpoint")
+ }
+ rest = after
+ }
+
+ var hash tlog.Hash
+ copy(hash[:], h)
+ return checkpoint{lines[0], tlog.Tree{N: n, Hash: hash}, lines[3]}, nil
+}
+
+func (c checkpoint) String() string {
+ return fmt.Sprintf("%s\n%d\n%s\n%s",
+ c.origin,
+ c.N,
+ base64.StdEncoding.EncodeToString(c.Hash[:]),
+ c.extension,
+ )
+}
+
+// generateMLDSA44Key generates an ML-DSA-44 signer and verifier key pair for a named server.
+func generateMLDSA44Key(rand io.Reader, name string) (skey, vkey string, err error) {
+ seed := make([]byte, mldsa.PrivateKeySize)
+ if _, err := io.ReadFull(rand, seed); err != nil {
+ return "", "", err
+ }
+ priv, err := mldsa.NewPrivateKey(mldsa.MLDSA44(), seed)
+ if err != nil {
+ return "", "", err
+ }
+ pubkey := append([]byte{algMLDSA44}, priv.PublicKey().Bytes()...)
+ privkey := append([]byte{algMLDSA44}, seed...)
+ h := keyHash(name, pubkey)
+
+ skey = fmt.Sprintf("PRIVATE+KEY+%s+%08x+%s", name, h, base64.StdEncoding.EncodeToString(privkey))
+ vkey = fmt.Sprintf("%s+%08x+%s", name, h, base64.StdEncoding.EncodeToString(pubkey))
+ return skey, vkey, nil
+}
+
+// newMLDSA44VerifierKey returns an encoded verifier key using the given name
+// and ML-DSA-44 public key.
+func newMLDSA44VerifierKey(name string, key *mldsa.PublicKey) (string, error) {
+ if key == nil || key.Parameters() != mldsa.MLDSA44() {
+ return "", fmt.Errorf("invalid ML-DSA-44 public key")
+ }
+
+ pubkey := append([]byte{algMLDSA44}, key.Bytes()...)
+ hash := keyHash(name, pubkey)
+
+ b64Key := base64.StdEncoding.EncodeToString(pubkey)
+ return fmt.Sprintf("%s+%08x+%s", name, hash, b64Key), nil
+}
diff --git a/src/cmd/vendor/golang.org/x/mod/sumdb/note/mldsa_stub.go b/src/cmd/vendor/golang.org/x/mod/sumdb/note/mldsa_stub.go
new file mode 100644
index 0000000000..37a820ae21
--- /dev/null
+++ b/src/cmd/vendor/golang.org/x/mod/sumdb/note/mldsa_stub.go
@@ -0,0 +1,15 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !go1.27 || fips140v1.0
+
+package note
+
+func mldsa44Verify(name string, key []byte) (func(msg, sig []byte) bool, error) {
+ return nil, errVerifierAlg
+}
+
+func mldsa44Sign(name string, key []byte) ([]byte, func(msg []byte) ([]byte, error), error) {
+ return nil, nil, errSignerAlg
+}
diff --git a/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go b/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go
index a41a0e56b0..e312db56e6 100644
--- a/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go
+++ b/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go
@@ -230,6 +230,7 @@ var (
const (
algEd25519 = 1
+ algMLDSA44 = 6
)
// isValidName reports whether name is valid.
@@ -268,6 +269,12 @@ func NewVerifier(vkey string) (Verifier, error) {
v.verify = func(msg, sig []byte) bool {
return ed25519.Verify(key, msg, sig)
}
+ case algMLDSA44:
+ verify, err := mldsa44Verify(name, key)
+ if err != nil {
+ return nil, err
+ }
+ v.verify = verify
}
return v, nil
@@ -320,6 +327,12 @@ func NewSigner(skey string) (Signer, error) {
s.sign = func(msg []byte) ([]byte, error) {
return ed25519.Sign(key, msg), nil
}
+ case algMLDSA44:
+ var err error
+ pubkey, s.sign, err = mldsa44Sign(name, key)
+ if err != nil {
+ return nil, err
+ }
}
if uint32(hash) != keyHash(name, pubkey) {
diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt
index 951987f8c4..5b897d076c 100644
--- a/src/cmd/vendor/modules.txt
+++ b/src/cmd/vendor/modules.txt
@@ -29,7 +29,7 @@ golang.org/x/arch/x86/x86asm
# golang.org/x/build v0.0.0-20261119205413-41b438ee44b1
## explicit; go 1.26.0
golang.org/x/build/relnote
-# golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf
+# golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5
## explicit; go 1.26.0
golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile
diff --git a/src/go.mod b/src/go.mod
index 416e8bba3e..34448573a2 100644
--- a/src/go.mod
+++ b/src/go.mod
@@ -10,6 +10,6 @@ require (
)
require (
- golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf // indirect
+ golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5 // indirect
golang.org/x/text v0.44.1-0.20261117190556-9e7a977af666 // indirect
)
diff --git a/src/go.sum b/src/go.sum
index da0f518b0b..e1930a7e70 100644
--- a/src/go.sum
+++ b/src/go.sum
@@ -2,8 +2,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/crypto v0.59.1-0.20261123192653-4dc4fb521066 h1:Ofz59C7AVXR9r3bQLgiADl5hUY9EqhXnm4ClSavKx5k=
golang.org/x/crypto v0.59.1-0.20261123192653-4dc4fb521066/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
-golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf h1:lJCJXanKWPoCLOjHWfHVDUMFfVmQaHnt8TO1IF3YBw0=
-golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY=
+golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5 h1:u6LG13Y7xtpSEjTHcR10buvRpeKP4a0p1pN9pIGMJFc=
+golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY=
golang.org/x/net v0.63.1-0.20261119175338-fd4c9ad54137 h1:Rusti8zeC6xaHNurcFe38Kl+10hovqBrci8MBZt6Cl0=
golang.org/x/net v0.63.1-0.20261119175338-fd4c9ad54137/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt
index 9aa12682b4..c5f87d52c6 100644
--- a/src/vendor/modules.txt
+++ b/src/vendor/modules.txt
@@ -7,7 +7,7 @@ golang.org/x/crypto/cryptobyte/asn1
golang.org/x/crypto/hkdf
golang.org/x/crypto/internal/alias
golang.org/x/crypto/internal/poly1305
-# golang.org/x/mod v0.43.1-0.20261112161916-2b553c8b61bf
+# golang.org/x/mod v0.43.1-0.20261203225801-dd05bf97a6a5
## explicit; go 1.26.0
# golang.org/x/net v0.63.1-0.20261119175338-fd4c9ad54137
## explicit; go 1.26.0