diff --git a/lib/time/update.bash b/lib/time/update.bash index 5e2c0873cd3600..768c244cf0f374 100755 --- a/lib/time/update.bash +++ b/lib/time/update.bash @@ -24,8 +24,8 @@ # in the CL match the update.bash in the CL. # Versions to use. -CODE=2026b -DATA=2026b +CODE=2026c +DATA=2026c set -e diff --git a/lib/time/zoneinfo.zip b/lib/time/zoneinfo.zip index 2d8488cee0223a..46c90a2b806a92 100644 Binary files a/lib/time/zoneinfo.zip and b/lib/time/zoneinfo.zip differ diff --git a/src/cmd/go/testdata/script/build_overlay.txt b/src/cmd/go/testdata/script/build_overlay.txt index 1111d119ba2841..fe6ddadaaaa112 100644 --- a/src/cmd/go/testdata/script/build_overlay.txt +++ b/src/cmd/go/testdata/script/build_overlay.txt @@ -33,28 +33,10 @@ exec ./print_trimpath_two_files$GOEXE stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]main.go stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]other.go -[cgo] go build -overlay overlay.json -o main_cgo_replace$GOEXE ./cgo_hello_replace -[cgo] exec ./main_cgo_replace$GOEXE -[cgo] stdout '^hello cgo\r?\n' - -[cgo] go build -overlay overlay.json -o main_cgo_quote$GOEXE ./cgo_hello_quote -[cgo] exec ./main_cgo_quote$GOEXE -[cgo] stdout '^hello cgo\r?\n' - -[cgo] go build -overlay overlay.json -o main_cgo_angle$GOEXE ./cgo_hello_angle -[cgo] exec ./main_cgo_angle$GOEXE -[cgo] stdout '^hello cgo\r?\n' - go build -overlay overlay.json -o main_call_asm$GOEXE ./call_asm exec ./main_call_asm$GOEXE ! stdout . -[cgo] go list -compiled -overlay overlay.json -f '{{range .CompiledGoFiles}}{{. | printf "%s\n"}}{{end}}' ./cgo_hello_replace -[cgo] cp stdout compiled_cgo_sources.txt -[cgo] go run ../print_line_comments.go compiled_cgo_sources.txt -[cgo] stdout $GOPATH[/\\]src[/\\]m[/\\]cgo_hello_replace[/\\]cgo_hello_replace.go -[cgo] ! stdout $GOPATH[/\\]src[/\\]m[/\\]overlay[/\\]hello.c - # Change the contents of a file in the overlay and ensure that makes the target stale env OLD_GOCACHE=$GOCACHE env GOCACHE=$WORK/cache # use a fresh cache so that multiple runs of the test don't interfere @@ -67,42 +49,6 @@ go build -x -overlay overlay.json ./test_cache stderr '(compile|gccgo)( |\.exe).*test_cache.go' # not cached env CACHE=$OLD_GOCACHE -# Run same tests but with gccgo. -env GO111MODULE=off -[!exec:gccgo] stop -[cross] stop # gccgo can't necessarily cross-compile - -! go build -compiler=gccgo . -go build -compiler=gccgo -overlay overlay.json -o main_gccgo$GOEXE . -exec ./main_gccgo$goexe -stdout '^hello$' - -go build -compiler=gccgo -overlay overlay.json -o print_abspath_gccgo$GOEXE ./printpath -exec ./print_abspath_gccgo$GOEXE -stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]main.go - -go build -compiler=gccgo -overlay overlay.json -o print_trimpath_gccgo$GOEXE -trimpath ./printpath -exec ./print_trimpath_gccgo$GOEXE -stdout ^\.[/\\]printpath[/\\]main.go - - -go build -compiler=gccgo -overlay overlay.json -o main_cgo_replace_gccgo$GOEXE ./cgo_hello_replace -exec ./main_cgo_replace_gccgo$GOEXE -stdout '^hello cgo\r?\n' - -go build -compiler=gccgo -overlay overlay.json -o main_cgo_quote_gccgo$GOEXE ./cgo_hello_quote -exec ./main_cgo_quote_gccgo$GOEXE -stdout '^hello cgo\r?\n' - -go build -compiler=gccgo -overlay overlay.json -o main_cgo_angle_gccgo$GOEXE ./cgo_hello_angle -exec ./main_cgo_angle_gccgo$GOEXE -stdout '^hello cgo\r?\n' - -go build -compiler=gccgo -overlay overlay.json -o main_call_asm_gccgo$GOEXE ./call_asm -exec ./main_call_asm_gccgo$GOEXE -! stdout . - - -- m/go.mod -- // TODO(matloob): how do overlays work with go.mod (especially if mod=readonly) module m @@ -131,33 +77,9 @@ the actual code is in the overlay "printpath/other.go": "overlay2/printpath2.go", "call_asm/asm_gc.s": "overlay/asm_gc.s", "call_asm/asm_gccgo.s": "overlay/asm_gccgo.s", - "test_cache/main.go": "overlay/test_cache.go", - "cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h", - "cgo_hello_replace/hello.c": "overlay/hello.c", - "cgo_hello_quote/cgo_hello.go": "overlay/cgo_hello_quote.go", - "cgo_hello_quote/cgo_header.h": "overlay/cgo_head.h", - "cgo_hello_angle/cgo_hello.go": "overlay/cgo_hello_angle.go", - "cgo_hello_angle/cgo_header.h": "overlay/cgo_head.h" + "test_cache/main.go": "overlay/test_cache.go" } } --- m/cgo_hello_replace/cgo_hello_replace.go -- -package main - -// #include "cgo_header.h" -import "C" - -func main() { - C.say_hello() -} --- m/cgo_hello_replace/cgo_header.h -- - // Test that this header is replaced with one that has the proper declaration. -void say_goodbye(); - --- m/cgo_hello_replace/hello.c -- -#include - -void say_goodbye() { puts("goodbye cgo\n"); fflush(stdout); } - -- m/overlay/f.go -- package main @@ -220,30 +142,6 @@ import "m/dir" func printMessage() { dir.PrintMessage() } --- m/overlay/cgo_hello_quote.go -- -package main - -// #include "cgo_header.h" -import "C" - -func main() { - C.say_hello() -} --- m/overlay/cgo_hello_angle.go -- -package main - -// #include -import "C" - -func main() { - C.say_hello() -} --- m/overlay/cgo_head.h -- -void say_hello(); --- m/overlay/hello.c -- -#include - -void say_hello() { puts("hello cgo\n"); fflush(stdout); } -- m/overlay/asm_gc.s -- // +build gc @@ -274,42 +172,3 @@ import "fmt" func bar() { fmt.Println("different") } --- m/cgo_hello_quote/hello.c -- -#include - -void say_hello() { puts("hello cgo\n"); fflush(stdout); } --- m/cgo_hello_angle/hello.c -- -#include - -void say_hello() { puts("hello cgo\n"); fflush(stdout); } - --- print_line_comments.go -- -package main - -import ( - "fmt" - "io/ioutil" - "log" - "os" - "strings" -) - -func main() { - compiledGoFilesArg := os.Args[1] - b, err := ioutil.ReadFile(compiledGoFilesArg) - if err != nil { - log.Fatal(err) - } - compiledGoFiles := strings.Split(strings.TrimSpace(string(b)), "\n") - for _, f := range compiledGoFiles { - b, err := ioutil.ReadFile(f) - if err != nil { - log.Fatal(err) - } - for _, line := range strings.Split(string(b), "\n") { - if strings.HasPrefix(line, "#line") || strings.HasPrefix(line, "//line") { - fmt.Println(line) - } - } - } -} diff --git a/src/cmd/go/testdata/script/build_overlay_cgo.txt b/src/cmd/go/testdata/script/build_overlay_cgo.txt new file mode 100644 index 00000000000000..c5b6bf3bbf53ab --- /dev/null +++ b/src/cmd/go/testdata/script/build_overlay_cgo.txt @@ -0,0 +1,128 @@ +[short] skip +[!cgo] skip + +# Test building cgo packages in overlays. + +cd m + +go build -overlay overlay.json -o main_cgo_replace$GOEXE ./cgo_hello_replace +exec ./main_cgo_replace$GOEXE +stdout '^hello cgo\r?\n' + +go build -overlay overlay.json -o main_cgo_quote$GOEXE ./cgo_hello_quote +exec ./main_cgo_quote$GOEXE +stdout '^hello cgo\r?\n' + +go build -overlay overlay.json -o main_cgo_angle$GOEXE ./cgo_hello_angle +exec ./main_cgo_angle$GOEXE +stdout '^hello cgo\r?\n' + +go list -compiled -overlay overlay.json -f '{{range .CompiledGoFiles}}{{. | printf "%s\n"}}{{end}}' ./cgo_hello_replace +cp stdout compiled_cgo_sources.txt +go run ../print_line_comments.go compiled_cgo_sources.txt +stdout $GOPATH[/\\]src[/\\]m[/\\]cgo_hello_replace[/\\]cgo_hello_replace.go +! stdout $GOPATH[/\\]src[/\\]m[/\\]overlay[/\\]hello.c + +-- m/go.mod -- +// TODO(matloob): how do overlays work with go.mod (especially if mod=readonly) +module m + +go 1.16 + +-- m/overlay.json -- +{ + "Replace": { + "printpath/main.go": "overlay/printpath.go", + "printpath/other.go": "overlay2/printpath2.go", + "call_asm/asm_gc.s": "overlay/asm_gc.s", + "call_asm/asm_gccgo.s": "overlay/asm_gccgo.s", + "test_cache/main.go": "overlay/test_cache.go", + "cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h", + "cgo_hello_replace/hello.c": "overlay/hello.c", + "cgo_hello_quote/cgo_hello.go": "overlay/cgo_hello_quote.go", + "cgo_hello_quote/cgo_header.h": "overlay/cgo_head.h", + "cgo_hello_angle/cgo_hello.go": "overlay/cgo_hello_angle.go", + "cgo_hello_angle/cgo_header.h": "overlay/cgo_head.h" + } +} +-- m/cgo_hello_replace/cgo_hello_replace.go -- +package main + +// #include "cgo_header.h" +import "C" + +func main() { + C.say_hello() +} +-- m/cgo_hello_replace/cgo_header.h -- + // Test that this header is replaced with one that has the proper declaration. +void say_goodbye(); + +-- m/cgo_hello_replace/hello.c -- +#include + +void say_goodbye() { puts("goodbye cgo\n"); fflush(stdout); } + +-- m/overlay/cgo_hello_quote.go -- +package main + +// #include "cgo_header.h" +import "C" + +func main() { + C.say_hello() +} +-- m/overlay/cgo_hello_angle.go -- +package main + +// #include +import "C" + +func main() { + C.say_hello() +} +-- m/overlay/cgo_head.h -- +void say_hello(); +-- m/overlay/hello.c -- +#include + +void say_hello() { puts("hello cgo\n"); fflush(stdout); } +-- m/cgo_hello_quote/hello.c -- +#include + +void say_hello() { puts("hello cgo\n"); fflush(stdout); } +-- m/cgo_hello_angle/hello.c -- +#include + +void say_hello() { puts("hello cgo\n"); fflush(stdout); } + +-- print_line_comments.go -- +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "strings" +) + +func main() { + compiledGoFilesArg := os.Args[1] + b, err := ioutil.ReadFile(compiledGoFilesArg) + if err != nil { + log.Fatal(err) + } + compiledGoFiles := strings.Split(strings.TrimSpace(string(b)), "\n") + for _, f := range compiledGoFiles { + b, err := ioutil.ReadFile(f) + if err != nil { + log.Fatal(err) + } + for _, line := range strings.Split(string(b), "\n") { + if strings.HasPrefix(line, "#line") || strings.HasPrefix(line, "//line") { + fmt.Println(line) + } + } + } +} diff --git a/src/cmd/go/testdata/script/build_overlay_gccgo.txt b/src/cmd/go/testdata/script/build_overlay_gccgo.txt new file mode 100644 index 00000000000000..4cc0c49ac547a2 --- /dev/null +++ b/src/cmd/go/testdata/script/build_overlay_gccgo.txt @@ -0,0 +1,209 @@ +[short] skip +[!exec:gccgo] skip +[cross] skip # gccgo can't necessarily cross-compile + +# Test building in overlays with gccgo. +# TODO(#39958): add a test that both gc and gccgo assembly files can include .h +# files. + +# The main package (m) is contained in an overlay. It imports m/dir2 which has one +# file in an overlay and one file outside the overlay, which in turn imports m/dir, +# which only has source files in the overlay. + +env GO111MODULE=off + +cd m + +! go build -compiler=gccgo . +go build -compiler=gccgo -overlay overlay.json -o main_gccgo$GOEXE . +exec ./main_gccgo$goexe +stdout '^hello$' + +go build -compiler=gccgo -overlay overlay.json -o print_abspath_gccgo$GOEXE ./printpath +exec ./print_abspath_gccgo$GOEXE +stdout $WORK[/\\]gopath[/\\]src[/\\]m[/\\]printpath[/\\]main.go + +go build -compiler=gccgo -overlay overlay.json -o print_trimpath_gccgo$GOEXE -trimpath ./printpath +exec ./print_trimpath_gccgo$GOEXE +stdout ^\.[/\\]printpath[/\\]main.go + + +go build -compiler=gccgo -overlay overlay.json -o main_cgo_replace_gccgo$GOEXE ./cgo_hello_replace +exec ./main_cgo_replace_gccgo$GOEXE +stdout '^hello cgo\r?\n' + +go build -compiler=gccgo -overlay overlay.json -o main_cgo_quote_gccgo$GOEXE ./cgo_hello_quote +exec ./main_cgo_quote_gccgo$GOEXE +stdout '^hello cgo\r?\n' + +go build -compiler=gccgo -overlay overlay.json -o main_cgo_angle_gccgo$GOEXE ./cgo_hello_angle +exec ./main_cgo_angle_gccgo$GOEXE +stdout '^hello cgo\r?\n' + +go build -compiler=gccgo -overlay overlay.json -o main_call_asm_gccgo$GOEXE ./call_asm +exec ./main_call_asm_gccgo$GOEXE +! stdout . + +-- m/go.mod -- +// TODO(matloob): how do overlays work with go.mod (especially if mod=readonly) +module m + +go 1.16 + +-- m/dir2/h.go -- +package dir2 + +func PrintMessage() { + printMessage() +} +-- m/dir/foo.txt -- +The build action code currently expects the package directory +to exist, so it can run the compiler in that directory. +TODO(matloob): Remove this requirement. +-- m/printpath/about.txt -- +the actual code is in the overlay +-- m/overlay.json -- +{ + "Replace": { + "f.go": "overlay/f.go", + "dir/g.go": "overlay/dir_g.go", + "dir2/i.go": "overlay/dir2_i.go", + "printpath/main.go": "overlay/printpath.go", + "printpath/other.go": "overlay2/printpath2.go", + "call_asm/asm_gc.s": "overlay/asm_gc.s", + "call_asm/asm_gccgo.s": "overlay/asm_gccgo.s", + "test_cache/main.go": "overlay/test_cache.go", + "cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h", + "cgo_hello_replace/hello.c": "overlay/hello.c", + "cgo_hello_quote/cgo_hello.go": "overlay/cgo_hello_quote.go", + "cgo_hello_quote/cgo_header.h": "overlay/cgo_head.h", + "cgo_hello_angle/cgo_hello.go": "overlay/cgo_hello_angle.go", + "cgo_hello_angle/cgo_header.h": "overlay/cgo_head.h" + } +} +-- m/cgo_hello_replace/cgo_hello_replace.go -- +package main + +// #include "cgo_header.h" +import "C" + +func main() { + C.say_hello() +} +-- m/cgo_hello_replace/cgo_header.h -- + // Test that this header is replaced with one that has the proper declaration. +void say_goodbye(); + +-- m/cgo_hello_replace/hello.c -- +#include + +void say_goodbye() { puts("goodbye cgo\n"); fflush(stdout); } + +-- m/overlay/f.go -- +package main + +import "m/dir2" + +func main() { + dir2.PrintMessage() +} +-- m/call_asm/main.go -- +package main + +func foo() // There will be a "missing function body" error if the assembly file isn't found. + +func main() { + foo() +} +-- m/overlay/dir_g.go -- +package dir + +import "fmt" + +func PrintMessage() { + fmt.Println("hello") +} +-- m/overlay/printpath.go -- +package main + +import ( + "fmt" + "path/filepath" + "runtime" +) + +func main() { + _, file, _, _ := runtime.Caller(0) + + // Since https://golang.org/cl/214286, the runtime's debug paths are + // slash-separated regardless of platform, so normalize them to system file + // paths. + fmt.Println(filepath.FromSlash(file)) +} +-- m/overlay2/printpath2.go -- +package main + +import ( + "fmt" + "path/filepath" + "runtime" +) + +func init() { + _, file, _, _ := runtime.Caller(0) + fmt.Println(filepath.FromSlash(file)) +} +-- m/overlay/dir2_i.go -- +package dir2 + +import "m/dir" + +func printMessage() { + dir.PrintMessage() +} +-- m/overlay/cgo_hello_quote.go -- +package main + +// #include "cgo_header.h" +import "C" + +func main() { + C.say_hello() +} +-- m/overlay/cgo_hello_angle.go -- +package main + +// #include +import "C" + +func main() { + C.say_hello() +} +-- m/overlay/cgo_head.h -- +void say_hello(); +-- m/overlay/hello.c -- +#include + +void say_hello() { puts("hello cgo\n"); fflush(stdout); } +-- m/overlay/asm_gc.s -- +// +build gc + +TEXT ·foo(SB),0,$0 + RET + +-- m/overlay/asm_gccgo.s -- +// +build gccgo + +.globl main.foo +.text +main.foo: + ret + +-- m/cgo_hello_quote/hello.c -- +#include + +void say_hello() { puts("hello cgo\n"); fflush(stdout); } +-- m/cgo_hello_angle/hello.c -- +#include + +void say_hello() { puts("hello cgo\n"); fflush(stdout); } diff --git a/src/cmd/go/testdata/script/test_vet.txt b/src/cmd/go/testdata/script/test_vet.txt index 6151f912ae0db1..5af26b54f9141b 100644 --- a/src/cmd/go/testdata/script/test_vet.txt +++ b/src/cmd/go/testdata/script/test_vet.txt @@ -16,22 +16,6 @@ go test -vet=off p1.go ! stderr '[\\/]vet.*-shift' stdout '\[no test files\]' -# ensure all runs non-default vet -! go test -vet=all ./vetall/... -stderr 'using resp before checking for errors' - -# Test issue #47309 -! go test -vet=bools,xyz ./vetall/... -stderr '-vet argument must be a supported analyzer' - -# Test with a single analyzer -! go test -vet=httpresponse ./vetall/... -stderr 'using resp before checking for errors' - -# Test with a list of analyzers -go test -vet=atomic,bools,nilfunc ./vetall/... -stdout 'm/vetall.*\[no tests to run\]' - # Test issue #22890 go test m/vetcycle stdout 'm/vetcycle.*\[no test files\]' @@ -67,21 +51,6 @@ import "fmt" func F() { fmt.Printf("%d") // oops } --- vetall/p.go -- -package p - -import "net/http" - -func F() { - resp, err := http.Head("example.com") - defer resp.Body.Close() - if err != nil { - panic(err) - } - // (defer statement belongs here) -} --- vetall/p_test.go -- -package p -- vetcycle/p.go -- package p diff --git a/src/cmd/go/testdata/script/test_vet_vetall.txt b/src/cmd/go/testdata/script/test_vet_vetall.txt new file mode 100644 index 00000000000000..6f7b6657337968 --- /dev/null +++ b/src/cmd/go/testdata/script/test_vet_vetall.txt @@ -0,0 +1,37 @@ +[short] skip + +# ensure all runs non-default vet +! go test -vet=all ./vetall/... +stderr 'using resp before checking for errors' + +# Test issue #47309 +! go test -vet=bools,xyz ./vetall/... +stderr '-vet argument must be a supported analyzer' + +# Test with a single analyzer +! go test -vet=httpresponse ./vetall/... +stderr 'using resp before checking for errors' + +# Test with a list of analyzers +go test -vet=atomic,bools,nilfunc ./vetall/... +stdout 'm/vetall.*\[no tests to run\]' + +-- go.mod -- +module m + +go 1.16 +-- vetall/p.go -- +package p + +import "net/http" + +func F() { + resp, err := http.Head("example.com") + defer resp.Body.Close() + if err != nil { + panic(err) + } + // (defer statement belongs here) +} +-- vetall/p_test.go -- +package p diff --git a/src/crypto/internal/cryptotest/wycheproof/_schema/go.mod b/src/crypto/internal/cryptotest/wycheproof/_schema/go.mod index 1253c1c5a94eb1..d7c20ce6f6d307 100644 --- a/src/crypto/internal/cryptotest/wycheproof/_schema/go.mod +++ b/src/crypto/internal/cryptotest/wycheproof/_schema/go.mod @@ -4,7 +4,7 @@ go 1.26.4 require ( github.com/atombender/go-jsonschema v0.23.1 - github.com/c2sp/wycheproof v0.0.0-20260606153636-6d7cccd0fcb1 + github.com/c2sp/wycheproof v0.0.0-20260625212325-ee7b4f7e6119 ) require ( diff --git a/src/crypto/internal/cryptotest/wycheproof/_schema/go.sum b/src/crypto/internal/cryptotest/wycheproof/_schema/go.sum index bc5fe4eb9e0b96..5ad2f74b721e16 100644 --- a/src/crypto/internal/cryptotest/wycheproof/_schema/go.sum +++ b/src/crypto/internal/cryptotest/wycheproof/_schema/go.sum @@ -1,7 +1,7 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= -github.com/c2sp/wycheproof v0.0.0-20260606153636-6d7cccd0fcb1 h1:veaGluF2y7kZnV/owZzY3FuOZWZQdzqnIcJsbJpFV7A= -github.com/c2sp/wycheproof v0.0.0-20260606153636-6d7cccd0fcb1/go.mod h1:/5JsOpi3fKmnnig5BQ2mz49TNtnrD308VfTVHcbr5x4= +github.com/c2sp/wycheproof v0.0.0-20260625212325-ee7b4f7e6119 h1:jOCu6erj86P93+eFn8Qxp6XLwftn1nW0C9RUx7xZwZg= +github.com/c2sp/wycheproof v0.0.0-20260625212325-ee7b4f7e6119/go.mod h1:/5JsOpi3fKmnnig5BQ2mz49TNtnrD308VfTVHcbr5x4= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/src/crypto/internal/cryptotest/wycheproof/schema.go b/src/crypto/internal/cryptotest/wycheproof/schema.go index 50c655f6fe032e..06939c82bb63c8 100644 --- a/src/crypto/internal/cryptotest/wycheproof/schema.go +++ b/src/crypto/internal/cryptotest/wycheproof/schema.go @@ -4980,6 +4980,10 @@ func (j *MLKEMDecapsTestGroupParameterSet) UnmarshalJSON(value []byte) error { } type MLKEMDecapsTestGroupTestsElem struct { + // If present, the shared key the implementation MUST return on a successful + // Decapsulate call. + K *string `json:"K,omitempty,omitzero"` + // An input ciphertext C string `json:"c"` @@ -4989,6 +4993,9 @@ type MLKEMDecapsTestGroupTestsElem struct { // The full decapsulation key Dk string `json:"dk"` + // The encapsulation key bytes of dk. + Ek string `json:"ek"` + // A list of flags Flags []string `json:"flags"` @@ -5011,6 +5018,9 @@ func (j *MLKEMDecapsTestGroupTestsElem) UnmarshalJSON(value []byte) error { if _, ok := raw["dk"]; raw != nil && !ok { return fmt.Errorf("field dk in MLKEMDecapsTestGroupTestsElem: required") } + if _, ok := raw["ek"]; raw != nil && !ok { + return fmt.Errorf("field ek in MLKEMDecapsTestGroupTestsElem: required") + } if _, ok := raw["flags"]; raw != nil && !ok { return fmt.Errorf("field flags in MLKEMDecapsTestGroupTestsElem: required") } diff --git a/src/crypto/internal/cryptotest/wycheproof/schemaversion.go b/src/crypto/internal/cryptotest/wycheproof/schemaversion.go index 642266db1f454f..9a837a27f6dbdc 100644 --- a/src/crypto/internal/cryptotest/wycheproof/schemaversion.go +++ b/src/crypto/internal/cryptotest/wycheproof/schemaversion.go @@ -8,4 +8,4 @@ package wycheproof // wycheproofVersion is the github.com/c2sp/wycheproof module version that // schema.go was generated against. -const wycheproofVersion = "v0.0.0-20260606153636-6d7cccd0fcb1" +const wycheproofVersion = "v0.0.0-20260625212325-ee7b4f7e6119" diff --git a/src/crypto/mlkem/mlkem_wycheproof_test.go b/src/crypto/mlkem/mlkem_wycheproof_test.go index 1188437ce78fbd..c5162525b37c77 100644 --- a/src/crypto/mlkem/mlkem_wycheproof_test.go +++ b/src/crypto/mlkem/mlkem_wycheproof_test.go @@ -356,6 +356,9 @@ func runSemiExpandedDecapsTest(t *testing.T, paramSet wycheproof.MLKEMDecapsTest if !bytes.Equal(mlkem.TestingOnlyExpandedBytes768(dk), dkBytes) { t.Errorf("expanded decapsulation key roundtrip mismatch") } + if want := wycheproof.MustDecodeHex(tv.Ek); !bytes.Equal(dk.EncapsulationKey().Bytes(), want) { + t.Errorf("encapsulation key mismatch:\n got: %x\nwant: %x", dk.EncapsulationKey().Bytes(), want) + } k, err := dk.Decapsulate(ciphertext) if err != nil { if shouldPass { @@ -367,16 +370,11 @@ func runSemiExpandedDecapsTest(t *testing.T, paramSet wycheproof.MLKEMDecapsTest t.Errorf("Decapsulate unexpectedly succeeded") return } - if len(k) != SharedKeySize { - t.Errorf("shared key has wrong length: got %d, want %d", len(k), SharedKeySize) - } - kFresh, cFresh := dk.EncapsulationKey().Encapsulate() - kRT, err := dk.Decapsulate(cFresh) - if err != nil { - t.Fatalf("Decapsulate of fresh ciphertext: %v", err) + if tv.K == nil { + t.Fatalf("Decapsulate succeeded but test vector has no expected K") } - if !bytes.Equal(kFresh, kRT) { - t.Errorf("encaps/decaps roundtrip key mismatch") + if want := wycheproof.MustDecodeHex(*tv.K); !bytes.Equal(k, want) { + t.Errorf("shared key mismatch:\n got: %x\nwant: %x", k, want) } case wycheproof.MLKEMDecapsTestGroupParameterSetMLKEM1024: @@ -390,6 +388,9 @@ func runSemiExpandedDecapsTest(t *testing.T, paramSet wycheproof.MLKEMDecapsTest if !bytes.Equal(mlkem.TestingOnlyExpandedBytes1024(dk), dkBytes) { t.Errorf("expanded decapsulation key roundtrip mismatch") } + if want := wycheproof.MustDecodeHex(tv.Ek); !bytes.Equal(dk.EncapsulationKey().Bytes(), want) { + t.Errorf("encapsulation key mismatch:\n got: %x\nwant: %x", dk.EncapsulationKey().Bytes(), want) + } k, err := dk.Decapsulate(ciphertext) if err != nil { if shouldPass { @@ -401,16 +402,11 @@ func runSemiExpandedDecapsTest(t *testing.T, paramSet wycheproof.MLKEMDecapsTest t.Errorf("Decapsulate unexpectedly succeeded") return } - if len(k) != SharedKeySize { - t.Errorf("shared key has wrong length: got %d, want %d", len(k), SharedKeySize) - } - kFresh, cFresh := dk.EncapsulationKey().Encapsulate() - kRT, err := dk.Decapsulate(cFresh) - if err != nil { - t.Fatalf("Decapsulate of fresh ciphertext: %v", err) + if tv.K == nil { + t.Fatalf("Decapsulate succeeded but test vector has no expected K") } - if !bytes.Equal(kFresh, kRT) { - t.Errorf("encaps/decaps roundtrip key mismatch") + if want := wycheproof.MustDecodeHex(*tv.K); !bytes.Equal(k, want) { + t.Errorf("shared key mismatch:\n got: %x\nwant: %x", k, want) } default: