Blame SOURCES/remove_ed25519vectors_test.patch

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