satellite/metainfo: add EncryptionParameters to SatStreamID

We have a use case for this in ListSegments. ListSegments is going to
return the EncryptedETag along with EncryptedKey and EncryptedKeyNonce.
It also must return the EncryptionParameters.

Since the EncryptionParameters are in the objects DB table, it would be
more efficient for ListSegment to avoid querying that DB table, but take
it from the SatStreamID.

Change-Id: I16c98641c0fe0c98e3303329d0da6ef137ca55cf
This commit is contained in:
Kaloyan Raev 2021-03-24 11:33:56 +02:00
parent c5cb4dce4d
commit cc42dfcc78
3 changed files with 77 additions and 55 deletions

View File

@ -26,18 +26,19 @@ var _ = time.Kitchen
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type StreamID struct {
Bucket []byte `protobuf:"bytes,1,opt,name=bucket,proto3" json:"bucket,omitempty"`
EncryptedPath []byte `protobuf:"bytes,2,opt,name=encrypted_path,json=encryptedPath,proto3" json:"encrypted_path,omitempty"`
Version int32 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"`
Redundancy *pb.RedundancyScheme `protobuf:"bytes,4,opt,name=redundancy,proto3" json:"redundancy,omitempty"`
CreationDate time.Time `protobuf:"bytes,5,opt,name=creation_date,json=creationDate,proto3,stdtime" json:"creation_date"`
ExpirationDate time.Time `protobuf:"bytes,6,opt,name=expiration_date,json=expirationDate,proto3,stdtime" json:"expiration_date"`
MultipartObject bool `protobuf:"varint,11,opt,name=multipart_object,json=multipartObject,proto3" json:"multipart_object,omitempty"`
SatelliteSignature []byte `protobuf:"bytes,9,opt,name=satellite_signature,json=satelliteSignature,proto3" json:"satellite_signature,omitempty"`
StreamId []byte `protobuf:"bytes,10,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Bucket []byte `protobuf:"bytes,1,opt,name=bucket,proto3" json:"bucket,omitempty"`
EncryptedPath []byte `protobuf:"bytes,2,opt,name=encrypted_path,json=encryptedPath,proto3" json:"encrypted_path,omitempty"`
Version int32 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"`
Redundancy *pb.RedundancyScheme `protobuf:"bytes,4,opt,name=redundancy,proto3" json:"redundancy,omitempty"`
EncryptionParameters *pb.EncryptionParameters `protobuf:"bytes,12,opt,name=encryption_parameters,json=encryptionParameters,proto3" json:"encryption_parameters,omitempty"`
CreationDate time.Time `protobuf:"bytes,5,opt,name=creation_date,json=creationDate,proto3,stdtime" json:"creation_date"`
ExpirationDate time.Time `protobuf:"bytes,6,opt,name=expiration_date,json=expirationDate,proto3,stdtime" json:"expiration_date"`
MultipartObject bool `protobuf:"varint,11,opt,name=multipart_object,json=multipartObject,proto3" json:"multipart_object,omitempty"`
SatelliteSignature []byte `protobuf:"bytes,9,opt,name=satellite_signature,json=satelliteSignature,proto3" json:"satellite_signature,omitempty"`
StreamId []byte `protobuf:"bytes,10,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StreamID) Reset() { *m = StreamID{} }
@ -92,6 +93,13 @@ func (m *StreamID) GetRedundancy() *pb.RedundancyScheme {
return nil
}
func (m *StreamID) GetEncryptionParameters() *pb.EncryptionParameters {
if m != nil {
return m.EncryptionParameters
}
return nil
}
func (m *StreamID) GetCreationDate() time.Time {
if m != nil {
return m.CreationDate
@ -214,38 +222,41 @@ func init() {
func init() { proto.RegisterFile("metainfo_sat.proto", fileDescriptor_47c60bd892d94aaf) }
var fileDescriptor_47c60bd892d94aaf = []byte{
// 527 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcd, 0x6e, 0xd3, 0x4c,
0x14, 0xfd, 0xfc, 0x85, 0xfc, 0x4d, 0xfe, 0xd0, 0x14, 0x90, 0x95, 0x82, 0x12, 0x15, 0x55, 0x0a,
0x1b, 0x5b, 0x6a, 0x57, 0x88, 0x15, 0x51, 0x36, 0x91, 0x80, 0x16, 0x87, 0x15, 0x1b, 0x6b, 0xec,
0xb9, 0x75, 0xa6, 0xd8, 0x33, 0xd6, 0xcc, 0x35, 0x6a, 0x97, 0xbc, 0x01, 0xef, 0xc2, 0x4b, 0xf0,
0x0c, 0x2c, 0xca, 0xab, 0x20, 0x8f, 0xe3, 0x38, 0x52, 0xd5, 0x05, 0xec, 0x7c, 0xce, 0x3d, 0xf7,
0xf8, 0xde, 0x39, 0x97, 0xd0, 0x0c, 0x90, 0x09, 0x79, 0xa5, 0x42, 0xc3, 0xd0, 0xcb, 0xb5, 0x42,
0x45, 0xa9, 0x61, 0x08, 0x69, 0x2a, 0x10, 0xbc, 0xba, 0x3a, 0x25, 0x89, 0x4a, 0x54, 0x55, 0x9f,
0xce, 0x12, 0xa5, 0x92, 0x14, 0x7c, 0x8b, 0xa2, 0xe2, 0xca, 0x47, 0x91, 0x81, 0x41, 0x96, 0xe5,
0x3b, 0xc1, 0x24, 0x57, 0x42, 0x22, 0x68, 0x1e, 0xed, 0x88, 0x71, 0xed, 0x53, 0xe1, 0x93, 0x1f,
0x2d, 0xd2, 0xdb, 0xa0, 0x06, 0x96, 0xad, 0x57, 0xf4, 0x19, 0xe9, 0x44, 0x45, 0xfc, 0x05, 0xd0,
0x75, 0xe6, 0xce, 0x62, 0x18, 0xec, 0x10, 0x3d, 0x25, 0x63, 0x90, 0xb1, 0xbe, 0xcd, 0x11, 0x78,
0x98, 0x33, 0xdc, 0xba, 0xff, 0xdb, 0xfa, 0x68, 0xcf, 0x5e, 0x32, 0xdc, 0x52, 0x97, 0x74, 0xbf,
0x82, 0x36, 0x42, 0x49, 0xb7, 0x35, 0x77, 0x16, 0xed, 0xa0, 0x86, 0xf4, 0x0d, 0x21, 0x1a, 0x78,
0x21, 0x39, 0x93, 0xf1, 0xad, 0xfb, 0x68, 0xee, 0x2c, 0x06, 0x67, 0xc7, 0x5e,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 0x05, 0xc4, 0x50, 0xfe, 0xb5, 0x8c, 0x64, 0xb8, 0x9c,
0x94, 0x2f, 0xf5, 0xeb, 0x6e, 0xd6, 0xbd, 0x2c, 0xf9, 0xf5, 0x2a, 0x18, 0x94, 0xaa, 0x0a, 0x70,
0xfa, 0x91, 0x3c, 0x55, 0x5a, 0x24, 0x42, 0xb2, 0x34, 0x54, 0x9a, 0x83, 0x0e, 0x53, 0x91, 0x09,
0x34, 0x6e, 0x67, 0xde, 0x5a, 0x0c, 0xce, 0x5e, 0x34, 0x83, 0xbe, 0xe5, 0x5c, 0x83, 0x31, 0xc0,
0x2f, 0x4a, 0xd9, 0xbb, 0x52, 0x15, 0x1c, 0xd5, 0xbd, 0x0d, 0x67, 0xee, 0x9f, 0x46, 0xf7, 0x9f,
0x4f, 0xe3, 0x81, 0x80, 0x7a, 0x0f, 0x05, 0xb4, 0x3c, 0xfd, 0xfc, 0xd2, 0xa0, 0xd2, 0xd7, 0x9e,
0x50, 0xbe, 0xfd, 0xf0, 0xf7, 0x22, 0xdf, 0xde, 0xb5, 0x64, 0x69, 0x1e, 0x45, 0x1d, 0x3b, 0xc3,
0xf9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x91, 0xd4, 0xc6, 0x83, 0xdf, 0x03, 0x00, 0x00,
// 562 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x40,
0x10, 0xc5, 0xb4, 0x49, 0xd3, 0x4d, 0xda, 0x54, 0xdb, 0x16, 0x59, 0x2d, 0x28, 0x56, 0x51, 0xa5,
0x70, 0xb1, 0xa5, 0xf6, 0x84, 0x38, 0x51, 0x85, 0x43, 0x24, 0xa0, 0xc1, 0x81, 0x0b, 0x17, 0x6b,
0xed, 0x9d, 0x3a, 0x5b, 0xec, 0x5d, 0x6b, 0x3d, 0x46, 0xed, 0x91, 0x2b, 0x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 0x72, 0xb8, 0xa9,
0x83, 0x52, 0x15, 0xf4, 0x9c, 0xec, 0x68, 0xa5, 0x30, 0xc8, 0x04, 0x44, 0x50, 0xfe, 0x6a, 0x79,
0x92, 0xd1, 0xc5, 0xb8, 0x74, 0xea, 0xd7, 0xdd, 0x64, 0x6b, 0x51, 0xe2, 0xf3, 0x99, 0x3f, 0x2c,
0x59, 0x55, 0xc1, 0xe9, 0x07, 0x72, 0xa8, 0xb4, 0x88, 0x85, 0x64, 0x49, 0xa0, 0x34, 0x07, 0x1d,
0x24, 0x22, 0x15, 0x98, 0xdb, 0x7d, 0x67, 0x63, 0x3a, 0x3c, 0x7b, 0xd6, 0x2d, 0xfa, 0x9a, 0x73,
0x0d, 0x79, 0x0e, 0xfc, 0xb2, 0xa4, 0xbd, 0x2d, 0x59, 0xfe, 0x7e, 0x33, 0xdb, 0x61, 0xf7, 0x44,
0x63, 0xeb, 0xbf, 0xa3, 0xf1, 0xc0, 0x81, 0x06, 0x0f, 0x1d, 0xe8, 0xe2, 0xf4, 0xf3, 0xf3, 0x1c,
0x95, 0xbe, 0x76, 0x85, 0xf2, 0xcc, 0xc3, 0x6b, 0x49, 0x9e, 0xf9, 0x5c, 0x24, 0x4b, 0xb2, 0x30,
0xec, 0x9b, 0x1d, 0xce, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x7a, 0x28, 0xd2, 0x48, 0x04,
0x00, 0x00,
}

View File

@ -6,6 +6,7 @@ option go_package = "storj.io/storj/satellite/internalpb";
package satellite.metainfo;
import "encryption.proto";
import "gogo.proto";
import "google/protobuf/timestamp.proto";
import "pointerdb.proto";
@ -17,6 +18,7 @@ message StreamID {
int32 version = 3;
pointerdb.RedundancyScheme redundancy = 4;
encryption.EncryptionParameters encryption_parameters = 12;
google.protobuf.Timestamp creation_date = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
google.protobuf.Timestamp expiration_date = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
@ -38,4 +40,4 @@ message SegmentID {
google.protobuf.Timestamp creation_date = 7 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
bytes satellite_signature = 8;
}
}

View File

@ -726,14 +726,15 @@ func (endpoint *Endpoint) BeginObject(ctx context.Context, req *pb.ObjectBeginRe
}
satStreamID, err := endpoint.packStreamID(ctx, &internalpb.StreamID{
Bucket: req.Bucket,
EncryptedPath: req.EncryptedPath,
Version: int32(object.Version),
Redundancy: pbRS,
CreationDate: object.CreatedAt,
ExpirationDate: req.ExpiresAt,
StreamId: streamID[:],
MultipartObject: object.FixedSegmentSize <= 0,
Bucket: req.Bucket,
EncryptedPath: req.EncryptedPath,
Version: int32(object.Version),
Redundancy: pbRS,
CreationDate: object.CreatedAt,
ExpirationDate: req.ExpiresAt,
StreamId: streamID[:],
MultipartObject: object.FixedSegmentSize <= 0,
EncryptionParameters: req.EncryptionParameters,
})
if err != nil {
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
@ -2115,6 +2116,10 @@ func (endpoint *Endpoint) objectToProto(ctx context.Context, object metabase.Obj
StreamId: object.StreamID[:],
MultipartObject: multipartObject,
Redundancy: rs,
EncryptionParameters: &pb.EncryptionParameters{
CipherSuite: pb.CipherSuite(object.Encryption.CipherSuite),
BlockSize: int64(object.Encryption.BlockSize),
},
})
if err != nil {
return nil, err
@ -2248,6 +2253,10 @@ func (endpoint *Endpoint) objectEntryToProtoListItem(ctx context.Context, bucket
// TODO: defaultRS may change while the upload is pending.
// Ideally, we should remove redundancy from satStreamID.
Redundancy: endpoint.defaultRS,
EncryptionParameters: &pb.EncryptionParameters{
CipherSuite: pb.CipherSuite(entry.Encryption.CipherSuite),
BlockSize: int64(entry.Encryption.BlockSize),
},
})
if err != nil {
return nil, err