Commit 114b599c authored by dignifiedquire's avatar dignifiedquire
Browse files

start implementing more key support

parent 4ab984ad
...@@ -102,7 +102,13 @@ func keyToCertificate(sk ic.PrivKey) (interface{}, *x509.Certificate, error) { ...@@ -102,7 +102,13 @@ func keyToCertificate(sk ic.PrivKey) (interface{}, *x509.Certificate, error) {
} }
publicKey = &k.PublicKey publicKey = &k.PublicKey
privateKey = k privateKey = k
// TODO: add support for ECDSA case pb.KeyType_Ed25519:
k, err := x509.ParsePKCS1PrivateKey(pbmes.GetData())
if err != nil {
return nil, nil, err
}
publicKey = &k.PublicKey
privateKey = k
default: default:
return nil, nil, errors.New("unsupported key type for TLS") return nil, nil, errors.New("unsupported key type for TLS")
} }
......
package libp2pquic
import (
"crypto/rand"
ic "github.com/libp2p/go-libp2p-crypto"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Crypto", func() {
var (
serverKey, clientKey ic.PrivKey
serverID, clientID peer.ID
)
Describe("keyToCertificate", func() {
It("Ed25519", func() {
priv, _, err := ic.GenerateEd25519Key(rand.Reader)
Expect(err).ToNot(HaveOccurred())
key, cert, err := keyToCertificate(priv)
Expect(err).ToNot(HaveOccurred())
})
})
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment