From 1f258271fcab29f5c5b50d2fc3809b453c764b8a Mon Sep 17 00:00:00 2001 From: tabokie Date: Tue, 4 Apr 2023 14:06:04 +0800 Subject: [PATCH 1/2] add encryption v2 Signed-off-by: tabokie --- pkg/configpb/configpb.pb.gw.go | 22 +- pkg/encryptionpb/encryptionpb.pb.go | 557 +++++++++++++++++++++++++--- proto/encryptionpb.proto | 7 + 3 files changed, 510 insertions(+), 76 deletions(-) diff --git a/pkg/configpb/configpb.pb.gw.go b/pkg/configpb/configpb.pb.gw.go index 9b4675b32..c0385b0e4 100644 --- a/pkg/configpb/configpb.pb.gw.go +++ b/pkg/configpb/configpb.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join var ( filter_Config_Get_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} @@ -57,10 +55,7 @@ func local_request_Config_Get_0(ctx context.Context, marshaler runtime.Marshaler var protoReq GetRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Config_Get_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Config_Get_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -127,10 +122,7 @@ func local_request_Config_Delete_0(ctx context.Context, marshaler runtime.Marsha var protoReq DeleteRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Config_Delete_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Config_Delete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -142,14 +134,11 @@ func local_request_Config_Delete_0(ctx context.Context, marshaler runtime.Marsha // RegisterConfigHandlerServer registers the http handlers for service Config to "mux". // UnaryRPC :call ConfigServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterConfigHandlerFromEndpoint instead. func RegisterConfigHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ConfigServer) error { mux.Handle("GET", pattern_Config_Get_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -157,7 +146,6 @@ func RegisterConfigHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser return } resp, md, err := local_request_Config_Get_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -171,8 +159,6 @@ func RegisterConfigHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser mux.Handle("POST", pattern_Config_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -180,7 +166,6 @@ func RegisterConfigHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser return } resp, md, err := local_request_Config_Update_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -194,8 +179,6 @@ func RegisterConfigHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser mux.Handle("DELETE", pattern_Config_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -203,7 +186,6 @@ func RegisterConfigHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser return } resp, md, err := local_request_Config_Delete_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/pkg/encryptionpb/encryptionpb.pb.go b/pkg/encryptionpb/encryptionpb.pb.go index 24ab078e2..b74d04210 100644 --- a/pkg/encryptionpb/encryptionpb.pb.go +++ b/pkg/encryptionpb/encryptionpb.pb.go @@ -234,6 +234,63 @@ func (m *FileDictionary) GetFiles() map[string]*FileInfo { return nil } +type FileDictionaryV2 struct { + // A map of dir path to dir ID. + Dirs map[string]uint64 `protobuf:"bytes,1,rep,name=dirs,proto3" json:"dirs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + // A map of dir ID to file dictionary. + DirFiles map[uint64]*FileDictionary `protobuf:"bytes,2,rep,name=dir_files,json=dirFiles,proto3" json:"dir_files,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FileDictionaryV2) Reset() { *m = FileDictionaryV2{} } +func (m *FileDictionaryV2) String() string { return proto.CompactTextString(m) } +func (*FileDictionaryV2) ProtoMessage() {} +func (*FileDictionaryV2) Descriptor() ([]byte, []int) { + return fileDescriptor_a483860494a778a2, []int{3} +} +func (m *FileDictionaryV2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FileDictionaryV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FileDictionaryV2.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FileDictionaryV2) XXX_Merge(src proto.Message) { + xxx_messageInfo_FileDictionaryV2.Merge(m, src) +} +func (m *FileDictionaryV2) XXX_Size() int { + return m.Size() +} +func (m *FileDictionaryV2) XXX_DiscardUnknown() { + xxx_messageInfo_FileDictionaryV2.DiscardUnknown(m) +} + +var xxx_messageInfo_FileDictionaryV2 proto.InternalMessageInfo + +func (m *FileDictionaryV2) GetDirs() map[string]uint64 { + if m != nil { + return m.Dirs + } + return nil +} + +func (m *FileDictionaryV2) GetDirFiles() map[uint64]*FileDictionary { + if m != nil { + return m.DirFiles + } + return nil +} + // The key used to encrypt the user data. type DataKey struct { // A sequence of secret bytes used to encrypt data. @@ -253,7 +310,7 @@ func (m *DataKey) Reset() { *m = DataKey{} } func (m *DataKey) String() string { return proto.CompactTextString(m) } func (*DataKey) ProtoMessage() {} func (*DataKey) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{3} + return fileDescriptor_a483860494a778a2, []int{4} } func (m *DataKey) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -324,7 +381,7 @@ func (m *KeyDictionary) Reset() { *m = KeyDictionary{} } func (m *KeyDictionary) String() string { return proto.CompactTextString(m) } func (*KeyDictionary) ProtoMessage() {} func (*KeyDictionary) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{4} + return fileDescriptor_a483860494a778a2, []int{5} } func (m *KeyDictionary) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,7 +440,7 @@ func (m *MasterKey) Reset() { *m = MasterKey{} } func (m *MasterKey) String() string { return proto.CompactTextString(m) } func (*MasterKey) ProtoMessage() {} func (*MasterKey) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{5} + return fileDescriptor_a483860494a778a2, []int{6} } func (m *MasterKey) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -480,7 +537,7 @@ func (m *MasterKeyPlaintext) Reset() { *m = MasterKeyPlaintext{} } func (m *MasterKeyPlaintext) String() string { return proto.CompactTextString(m) } func (*MasterKeyPlaintext) ProtoMessage() {} func (*MasterKeyPlaintext) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{6} + return fileDescriptor_a483860494a778a2, []int{7} } func (m *MasterKeyPlaintext) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -523,7 +580,7 @@ func (m *MasterKeyFile) Reset() { *m = MasterKeyFile{} } func (m *MasterKeyFile) String() string { return proto.CompactTextString(m) } func (*MasterKeyFile) ProtoMessage() {} func (*MasterKeyFile) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{7} + return fileDescriptor_a483860494a778a2, []int{8} } func (m *MasterKeyFile) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -579,7 +636,7 @@ func (m *MasterKeyKms) Reset() { *m = MasterKeyKms{} } func (m *MasterKeyKms) String() string { return proto.CompactTextString(m) } func (*MasterKeyKms) ProtoMessage() {} func (*MasterKeyKms) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{8} + return fileDescriptor_a483860494a778a2, []int{9} } func (m *MasterKeyKms) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -659,7 +716,7 @@ func (m *EncryptedContent) Reset() { *m = EncryptedContent{} } func (m *EncryptedContent) String() string { return proto.CompactTextString(m) } func (*EncryptedContent) ProtoMessage() {} func (*EncryptedContent) Descriptor() ([]byte, []int) { - return fileDescriptor_a483860494a778a2, []int{9} + return fileDescriptor_a483860494a778a2, []int{10} } func (m *EncryptedContent) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -729,6 +786,9 @@ func init() { proto.RegisterType((*FileInfo)(nil), "encryptionpb.FileInfo") proto.RegisterType((*FileDictionary)(nil), "encryptionpb.FileDictionary") proto.RegisterMapType((map[string]*FileInfo)(nil), "encryptionpb.FileDictionary.FilesEntry") + proto.RegisterType((*FileDictionaryV2)(nil), "encryptionpb.FileDictionaryV2") + proto.RegisterMapType((map[uint64]*FileDictionary)(nil), "encryptionpb.FileDictionaryV2.DirFilesEntry") + proto.RegisterMapType((map[string]uint64)(nil), "encryptionpb.FileDictionaryV2.DirsEntry") proto.RegisterType((*DataKey)(nil), "encryptionpb.DataKey") proto.RegisterType((*KeyDictionary)(nil), "encryptionpb.KeyDictionary") proto.RegisterMapType((map[uint64]*DataKey)(nil), "encryptionpb.KeyDictionary.KeysEntry") @@ -743,55 +803,60 @@ func init() { func init() { proto.RegisterFile("encryptionpb.proto", fileDescriptor_a483860494a778a2) } var fileDescriptor_a483860494a778a2 = []byte{ - // 768 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0xd5, 0x50, 0xd4, 0x83, 0x57, 0x8f, 0x0a, 0x03, 0xdb, 0x15, 0x54, 0x40, 0x15, 0xe8, 0xba, - 0x15, 0x5a, 0x43, 0x85, 0xd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0x7e, 0x00, 0xb9, 0x0b, - 0x63, 0x4e, 0xfc, 0x3a, 0x6a, 0x65, 0xdb, 0x25, 0xe5, 0xb7, 0x74, 0xa5, 0x34, 0x99, 0x41, 0xbf, - 0x6b, 0x53, 0x2f, 0x50, 0xa3, 0xac, 0xc6, 0x29, 0xc0, 0x2a, 0x88, 0x6b, 0x90, 0x35, 0x49, 0xc0, - 0x7a, 0x97, 0xd4, 0x70, 0x89, 0xb7, 0x21, 0xb7, 0xd0, 0xe6, 0x97, 0x84, 0x35, 0x5f, 0x52, 0x36, - 0x6e, 0x97, 0x0f, 0xcf, 0xad, 0x46, 0xa4, 0xff, 0x84, 0x3d, 0x24, 0xbf, 0x42, 0x50, 0x38, 0xd6, - 0xa8, 0xd6, 0x27, 0xa9, 0x7a, 0xe5, 0xa8, 0xde, 0xea, 0xe4, 0xc2, 0xf7, 0x9c, 0x1c, 0x6f, 0x42, - 0x65, 0xe2, 0x11, 0x2d, 0xdc, 0x19, 0x53, 0xc3, 0x22, 0x4c, 0x38, 0x51, 0x2d, 0x2f, 0x83, 0x23, - 0xc3, 0x22, 0xf8, 0x67, 0x28, 0x5d, 0x69, 0xfe, 0x98, 0x5c, 0xbb, 0x8e, 0x4f, 0xf4, 0xba, 0xd8, - 0x42, 0xed, 0xa2, 0x0a, 0x57, 0x9a, 0xdf, 0x8d, 0x22, 0xf2, 0x7b, 0x04, 0x95, 0x3e, 0x09, 0x12, - 0xf2, 0xed, 0x83, 0x68, 0x92, 0x60, 0xa9, 0xde, 0x56, 0xba, 0x9b, 0x14, 0x35, 0x44, 0x5c, 0x3b, - 0x96, 0x82, 0x7f, 0x81, 0xea, 0xe4, 0xd2, 0xf3, 0x88, 0x4d, 0xc7, 0xfc, 0xce, 0x05, 0xde, 0x53, - 0x14, 0xed, 0x87, 0x57, 0xdf, 0x18, 0x82, 0x14, 0x27, 0x26, 0xf5, 0x10, 0x23, 0x3d, 0xfe, 0x48, - 0xeb, 0xbb, 0x9e, 0x6e, 0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e, 0x38, 0x1b, 0xd7, 0xa1, 0x30, - 0x89, 0x28, 0x7c, 0x34, 0x2c, 0x21, 0xde, 0x05, 0xb0, 0xd8, 0x59, 0x43, 0x67, 0x71, 0xa1, 0x7f, - 0xbc, 0x47, 0x68, 0x55, 0xb2, 0x62, 0x3b, 0x44, 0x73, 0x46, 0x8c, 0xe7, 0xcc, 0x16, 0x54, 0x27, - 0x86, 0x3b, 0x23, 0x5e, 0x28, 0x33, 0xab, 0x95, 0x63, 0x7b, 0x95, 0x55, 0xb4, 0x4f, 0x82, 0xc6, - 0xff, 0x50, 0x49, 0xf5, 0x78, 0xc7, 0x1c, 0x58, 0x4b, 0xfa, 0xb4, 0x9c, 0x30, 0xe4, 0xef, 0x66, - 0xac, 0x51, 0xfc, 0x6a, 0x71, 0x09, 0x0a, 0x4f, 0x87, 0xfd, 0xe1, 0x93, 0x67, 0xc3, 0x5a, 0x06, - 0x57, 0x40, 0x3a, 0x7d, 0x7c, 0x70, 0x32, 0x1c, 0x75, 0x9f, 0x8f, 0x6a, 0x08, 0x57, 0x01, 0x0e, - 0xba, 0x67, 0x3b, 0xca, 0xde, 0xf8, 0x68, 0xa4, 0xd6, 0x84, 0x25, 0xde, 0x57, 0x18, 0xce, 0x72, - 0xac, 0xfc, 0xb3, 0xcb, 0xb0, 0x18, 0xd6, 0x3a, 0x1b, 0xfc, 0xcd, 0x40, 0xee, 0xf0, 0xd7, 0x4f, - 0x6f, 0x8b, 0xe8, 0xc3, 0x4d, 0x13, 0x7d, 0xbc, 0x69, 0xa2, 0xcf, 0x37, 0x4d, 0xf4, 0xf2, 0x4b, - 0x33, 0x03, 0x35, 0xc7, 0x9b, 0x76, 0xa8, 0x61, 0x2e, 0x3a, 0xe6, 0x82, 0x0d, 0xf3, 0xf3, 0x3c, - 0xfb, 0xfc, 0xf5, 0x35, 0x00, 0x00, 0xff, 0xff, 0xec, 0x2d, 0xb0, 0x8e, 0x1e, 0x06, 0x00, 0x00, + // 846 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcf, 0x73, 0xdb, 0x44, + 0x14, 0xf6, 0xca, 0xb2, 0x63, 0x3d, 0xff, 0xc0, 0xb3, 0x93, 0x06, 0x8f, 0x60, 0x8c, 0x47, 0xa5, + 0xe0, 0x81, 0x8c, 0x99, 0x0a, 0x48, 0x5b, 0x7e, 0xcc, 0xd0, 0x36, 0x66, 0x92, 0x31, 0x31, 0x19, + 0x35, 0x14, 0x38, 0x79, 0x14, 0x6b, 0x9b, 0xec, 0xc8, 0xfa, 0xc1, 0x6a, 0xe3, 0x56, 0xff, 0x09, + 0x1c, 0xe1, 0xc4, 0x8d, 0x3f, 0x80, 0x0b, 0x47, 0x8e, 0x1c, 0x39, 0x32, 0xe1, 0x1f, 0x61, 0x76, + 0xb5, 0x92, 0xa5, 0x69, 0xd2, 0xd2, 0x93, 0xf5, 0xde, 0xbe, 0xef, 0xdb, 0xef, 0xbd, 0xfd, 0x76, + 0x0d, 0x98, 0x84, 0x4b, 0x96, 0xc6, 0x9c, 0x46, 0x61, 0x7c, 0x3a, 0x89, 0x59, 0xc4, 0x23, 0xdc, + 0x29, 0xe7, 0xcc, 0xed, 0xb3, 0xe8, 0x2c, 0x92, 0x0b, 0x1f, 0x88, 0xaf, 0xac, 0xc6, 0x7c, 0x8d, + 0x5d, 0x24, 0x5c, 0x7e, 0x66, 0x09, 0xeb, 0x0e, 0xf4, 0xa6, 0x05, 0xec, 0x88, 0x70, 0x17, 0xdf, + 0x80, 0xa6, 0x4f, 0xd2, 0x05, 0xf5, 0x06, 0x68, 0x84, 0xc6, 0xba, 0xd3, 0xf0, 0x49, 0x7a, 0xe8, + 0xe1, 0x1e, 0x68, 0x74, 0x3d, 0xd0, 0x46, 0x68, 0xdc, 0x71, 0x34, 0xba, 0xb6, 0x28, 0xb4, 0xbe, + 0xa4, 0x2b, 0x72, 0x18, 0x3e, 0x89, 0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df, 0xe5, 0xee, 0x8c, + 0x54, 0x58, 0x3b, 0x19, 0xeb, 0xc6, 0x2b, 0xda, 0xab, 0x78, 0x05, 0xdf, 0x84, 0xee, 0x92, 0x11, + 0x57, 0xac, 0x2c, 0x38, 0x0d, 0x88, 0xb4, 0x9a, 0xee, 0x74, 0xf2, 0xe4, 0x09, 0x0d, 0x08, 0x7e, + 0x0b, 0xda, 0x4f, 0xdd, 0x64, 0x41, 0x9e, 0xc5, 0x51, 0x42, 0xbc, 0x81, 0x3e, 0x42, 0xe3, 0x96, + 0x03, 0x4f, 0xdd, 0x64, 0x9a, 0x65, 0xac, 0x3f, 0x10, 0x74, 0x67, 0x24, 0x2d, 0x19, 0xee, 0x1e, + 0xe8, 0x3e, 0x49, 0xf3, 0xa3, 0xbc, 0x55, 0x55, 0x53, 0x29, 0x15, 0x51, 0x7e, 0x8e, 0x02, 0x82, + 0xdf, 0x86, 0xde, 0xf2, 0x82, 0x31, 0x12, 0xf2, 0x85, 0xba, 0x25, 0x9a, 0xd2, 0x94, 0x65, 0x67, + 0xe2, 0xb2, 0x98, 0x73, 0x30, 0x0a, 0xe0, 0x15, 0x53, 0x7e, 0xbf, 0x3a, 0xe5, 0x1b, 0x55, 0x01, + 0x6a, 0x8e, 0xe5, 0xf1, 0xfe, 0x8e, 0xc0, 0x38, 0x72, 0x13, 0x4e, 0x98, 0x18, 0xf0, 0x17, 0x60, + 0xc4, 0x2b, 0x97, 0x86, 0x9c, 0x3c, 0xe3, 0x92, 0xb6, 0x6d, 0x8f, 0xaa, 0x14, 0x45, 0xed, 0x71, + 0x5e, 0x77, 0x50, 0x73, 0x36, 0x20, 0x7c, 0x1b, 0x74, 0xe1, 0x44, 0xb5, 0xff, 0x1b, 0xd7, 0x80, + 0xc5, 0x71, 0x1f, 0xd4, 0x1c, 0x59, 0x8a, 0x27, 0x50, 0xf7, 0x83, 0x44, 0x9e, 0x40, 0xdb, 0x36, + 0xaf, 0x41, 0xcc, 0x82, 0xe4, 0x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0x51, 0x71, 0x6b, 0x71, 0x1b, + 0xb6, 0xbe, 0x99, 0xcf, 0xe6, 0x5f, 0x7f, 0x3b, 0xef, 0xd7, 0x70, 0x17, 0x8c, 0xe3, 0xaf, 0xee, + 0x1f, 0xce, 0x4f, 0xa6, 0xdf, 0x9d, 0xf4, 0x11, 0xee, 0x01, 0xdc, 0x9f, 0x3e, 0xba, 0x6d, 0xdf, + 0x5d, 0x3c, 0x3c, 0x71, 0xfa, 0x5a, 0x1e, 0xdf, 0xb3, 0x65, 0x5c, 0x57, 0xb1, 0xfd, 0xf1, 0x9e, + 0x8c, 0x75, 0xc1, 0xf5, 0xe8, 0xe8, 0x23, 0x19, 0x34, 0x1e, 0xbc, 0xf3, 0xf7, 0xaf, 0x2d, 0xf4, + 0xe7, 0xe5, 0x10, 0xfd, 0x75, 0x39, 0x44, 0xff, 0x5c, 0x0e, 0xd1, 0x8f, 0xff, 0x0e, 0x6b, 0xd0, + 0x8f, 0xd8, 0xd9, 0x84, 0x53, 0x7f, 0x3d, 0xf1, 0xd7, 0xf2, 0xef, 0xef, 0xb4, 0x29, 0x7f, 0x3e, + 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x77, 0x4e, 0x99, 0xe7, 0x50, 0x07, 0x00, 0x00, } func (m *EncryptionMeta) Marshal() (dAtA []byte, err error) { @@ -930,6 +995,74 @@ func (m *FileDictionary) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *FileDictionaryV2) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FileDictionaryV2) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FileDictionaryV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.DirFiles) > 0 { + for k := range m.DirFiles { + v := m.DirFiles[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEncryptionpb(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintEncryptionpb(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintEncryptionpb(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Dirs) > 0 { + for k := range m.Dirs { + v := m.Dirs[k] + baseI := i + i = encodeVarintEncryptionpb(dAtA, i, uint64(v)) + i-- + dAtA[i] = 0x10 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintEncryptionpb(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintEncryptionpb(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *DataKey) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1413,6 +1546,39 @@ func (m *FileDictionary) Size() (n int) { return n } +func (m *FileDictionaryV2) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Dirs) > 0 { + for k, v := range m.Dirs { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovEncryptionpb(uint64(len(k))) + 1 + sovEncryptionpb(uint64(v)) + n += mapEntrySize + 1 + sovEncryptionpb(uint64(mapEntrySize)) + } + } + if len(m.DirFiles) > 0 { + for k, v := range m.DirFiles { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovEncryptionpb(uint64(l)) + } + mapEntrySize := 1 + sovEncryptionpb(uint64(k)) + l + n += mapEntrySize + 1 + sovEncryptionpb(uint64(mapEntrySize)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *DataKey) Size() (n int) { if m == nil { return 0 @@ -2026,6 +2192,285 @@ func (m *FileDictionary) Unmarshal(dAtA []byte) error { } return nil } +func (m *FileDictionaryV2) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FileDictionaryV2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FileDictionaryV2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dirs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEncryptionpb + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEncryptionpb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Dirs == nil { + m.Dirs = make(map[string]uint64) + } + var mapkey string + var mapvalue uint64 + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthEncryptionpb + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthEncryptionpb + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else { + iNdEx = entryPreIndex + skippy, err := skipEncryptionpb(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEncryptionpb + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Dirs[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DirFiles", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEncryptionpb + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEncryptionpb + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DirFiles == nil { + m.DirFiles = make(map[uint64]*FileDictionary) + } + var mapkey uint64 + var mapvalue *FileDictionary + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEncryptionpb + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthEncryptionpb + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthEncryptionpb + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &FileDictionary{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipEncryptionpb(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEncryptionpb + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.DirFiles[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEncryptionpb(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEncryptionpb + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *DataKey) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/proto/encryptionpb.proto b/proto/encryptionpb.proto index 2328088c7..fa58d9eba 100644 --- a/proto/encryptionpb.proto +++ b/proto/encryptionpb.proto @@ -38,6 +38,13 @@ message FileDictionary { map files = 1; } +message FileDictionaryV2 { + // A map of dir path to dir ID. + map dirs = 1; + // A map of dir ID to file dictionary. + map dir_files = 2; +} + enum EncryptionMethod { UNKNOWN = 0; PLAINTEXT = 1; From b47521548d4f253d333673609a4bcc7f270e7e80 Mon Sep 17 00:00:00 2001 From: tabokie Date: Tue, 4 Apr 2023 14:10:35 +0800 Subject: [PATCH 2/2] fix Signed-off-by: tabokie --- scripts/proto.lock | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/proto.lock b/scripts/proto.lock index 6b3bcabf3..7e89a8333 100644 --- a/scripts/proto.lock +++ b/scripts/proto.lock @@ -4358,6 +4358,27 @@ } ] }, + { + "name": "FileDictionaryV2", + "maps": [ + { + "key_type": "string", + "field": { + "id": 1, + "name": "dirs", + "type": "uint64" + } + }, + { + "key_type": "uint64", + "field": { + "id": 2, + "name": "dir_files", + "type": "FileDictionary" + } + } + ] + }, { "name": "DataKey", "fields": [