Blame SOURCES/remove_ed25519vectors_test.patch

555bc4
From d7cad65ab9179804e9f089ce97bc124e9ef79494 Mon Sep 17 00:00:00 2001
555bc4
From: =?UTF-8?q?Alejandro=20S=C3=A1ez?= <asm@redhat.com>
555bc4
Date: Wed, 15 Dec 2021 16:02:15 +0100
555bc4
Subject: [PATCH] Remove ed25519vectors_test.go
555bc4
555bc4
---
555bc4
 src/crypto/ed25519/ed25519vectors_test.go | 109 ----------------------
555bc4
 1 file changed, 109 deletions(-)
555bc4
 delete mode 100644 src/crypto/ed25519/ed25519vectors_test.go
555bc4
555bc4
diff --git a/src/crypto/ed25519/ed25519vectors_test.go b/src/crypto/ed25519/ed25519vectors_test.go
555bc4
deleted file mode 100644
555bc4
index 74fcdcdf4e..0000000000
555bc4
--- a/src/crypto/ed25519/ed25519vectors_test.go
555bc4
+++ /dev/null
555bc4
@@ -1,109 +0,0 @@
555bc4
-// Copyright 2021 The Go Authors. All rights reserved.
555bc4
-// Use of this source code is governed by a BSD-style
555bc4
-// license that can be found in the LICENSE file.
555bc4
-
555bc4
-package ed25519_test
555bc4
-
555bc4
-import (
555bc4
-	"crypto/ed25519"
555bc4
-	"encoding/hex"
555bc4
-	"encoding/json"
555bc4
-	"internal/testenv"
555bc4
-	"os"
555bc4
-	"os/exec"
555bc4
-	"path/filepath"
555bc4
-	"testing"
555bc4
-)
555bc4
-
555bc4
-// TestEd25519Vectors runs a very large set of test vectors that exercise all
555bc4
-// combinations of low-order points, low-order components, and non-canonical
555bc4
-// encodings. These vectors lock in unspecified and spec-divergent behaviors in
555bc4
-// edge cases that are not security relevant in most contexts, but that can
555bc4
-// cause issues in consensus applications if changed.
555bc4
-//
555bc4
-// Our behavior matches the "classic" unwritten verification rules of the
555bc4
-// "ref10" reference implementation.
555bc4
-//
555bc4
-// Note that although we test for these edge cases, they are not covered by the
555bc4
-// Go 1 Compatibility Promise. Applications that need stable verification rules
555bc4
-// should use github.com/hdevalence/ed25519consensus.
555bc4
-//
555bc4
-// See https://hdevalence.ca/blog/2020-10-04-its-25519am for more details.
555bc4
-func TestEd25519Vectors(t *testing.T) {
555bc4
-	jsonVectors := downloadEd25519Vectors(t)
555bc4
-	var vectors []struct {
555bc4
-		A, R, S, M string
555bc4
-		Flags      []string
555bc4
-	}
555bc4
-	if err := json.Unmarshal(jsonVectors, &vectors); err != nil {
555bc4
-		t.Fatal(err)
555bc4
-	}
555bc4
-	for i, v := range vectors {
555bc4
-		expectedToVerify := true
555bc4
-		for _, f := range v.Flags {
555bc4
-			switch f {
555bc4
-			// We use the simplified verification formula that doesn't multiply
555bc4
-			// by the cofactor, so any low order residue will cause the
555bc4
-			// signature not to verify.
555bc4
-			//
555bc4
-			// This is allowed, but not required, by RFC 8032.
555bc4
-			case "LowOrderResidue":
555bc4
-				expectedToVerify = false
555bc4
-			// Our point decoding allows non-canonical encodings (in violation
555bc4
-			// of RFC 8032) but R is not decoded: instead, R is recomputed and
555bc4
-			// compared bytewise against the canonical encoding.
555bc4
-			case "NonCanonicalR":
555bc4
-				expectedToVerify = false
555bc4
-			}
555bc4
-		}
555bc4
-
555bc4
-		publicKey := decodeHex(t, v.A)
555bc4
-		signature := append(decodeHex(t, v.R), decodeHex(t, v.S)...)
555bc4
-		message := []byte(v.M)
555bc4
-
555bc4
-		didVerify := ed25519.Verify(publicKey, message, signature)
555bc4
-		if didVerify && !expectedToVerify {
555bc4
-			t.Errorf("#%d: vector with flags %s unexpectedly verified", i, v.Flags)
555bc4
-		}
555bc4
-		if !didVerify && expectedToVerify {
555bc4
-			t.Errorf("#%d: vector with flags %s unexpectedly rejected", i, v.Flags)
555bc4
-		}
555bc4
-	}
555bc4
-}
555bc4
-
555bc4
-func downloadEd25519Vectors(t *testing.T) []byte {
555bc4
-	testenv.MustHaveExternalNetwork(t)
555bc4
-
555bc4
-	// Download the JSON test file from the GOPROXY with `go mod download`,
555bc4
-	// pinning the version so test and module caching works as expected.
555bc4
-	goTool := testenv.GoToolPath(t)
555bc4
-	path := "filippo.io/mostly-harmless/ed25519vectors@v0.0.0-20210322192420-30a2d7243a94"
555bc4
-	cmd := exec.Command(goTool, "mod", "download", "-json", path)
555bc4
-	// TODO: enable the sumdb once the TryBots proxy supports it.
555bc4
-	cmd.Env = append(os.Environ(), "GONOSUMDB=*")
555bc4
-	output, err := cmd.Output()
555bc4
-	if err != nil {
555bc4
-		t.Fatalf("failed to run `go mod download -json %s`, output: %s", path, output)
555bc4
-	}
555bc4
-	var dm struct {
555bc4
-		Dir string // absolute path to cached source root directory
555bc4
-	}
555bc4
-	if err := json.Unmarshal(output, &dm;; err != nil {
555bc4
-		t.Fatal(err)
555bc4
-	}
555bc4
-
555bc4
-	jsonVectors, err := os.ReadFile(filepath.Join(dm.Dir, "ed25519vectors.json"))
555bc4
-	if err != nil {
555bc4
-		t.Fatalf("failed to read ed25519vectors.json: %v", err)
555bc4
-	}
555bc4
-	return jsonVectors
555bc4
-}
555bc4
-
555bc4
-func decodeHex(t *testing.T, s string) []byte {
555bc4
-	t.Helper()
555bc4
-	b, err := hex.DecodeString(s)
555bc4
-	if err != nil {
555bc4
-		t.Errorf("invalid hex: %v", err)
555bc4
-	}
555bc4
-	return b
555bc4
-}
555bc4
-- 
555bc4
2.33.1
555bc4