mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 20:56:18 +08:00
internal/sm2ec: make SetBytes constant time, use latest golang features #309
This commit is contained in:
parent
5ade794e6b
commit
759bb4c0b9
@ -2,13 +2,18 @@ package subtle
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand/v2"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/emmansun/gmsm/internal/byteorder"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConstantTimeLessOrEqBytes(t *testing.T) {
|
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++ {
|
for l := 0; l < 20; l++ {
|
||||||
a := make([]byte, l)
|
a := make([]byte, l)
|
||||||
b := make([]byte, l)
|
b := make([]byte, l)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user