mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Return InvalidDigest when md5 sent by client is invalid (#5654)
This is to ensure proper compatibility with AWS S3, handle special cases where - Content-Md5 is set to empty - Content-Md5 is set to invalid
This commit is contained in:
committed by
Dee Koder
parent
9ede179a21
commit
3145462ad2
@@ -24,11 +24,16 @@ import (
|
||||
"github.com/minio/sha256-simd"
|
||||
)
|
||||
|
||||
// getSHA256Hash returns SHA-256 hash of given data.
|
||||
// getSHA256Hash returns SHA-256 hash in hex encoding of given data.
|
||||
func getSHA256Hash(data []byte) string {
|
||||
return hex.EncodeToString(getSHA256Sum(data))
|
||||
}
|
||||
|
||||
// getSHA256Hash returns SHA-256 sum of given data.
|
||||
func getSHA256Sum(data []byte) []byte {
|
||||
hash := sha256.New()
|
||||
hash.Write(data)
|
||||
return hex.EncodeToString(hash.Sum(nil))
|
||||
return hash.Sum(nil)
|
||||
}
|
||||
|
||||
// getMD5Sum returns MD5 sum of given data.
|
||||
@@ -38,7 +43,7 @@ func getMD5Sum(data []byte) []byte {
|
||||
return hash.Sum(nil)
|
||||
}
|
||||
|
||||
// getMD5Hash returns MD5 hash of given data.
|
||||
// getMD5Hash returns MD5 hash in hex encoding of given data.
|
||||
func getMD5Hash(data []byte) string {
|
||||
return hex.EncodeToString(getMD5Sum(data))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user