Skip to content

Commit 1207888

Browse files
committed
rsa_test.go: add TestImportRSAPublicKeyBlob and TestImportRSAPrivateKeyBlob.
1 parent 4f86bad commit 1207888

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

wincrypto/rsa_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"crypto/rsa"
77
"crypto/x509"
88
"encoding/pem"
9+
"os"
910
"testing"
1011

1112
"github.com/davecgh/go-spew/spew"
@@ -116,6 +117,28 @@ func TestParseRSAPrivateKey(t *testing.T) {
116117
})
117118
}
118119

120+
func TestImportRSAPublicKeyBlob(t *testing.T) {
121+
t.Run("common", func(t *testing.T) {
122+
key, err := os.ReadFile("testdata/public.key")
123+
require.NoError(t, err)
124+
125+
publicKey, err := ImportRSAPublicKeyBlob(key)
126+
require.NoError(t, err)
127+
require.NotNil(t, publicKey)
128+
})
129+
}
130+
131+
func TestImportRSAPrivateKeyBlob(t *testing.T) {
132+
t.Run("common", func(t *testing.T) {
133+
key, err := os.ReadFile("testdata/private.key")
134+
require.NoError(t, err)
135+
136+
privateKey, err := ImportRSAPrivateKeyBlob(key)
137+
require.NoError(t, err)
138+
require.NotNil(t, privateKey)
139+
})
140+
}
141+
119142
func TestExportRSAPublicKeyBlob(t *testing.T) {
120143
key, err := rsa.GenerateKey(rand.Reader, 2048)
121144
require.NoError(t, err)

wincrypto/testdata/private.key

1.14 KB
Binary file not shown.

wincrypto/testdata/public.key

276 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)