Skip to content

Commit 2aafb88

Browse files
committed
win_test.go: add TestWinAES and TestWinRSA, finish TestWinAES.
1 parent a152019 commit 2aafb88

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

wincrypto/win_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
11
package wincrypto
2+
3+
import (
4+
"testing"
5+
6+
"github.com/davecgh/go-spew/spew"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestWinAES(t *testing.T) {
11+
t.Run("encrypt", func(t *testing.T) {
12+
data := []byte{1, 2, 3, 4}
13+
key := []byte{
14+
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,
15+
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,
16+
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,
17+
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,
18+
}
19+
output, err := AESEncrypt(data, key)
20+
require.NoError(t, err)
21+
22+
// this output will move to the test of Gleam-RT
23+
spew.Dump(output)
24+
})
25+
26+
t.Run("decrypt", func(t *testing.T) {
27+
data := []byte{
28+
0x49, 0x8E, 0xD4, 0x85, 0x40, 0x12, 0x18, 0x74,
29+
0xDB, 0x3D, 0x2E, 0xEB, 0xA2, 0x10, 0xED, 0x9D,
30+
0xE9, 0xFB, 0xDF, 0x90, 0xA6, 0xB4, 0x39, 0x4A,
31+
0xA3, 0x62, 0xE0, 0x86, 0x1F, 0x94, 0xF7, 0xD5,
32+
}
33+
key := []byte{
34+
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,
35+
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03,
36+
}
37+
output, err := AESDecrypt(data, key)
38+
require.NoError(t, err)
39+
40+
expected := []byte{1, 2, 3, 4}
41+
require.Equal(t, expected, output)
42+
})
43+
}
44+
45+
func TestWinRSA(t *testing.T) {
46+
t.Run("sign", func(t *testing.T) {
47+
48+
})
49+
50+
t.Run("verify", func(t *testing.T) {
51+
52+
})
53+
54+
t.Run("encrypt", func(t *testing.T) {
55+
56+
})
57+
58+
t.Run("decrypt", func(t *testing.T) {
59+
60+
})
61+
}

0 commit comments

Comments
 (0)