| 1 |
// Copyright 2024 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package fipstest |
| 6 |
|
| 7 |
import ( |
| 8 |
"crypto/internal/cryptotest" |
| 9 |
. "crypto/internal/fips140/edwards25519" |
| 10 |
"testing" |
| 11 |
) |
| 12 |
|
| 13 |
var testAllocationsSink byte |
| 14 |
|
| 15 |
func TestEdwards25519Allocations(t *testing.T) { |
| 16 |
cryptotest.SkipTestAllocations(t) |
| 17 |
if allocs := testing.AllocsPerRun(100, func() { |
| 18 |
p := NewIdentityPoint() |
| 19 |
p.Add(p, NewGeneratorPoint()) |
| 20 |
s := NewScalar() |
| 21 |
testAllocationsSink ^= s.Bytes()[0] |
| 22 |
testAllocationsSink ^= p.Bytes()[0] |
| 23 |
}); allocs > 0 { |
| 24 |
t.Errorf("expected zero allocations, got %0.1v", allocs) |
| 25 |
} |
| 26 |
} |