Skip to content

Commit 5cab358

Browse files
committed
win_test.go: add TestWinRSA, add RSA private key for test.
1 parent 2aafb88 commit 5cab358

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

wincrypto/testdata/privatekey.keyx

1.14 KB
Binary file not shown.

wincrypto/testdata/privatekey.sign

1.14 KB
Binary file not shown.

wincrypto/win_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package wincrypto
22

33
import (
4+
"crypto"
5+
"crypto/rand"
6+
"crypto/rsa"
7+
"crypto/sha256"
8+
"os"
49
"testing"
510

611
"github.com/davecgh/go-spew/spew"
@@ -44,7 +49,20 @@ func TestWinAES(t *testing.T) {
4449

4550
func TestWinRSA(t *testing.T) {
4651
t.Run("sign", func(t *testing.T) {
52+
key, err := os.ReadFile("testdata/privatekey.sign")
53+
require.NoError(t, err)
54+
55+
privateKey, err := ImportRSAPrivateKeyBlob(key)
56+
require.NoError(t, err)
57+
58+
message := []byte{1, 2, 3, 4}
59+
digest := sha256.Sum256(message)
4760

61+
signature, err := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, digest[:])
62+
require.NoError(t, err)
63+
64+
// this output will move to the test of Gleam-RT
65+
spew.Dump(signature)
4866
})
4967

5068
t.Run("verify", func(t *testing.T) {

0 commit comments

Comments
 (0)