@cryptotaxi247 / kubo / commits / 2ed7da8cf

refactor(crypto) mv proto PBPublicKey -> PublicKey, etc.

Brian Tiger Chow committed Oct 22, 2014 at 21:41 UTC 2ed7da8cfdd27a2305b577088034e7031aecb74a
4 files changed +20 -20
crypto/internal/pb/crypto.pb.go
+14 -14
@@ -9,8 +9,8 @@ It is generated from these files:
9 crypto.proto
10
11 It has these top-level messages:
12 - PBPublicKey
13 - PBPrivateKey
12 + PublicKey
13 + PrivateKey
14 */
15 package crypto_pb
16
@@ -51,48 +51,48 @@ func (x *KeyType) UnmarshalJSON(data []byte) error {
51 return nil
52 }
53
54 -type PBPublicKey struct {
54 +type PublicKey struct {
55 Type *KeyType `protobuf:"varint,1,req,enum=crypto.pb.KeyType" json:"Type,omitempty"`
56 Data []byte `protobuf:"bytes,2,req" json:"Data,omitempty"`
57 XXX_unrecognized []byte `json:"-"`
58 }
59
60 -func (m *PBPublicKey) Reset() { *m = PBPublicKey{} }
61 -func (m *PBPublicKey) String() string { return proto.CompactTextString(m) }
62 -func (*PBPublicKey) ProtoMessage() {}
60 +func (m *PublicKey) Reset() { *m = PublicKey{} }
61 +func (m *PublicKey) String() string { return proto.CompactTextString(m) }
62 +func (*PublicKey) ProtoMessage() {}
63
64 -func (m *PBPublicKey) GetType() KeyType {
64 +func (m *PublicKey) GetType() KeyType {
65 if m != nil && m.Type != nil {
66 return *m.Type
67 }
68 return KeyType_RSA
69 }
70
71 -func (m *PBPublicKey) GetData() []byte {
71 +func (m *PublicKey) GetData() []byte {
72 if m != nil {
73 return m.Data
74 }
75 return nil
76 }
77
78 -type PBPrivateKey struct {
78 +type PrivateKey struct {
79 Type *KeyType `protobuf:"varint,1,req,enum=crypto.pb.KeyType" json:"Type,omitempty"`
80 Data []byte `protobuf:"bytes,2,req" json:"Data,omitempty"`
81 XXX_unrecognized []byte `json:"-"`
82 }
83
84 -func (m *PBPrivateKey) Reset() { *m = PBPrivateKey{} }
85 -func (m *PBPrivateKey) String() string { return proto.CompactTextString(m) }
86 -func (*PBPrivateKey) ProtoMessage() {}
84 +func (m *PrivateKey) Reset() { *m = PrivateKey{} }
85 +func (m *PrivateKey) String() string { return proto.CompactTextString(m) }
86 +func (*PrivateKey) ProtoMessage() {}
87
88 -func (m *PBPrivateKey) GetType() KeyType {
88 +func (m *PrivateKey) GetType() KeyType {
89 if m != nil && m.Type != nil {
90 return *m.Type
91 }
92 return KeyType_RSA
93 }
94
95 -func (m *PBPrivateKey) GetData() []byte {
95 +func (m *PrivateKey) GetData() []byte {
96 if m != nil {
97 return m.Data
98 }
crypto/internal/pb/crypto.proto
+2 -2
@@ -4,12 +4,12 @@ enum KeyType {
4 RSA = 0;
5 }
6
7 -message PBPublicKey {
7 +message PublicKey {
8 required KeyType Type = 1;
9 required bytes Data = 2;
10 }
11
12 -message PBPrivateKey {
12 +message PrivateKey {
13 required KeyType Type = 1;
14 required bytes Data = 2;
15 }
crypto/key.go
+2 -2
@@ -206,7 +206,7 @@ func KeyStretcher(cmp int, cipherType string, hashType string, secret []byte) ([
206 }
207
208 func UnmarshalPublicKey(data []byte) (PubKey, error) {
209 - pmes := new(pb.PBPublicKey)
209 + pmes := new(pb.PublicKey)
210 err := proto.Unmarshal(data, pmes)
211 if err != nil {
212 return nil, err
@@ -221,7 +221,7 @@ func UnmarshalPublicKey(data []byte) (PubKey, error) {
221 }
222
223 func UnmarshalPrivateKey(data []byte) (PrivKey, error) {
224 - pmes := new(pb.PBPrivateKey)
224 + pmes := new(pb.PrivateKey)
225 err := proto.Unmarshal(data, pmes)
226 if err != nil {
227 return nil, err
crypto/rsa.go
+2 -2
@@ -36,7 +36,7 @@ func (pk *RsaPublicKey) Bytes() ([]byte, error) {
36 return nil, err
37 }
38
39 - pbmes := new(pb.PBPublicKey)
39 + pbmes := new(pb.PublicKey)
40 typ := pb.KeyType_RSA
41 pbmes.Type = &typ
42 pbmes.Data = b
@@ -69,7 +69,7 @@ func (sk *RsaPrivateKey) GetPublic() PubKey {
69
70 func (sk *RsaPrivateKey) Bytes() ([]byte, error) {
71 b := x509.MarshalPKCS1PrivateKey(sk.k)
72 - pbmes := new(pb.PBPrivateKey)
72 + pbmes := new(pb.PrivateKey)
73 typ := pb.KeyType_RSA
74 pbmes.Type = &typ
75 pbmes.Data = b