Browse Source

correct IV based on its position within that part, not its position in the entire object

pull/7481/head
chrislu 2 weeks ago
parent
commit
c28f3fdd66
  1. 10
      weed/s3api/s3api_object_handlers.go

10
weed/s3api/s3api_object_handlers.go

@ -1288,12 +1288,12 @@ func (s3a *S3ApiServer) decryptSSECChunkView(ctx context.Context, fileChunk *fil
return nil, fmt.Errorf("failed to fetch chunk view: %w", err)
}
// Calculate IV using both PartOffset and OffsetInChunk for CTR seek
// CTR mode allows seeking by adjusting the IV to any byte offset
absoluteOffset := ssecMetadata.PartOffset + chunkView.OffsetInChunk
// For multipart SSE-C, each part is encrypted independently from offset 0
// PartOffset tells us where this part sits in the final object, but encryption starts at 0
// Only use OffsetInChunk for IV adjustment, not PartOffset
var adjustedIV []byte
if absoluteOffset > 0 {
adjustedIV = adjustCTRIV(chunkIV, absoluteOffset)
if chunkView.OffsetInChunk > 0 {
adjustedIV = adjustCTRIV(chunkIV, chunkView.OffsetInChunk)
} else {
adjustedIV = chunkIV
}

Loading…
Cancel
Save