diff --git a/weed/s3api/s3api_sse_s3_upload_test.go b/weed/s3api/s3api_sse_s3_upload_test.go index 7a7769396..a09104548 100644 --- a/weed/s3api/s3api_sse_s3_upload_test.go +++ b/weed/s3api/s3api_sse_s3_upload_test.go @@ -163,7 +163,7 @@ func TestHandleSSES3MultipartEncryptionFlow(t *testing.T) { plaintext := []byte("Test data for part 2 of multipart upload") // Calculate what the derived IV should be - expectedDerivedIV, _ := calculateIVWithOffset(baseIV, partOffset) + expectedDerivedIV, ivSkip := calculateIVWithOffset(baseIV, partOffset) // Simulate the upload by calling CreateSSES3EncryptedReaderWithBaseIV directly // (This is what handleSSES3MultipartEncryption does internally) @@ -211,6 +211,12 @@ func TestHandleSSES3MultipartEncryptionFlow(t *testing.T) { } stream := cipher.NewCTR(block, originalKey.IV) + + // Handle ivSkip for non-block-aligned offsets + if ivSkip > 0 { + skipDummy := make([]byte, ivSkip) + stream.XORKeyStream(skipDummy, skipDummy) + } stream.XORKeyStream(decryptedData, encryptedData) if !bytes.Equal(decryptedData, plaintext) {