12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- // Copyright 2021 Jeffrey H. Johnson <trnsz@pobox.com>.
- // Copyright 2021 Gridfinity, LLC.
- // Copyright 2020 Frank Denis <j at pureftpd dot org>.
- // Copyright 2012 The Go Authors.
- //
- // All rights reserved.
- //
- // Use of this source code is governed by the BSD-style
- // license that can be found in the LICENSE file.
- package goc25519sm
- import (
- "fmt"
- "os"
- "testing"
- u "github.com/johnsonjh/leaktestfe"
- )
- func TestMain(m *testing.M) {
- CorruptBasepointTest = true
- exitVal := m.Run()
- os.Exit(
- exitVal,
- )
- }
- func TestOldScalarMultVerifyFailure(
- t *testing.T,
- ) {
- defer u.Leakplug(
- t,
- )
- var dst, scalar, point [X25519Size]byte
- copy(dst[:], ExamplePointB[:])
- copy(scalar[:], ExamplePointA[:])
- copy(point[:], ExamplePointB[:])
- err := oldScalarMultVerify(&dst, &scalar, &point)
- if err != nil {
- t.Fatal(
- fmt.Sprintf(
- "\ngoc25519sm_verify_test.TestOldScalarMultVerifyFailure.oldScalarMultVerify FAILURE:\n dst=%v\n scalar=%v\n point=%v\n %v",
- dst,
- scalar,
- point,
- err,
- ),
- )
- }
- }
- func TestOldScalarMultVerifyLowFailure(
- t *testing.T,
- ) {
- defer u.Leakplug(
- t,
- )
- var dst, scalar, point [X25519Size]byte
- copy(scalar[:], ExamplePointA[:])
- copy(point[:], ExamplePointB[:])
- err := oldScalarMultVerify(&dst, &scalar, &point)
- if err == nil {
- t.Fatal(
- fmt.Sprintf(
- "\ngoc25519sm_verify_test.TestOldScalarMultVerifyLowFailure.oldScalarMultVerify FAILURE:\n dst=%v\n scalar=%v\n point=%v\n %v",
- dst,
- scalar,
- point,
- err,
- ),
- )
- }
- }
- func TestInitCorruptBasepointTestFailure(
- t *testing.T,
- ) {
- defer u.Leakplug(
- t,
- )
- if !CorruptBasepointTest {
- t.Fatal(
- "\ngoc25519sm_verify_test.TestInitFailure FAILURE:\n CorruptBasepointTest unset",
- )
- }
- }
|