internal/sm2ec: make SetBytes constant time, use latest golang features #309

This commit is contained in:
Sun Yimin 2025-03-04 11:30:20 +08:00 committed by GitHub
parent 5ade794e6b
commit 759bb4c0b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,13 +2,18 @@ package subtle
import (
"bytes"
"crypto/rand"
"fmt"
"math/rand/v2"
"testing"
"time"
"github.com/emmansun/gmsm/internal/byteorder"
)
func TestConstantTimeLessOrEqBytes(t *testing.T) {
r := rand.Reader
seed := make([]byte, 32)
byteorder.BEPutUint64(seed, uint64(time.Now().UnixNano()))
r := rand.NewChaCha8([32]byte(seed))
for l := 0; l < 20; l++ {
a := make([]byte, l)
b := make([]byte, l)