mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-04 05:16:23 +08:00
refactor(crypto) mv proto PBPublicKey -> PublicKey, etc.
This commit is contained in:
@ -9,8 +9,8 @@ It is generated from these files:
|
|||||||
crypto.proto
|
crypto.proto
|
||||||
|
|
||||||
It has these top-level messages:
|
It has these top-level messages:
|
||||||
PBPublicKey
|
PublicKey
|
||||||
PBPrivateKey
|
PrivateKey
|
||||||
*/
|
*/
|
||||||
package crypto_pb
|
package crypto_pb
|
||||||
|
|
||||||
@ -51,48 +51,48 @@ func (x *KeyType) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type PBPublicKey struct {
|
type PublicKey struct {
|
||||||
Type *KeyType `protobuf:"varint,1,req,enum=crypto.pb.KeyType" json:"Type,omitempty"`
|
Type *KeyType `protobuf:"varint,1,req,enum=crypto.pb.KeyType" json:"Type,omitempty"`
|
||||||
Data []byte `protobuf:"bytes,2,req" json:"Data,omitempty"`
|
Data []byte `protobuf:"bytes,2,req" json:"Data,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PBPublicKey) Reset() { *m = PBPublicKey{} }
|
func (m *PublicKey) Reset() { *m = PublicKey{} }
|
||||||
func (m *PBPublicKey) String() string { return proto.CompactTextString(m) }
|
func (m *PublicKey) String() string { return proto.CompactTextString(m) }
|
||||||
func (*PBPublicKey) ProtoMessage() {}
|
func (*PublicKey) ProtoMessage() {}
|
||||||
|
|
||||||
func (m *PBPublicKey) GetType() KeyType {
|
func (m *PublicKey) GetType() KeyType {
|
||||||
if m != nil && m.Type != nil {
|
if m != nil && m.Type != nil {
|
||||||
return *m.Type
|
return *m.Type
|
||||||
}
|
}
|
||||||
return KeyType_RSA
|
return KeyType_RSA
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PBPublicKey) GetData() []byte {
|
func (m *PublicKey) GetData() []byte {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Data
|
return m.Data
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type PBPrivateKey struct {
|
type PrivateKey struct {
|
||||||
Type *KeyType `protobuf:"varint,1,req,enum=crypto.pb.KeyType" json:"Type,omitempty"`
|
Type *KeyType `protobuf:"varint,1,req,enum=crypto.pb.KeyType" json:"Type,omitempty"`
|
||||||
Data []byte `protobuf:"bytes,2,req" json:"Data,omitempty"`
|
Data []byte `protobuf:"bytes,2,req" json:"Data,omitempty"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PBPrivateKey) Reset() { *m = PBPrivateKey{} }
|
func (m *PrivateKey) Reset() { *m = PrivateKey{} }
|
||||||
func (m *PBPrivateKey) String() string { return proto.CompactTextString(m) }
|
func (m *PrivateKey) String() string { return proto.CompactTextString(m) }
|
||||||
func (*PBPrivateKey) ProtoMessage() {}
|
func (*PrivateKey) ProtoMessage() {}
|
||||||
|
|
||||||
func (m *PBPrivateKey) GetType() KeyType {
|
func (m *PrivateKey) GetType() KeyType {
|
||||||
if m != nil && m.Type != nil {
|
if m != nil && m.Type != nil {
|
||||||
return *m.Type
|
return *m.Type
|
||||||
}
|
}
|
||||||
return KeyType_RSA
|
return KeyType_RSA
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *PBPrivateKey) GetData() []byte {
|
func (m *PrivateKey) GetData() []byte {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Data
|
return m.Data
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@ enum KeyType {
|
|||||||
RSA = 0;
|
RSA = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PBPublicKey {
|
message PublicKey {
|
||||||
required KeyType Type = 1;
|
required KeyType Type = 1;
|
||||||
required bytes Data = 2;
|
required bytes Data = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PBPrivateKey {
|
message PrivateKey {
|
||||||
required KeyType Type = 1;
|
required KeyType Type = 1;
|
||||||
required bytes Data = 2;
|
required bytes Data = 2;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ func KeyStretcher(cmp int, cipherType string, hashType string, secret []byte) ([
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UnmarshalPublicKey(data []byte) (PubKey, error) {
|
func UnmarshalPublicKey(data []byte) (PubKey, error) {
|
||||||
pmes := new(pb.PBPublicKey)
|
pmes := new(pb.PublicKey)
|
||||||
err := proto.Unmarshal(data, pmes)
|
err := proto.Unmarshal(data, pmes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -221,7 +221,7 @@ func UnmarshalPublicKey(data []byte) (PubKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UnmarshalPrivateKey(data []byte) (PrivKey, error) {
|
func UnmarshalPrivateKey(data []byte) (PrivKey, error) {
|
||||||
pmes := new(pb.PBPrivateKey)
|
pmes := new(pb.PrivateKey)
|
||||||
err := proto.Unmarshal(data, pmes)
|
err := proto.Unmarshal(data, pmes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -36,7 +36,7 @@ func (pk *RsaPublicKey) Bytes() ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pbmes := new(pb.PBPublicKey)
|
pbmes := new(pb.PublicKey)
|
||||||
typ := pb.KeyType_RSA
|
typ := pb.KeyType_RSA
|
||||||
pbmes.Type = &typ
|
pbmes.Type = &typ
|
||||||
pbmes.Data = b
|
pbmes.Data = b
|
||||||
@ -69,7 +69,7 @@ func (sk *RsaPrivateKey) GetPublic() PubKey {
|
|||||||
|
|
||||||
func (sk *RsaPrivateKey) Bytes() ([]byte, error) {
|
func (sk *RsaPrivateKey) Bytes() ([]byte, error) {
|
||||||
b := x509.MarshalPKCS1PrivateKey(sk.k)
|
b := x509.MarshalPKCS1PrivateKey(sk.k)
|
||||||
pbmes := new(pb.PBPrivateKey)
|
pbmes := new(pb.PrivateKey)
|
||||||
typ := pb.KeyType_RSA
|
typ := pb.KeyType_RSA
|
||||||
pbmes.Type = &typ
|
pbmes.Type = &typ
|
||||||
pbmes.Data = b
|
pbmes.Data = b
|
||||||
|
Reference in New Issue
Block a user