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