Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p-quic-transport
Commits
114b599c
Commit
114b599c
authored
Jul 13, 2018
by
dignifiedquire
Browse files
start implementing more key support
parent
4ab984ad
Changes
2
Show whitespace changes
Inline
Side-by-side
crypto.go
View file @
114b599c
...
...
@@ -102,7 +102,13 @@ func keyToCertificate(sk ic.PrivKey) (interface{}, *x509.Certificate, error) {
}
publicKey
=
&
k
.
PublicKey
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
:
return
nil
,
nil
,
errors
.
New
(
"unsupported key type for TLS"
)
}
...
...
crypto_test.go
0 → 100644
View file @
114b599c
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
())
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment