Commit e3a9a11a authored by Brian Tiger Chow's avatar Brian Tiger Chow
parent 673bb1ba
......@@ -14,8 +14,9 @@ import (
"crypto/sha512"
"hash"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
pb "github.com/jbenet/go-ipfs/crypto/internal/pb"
u "github.com/jbenet/go-ipfs/util"
)
......@@ -205,14 +206,14 @@ func KeyStretcher(cmp int, cipherType string, hashType string, secret []byte) ([
}
func UnmarshalPublicKey(data []byte) (PubKey, error) {
pmes := new(PBPublicKey)
pmes := new(pb.PBPublicKey)
err := proto.Unmarshal(data, pmes)
if err != nil {
return nil, err
}
switch pmes.GetType() {
case KeyType_RSA:
case pb.KeyType_RSA:
return UnmarshalRsaPublicKey(pmes.GetData())
default:
return nil, ErrBadKeyType
......@@ -220,14 +221,14 @@ func UnmarshalPublicKey(data []byte) (PubKey, error) {
}
func UnmarshalPrivateKey(data []byte) (PrivKey, error) {
pmes := new(PBPrivateKey)
pmes := new(pb.PBPrivateKey)
err := proto.Unmarshal(data, pmes)
if err != nil {
return nil, err
}
switch pmes.GetType() {
case KeyType_RSA:
case pb.KeyType_RSA:
return UnmarshalRsaPrivateKey(pmes.GetData())
default:
return nil, ErrBadKeyType
......
......@@ -8,7 +8,9 @@ import (
"crypto/x509"
"errors"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
pb "github.com/jbenet/go-ipfs/crypto/internal/pb"
)
type RsaPrivateKey struct {
......@@ -34,8 +36,8 @@ func (pk *RsaPublicKey) Bytes() ([]byte, error) {
return nil, err
}
pbmes := new(PBPublicKey)
typ := KeyType_RSA
pbmes := new(pb.PBPublicKey)
typ := pb.KeyType_RSA
pbmes.Type = &typ
pbmes.Data = b
return proto.Marshal(pbmes)
......@@ -67,8 +69,8 @@ func (sk *RsaPrivateKey) GetPublic() PubKey {
func (sk *RsaPrivateKey) Bytes() ([]byte, error) {
b := x509.MarshalPKCS1PrivateKey(sk.k)
pbmes := new(PBPrivateKey)
typ := KeyType_RSA
pbmes := new(pb.PBPrivateKey)
typ := pb.KeyType_RSA
pbmes.Type = &typ
pbmes.Data = b
return proto.Marshal(pbmes)
......
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