Fix SSE-C checksums (#19896)

Compression will be disabled by default if SSE-C is specified. So we can still honor SSE-C.
This commit is contained in:
Klaus Post
2024-06-10 08:31:51 -07:00
committed by GitHub
parent 6c7a21df6b
commit a2cab02554
20 changed files with 113 additions and 73 deletions

View File

@@ -755,7 +755,7 @@ type ObjReaderFn func(inputReader io.Reader, h http.Header, cleanupFns ...func()
// are called on Close() in FIFO order as passed in ObjReadFn(). NOTE: It is
// assumed that clean up functions do not panic (otherwise, they may
// not all run!).
func NewGetObjectReader(rs *HTTPRangeSpec, oi ObjectInfo, opts ObjectOptions) (
func NewGetObjectReader(rs *HTTPRangeSpec, oi ObjectInfo, opts ObjectOptions, h http.Header) (
fn ObjReaderFn, off, length int64, err error,
) {
if opts.CheckPrecondFn != nil && opts.CheckPrecondFn(oi) {
@@ -810,7 +810,9 @@ func NewGetObjectReader(rs *HTTPRangeSpec, oi ObjectInfo, opts ObjectOptions) (
return b, nil
}
if isEncrypted {
decrypt = oi.compressionIndexDecrypt
decrypt = func(b []byte) ([]byte, error) {
return oi.compressionIndexDecrypt(b, h)
}
}
// In case of range based queries on multiparts, the offset and length are reduced.
off, decOff, firstPart, decryptSkip, seqNum = getCompressedOffsets(oi, off, decrypt)
@@ -982,8 +984,8 @@ func compressionIndexEncrypter(key crypto.ObjectKey, input func() []byte) func()
}
// compressionIndexDecrypt reverses compressionIndexEncrypter.
func (o *ObjectInfo) compressionIndexDecrypt(input []byte) ([]byte, error) {
return o.metadataDecrypter()("compression-index", input)
func (o *ObjectInfo) compressionIndexDecrypt(input []byte, h http.Header) ([]byte, error) {
return o.metadataDecrypter(h)("compression-index", input)
}
// SealMD5CurrFn seals md5sum with object encryption key and returns sealed