-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpadding_test.go
47 lines (39 loc) · 995 Bytes
/
padding_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package rome_test
import (
"testing"
"github.com/go-compile/rome"
"github.com/go-compile/rome/ed25519"
)
func TestPadding(t *testing.T) {
for i := 0; i <= 100; i++ {
buf := make([]byte, i)
if len(rome.Pad(buf, 100)) != 100 {
t.Fatal("length of padded output not 100")
}
}
}
func TestKeyPaddingP521(t *testing.T) {
for i := 1; i <= 500; i++ {
k, err := generate()
if err != nil {
t.Fatal(err)
}
if len(k.PrivateRaw()) != k.Public().Size() {
t.Fatal("private key returned in wrong size compared with curve's stated size")
}
}
}
func TestKeyPaddingEd25519(t *testing.T) {
for i := 1; i <= 500; i++ {
k, err := ed25519.Generate()
if err != nil {
t.Fatal(err)
}
if actual := len(k.PrivateRaw()); actual != k.Public().Size() {
t.Fatalf("private key: %d, expected: %d", actual, k.Public().Size())
}
if actual := len(k.PublicRaw()); actual != k.Public().Size() {
t.Fatalf("private key: %d, expected: %d", actual, k.Public().Size())
}
}
}