@ -2167,7 +2167,7 @@ func (s3a *S3ApiServer) copyChunkWithReencryption(chunk *filer_pb.FileChunk, cop
// copyChunksWithSSEKMS handles SSE-KMS aware copying with smart fast/slow path selection
// copyChunksWithSSEKMS handles SSE-KMS aware copying with smart fast/slow path selection
// Returns chunks and destination metadata like SSE-C for consistency
// Returns chunks and destination metadata like SSE-C for consistency
func ( s3a * S3ApiServer ) copyChunksWithSSEKMS ( entry * filer_pb . Entry , r * http . Request , bucket string ) ( [ ] * filer_pb . FileChunk , map [ string ] [ ] byte , error ) {
func ( s3a * S3ApiServer ) copyChunksWithSSEKMS ( entry * filer_pb . Entry , r * http . Request , bucket string , dstPath string ) ( [ ] * filer_pb . FileChunk , map [ string ] [ ] byte , error ) {
// Parse SSE-KMS headers from copy request
// Parse SSE-KMS headers from copy request
destKeyID , encryptionContext , bucketKeyEnabled , err := ParseSSEKMSCopyHeaders ( r )
destKeyID , encryptionContext , bucketKeyEnabled , err := ParseSSEKMSCopyHeaders ( r )
@ -2188,13 +2188,13 @@ func (s3a *S3ApiServer) copyChunksWithSSEKMS(entry *filer_pb.Entry, r *http.Requ
if isMultipartSSEKMS {
if isMultipartSSEKMS {
glog . V ( 2 ) . Infof ( "Detected multipart SSE-KMS object with %d encrypted chunks for copy" , sseKMSChunks )
glog . V ( 2 ) . Infof ( "Detected multipart SSE-KMS object with %d encrypted chunks for copy" , sseKMSChunks )
return s3a . copyMultipartSSEKMSChunks ( entry , destKeyID , encryptionContext , bucketKeyEnabled , r . URL . Path , bucket )
return s3a . copyMultipartSSEKMSChunks ( entry , destKeyID , encryptionContext , bucketKeyEnabled , dst Path, bucket )
}
}
// Single-part SSE-KMS object: use existing logic
// Single-part SSE-KMS object: use existing logic
// If no SSE-KMS headers and source is not SSE-KMS encrypted, use regular copy
// If no SSE-KMS headers and source is not SSE-KMS encrypted, use regular copy
if destKeyID == "" && ! IsSSEKMSEncrypted ( entry . Extended ) {
if destKeyID == "" && ! IsSSEKMSEncrypted ( entry . Extended ) {
chunks , err := s3a . copyChunks ( entry , r . URL . Path )
chunks , err := s3a . copyChunks ( entry , dst Path)
return chunks , nil , err
return chunks , nil , err
}
}
@ -2215,19 +2215,19 @@ func (s3a *S3ApiServer) copyChunksWithSSEKMS(entry *filer_pb.Entry, r *http.Requ
return nil , nil , err
return nil , nil , err
}
}
glog . V ( 2 ) . Infof ( "SSE-KMS copy strategy for %s: %v" , r . URL . Path , strategy )
glog . V ( 2 ) . Infof ( "SSE-KMS copy strategy for %s: %v" , dst Path, strategy )
switch strategy {
switch strategy {
case SSEKMSCopyStrategyDirect :
case SSEKMSCopyStrategyDirect :
// FAST PATH: Direct chunk copy (same key or both unencrypted)
// FAST PATH: Direct chunk copy (same key or both unencrypted)
glog . V ( 2 ) . Infof ( "Using fast path: direct chunk copy for %s" , r . URL . Path )
chunks , err := s3a . copyChunks ( entry , r . URL . Path )
glog . V ( 2 ) . Infof ( "Using fast path: direct chunk copy for %s" , dst Path)
chunks , err := s3a . copyChunks ( entry , dst Path)
// For direct copy, generate destination metadata if we're encrypting to SSE-KMS
// For direct copy, generate destination metadata if we're encrypting to SSE-KMS
var dstMetadata map [ string ] [ ] byte
var dstMetadata map [ string ] [ ] byte
if destKeyID != "" {
if destKeyID != "" {
dstMetadata = make ( map [ string ] [ ] byte )
dstMetadata = make ( map [ string ] [ ] byte )
if encryptionContext == nil {
if encryptionContext == nil {
encryptionContext = BuildEncryptionContext ( bucket , r . URL . Path , bucketKeyEnabled )
encryptionContext = BuildEncryptionContext ( bucket , dst Path, bucketKeyEnabled )
}
}
sseKey := & SSEKMSKey {
sseKey := & SSEKMSKey {
KeyID : destKeyID ,
KeyID : destKeyID ,
@ -2245,8 +2245,8 @@ func (s3a *S3ApiServer) copyChunksWithSSEKMS(entry *filer_pb.Entry, r *http.Requ
case SSEKMSCopyStrategyDecryptEncrypt :
case SSEKMSCopyStrategyDecryptEncrypt :
// SLOW PATH: Decrypt source and re-encrypt for destination
// SLOW PATH: Decrypt source and re-encrypt for destination
glog . V ( 2 ) . Infof ( "Using slow path: decrypt/re-encrypt for %s" , r . URL . Path )
return s3a . copyChunksWithSSEKMSReencryption ( entry , destKeyID , encryptionContext , bucketKeyEnabled , r . URL . Path , bucket )
glog . V ( 2 ) . Infof ( "Using slow path: decrypt/re-encrypt for %s" , dst Path)
return s3a . copyChunksWithSSEKMSReencryption ( entry , destKeyID , encryptionContext , bucketKeyEnabled , dst Path, bucket )
default :
default :
return nil , nil , fmt . Errorf ( "unknown SSE-KMS copy strategy: %v" , strategy )
return nil , nil , fmt . Errorf ( "unknown SSE-KMS copy strategy: %v" , strategy )