// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/web_package/signed_web_bundles/ed25519_signature.h" #include <vector> #include "base/containers/span.h" #include "base/ranges/algorithm.h" #include "base/test/gmock_expected_support.h" #include "testing/gtest/include/gtest/gtest.h" namespace web_package { namespace { constexpr uint8_t kMessage[] = …; constexpr uint8_t kOtherMessage[] = …; // Signature and public key were generated with the following Go script: // // package main // // import ( // "crypto/ed25519" // "fmt" // "strings" // ) // // func printHex(data []byte) string { // var result strings.Builder // for i, byte := range data { // if i > 0 { // result.WriteString(", ") // } // fmt.Fprintf(&result, "0x%02x", byte) // } // return result.String() // } // // func main() { // public_key, private_key, _ := ed25519.GenerateKey(nil) // fmt.Print("Public Key: ") // fmt.Println(printHex(public_key)) // fmt.Print("Signature: ") // fmt.Println(printHex(ed25519.Sign(private_key, []byte("test message")))) // } constexpr uint8_t kPublicKey[] = …; constexpr uint8_t kSignature[] = …; // This is a different signature with the first byte changed to 0xFF. constexpr uint8_t kOtherSignature[] = …; } // namespace TEST(Ed25519SignatureTest, ValidSignatureFromVector) { … } TEST(Ed25519SignatureTest, ValidSignatureFromArray) { … } TEST(Ed25519SignatureTest, Equality) { … } TEST(Ed25519SignatureTest, InvalidSignature) { … } TEST(Ed25519SignatureTest, Verify) { … } } // namespace web_package