-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_test.go
57 lines (45 loc) · 1.23 KB
/
key_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
48
49
50
51
52
53
54
55
56
57
// SPDX-FileCopyrightText: 2023-2024 Steffen Vogel <[email protected]>
// SPDX-License-Identifier: Apache-2.0
package openpgp_test
import (
"testing"
"github.com/stretchr/testify/require"
opc "cunicu.li/go-openpgp-card"
)
func TestGenerateKey(t *testing.T) {
t.Run("RSA", testGenerateKeyRSA)
t.Run("ECDSA", testGenerateKeyECDSA)
t.Run("ECDH", testGenerateKeyECDH)
t.Run("EdDSA", testGenerateKeyEdDSA)
}
func TestImportKey(t *testing.T) {
t.Run("RSA", testImportKeyRSA)
t.Run("ECDSA", testImportKeyECDSA)
t.Run("ECDH", testImportKeyECDH)
t.Run("EdDSA", testImportKeyEdDSA)
}
func TestSign(t *testing.T) {
t.Run("RSA", testSignRSA)
t.Run("ECDSA", testSignECDSA)
t.Run("EdDSA", testSignEdDSA)
}
func TestSupportedAlgorithms(t *testing.T) {
withCard(t, false, func(t *testing.T, c *opc.Card) {
require := require.New(t)
asByKey, err := c.SupportedAlgorithms()
require.NoError(err)
for key, as := range asByKey {
for _, a := range as {
t.Logf("%s %s %#x", key, a, a.ImportFormat)
}
}
})
}
func TestAlgorithmAttributes(t *testing.T) {
withCard(t, false, func(t *testing.T, c *opc.Card) {
require := require.New(t)
attrs, err := c.AlgorithmAttributes(opc.KeySign)
require.NoError(err)
t.Log(attrs)
})
}