signature: Use a layered approach for signature verification.

Signature calculation has now moved out from being a package to
top-level as a layered mechanism.

In case of payload calculation with body, go-routines are initiated
to simultaneously write and calculate shasum. Errors are sent
over the writer so that the lower layer removes the temporary files
properly.
This commit is contained in:
Harshavardhana
2016-03-12 16:08:15 -08:00
parent 1b0bc814c4
commit 9dca46e156
39 changed files with 572 additions and 739 deletions
+8 -9
View File
@@ -19,18 +19,17 @@ package main
import (
"encoding/base64"
"strings"
"github.com/minio/minio/pkg/probe"
)
// isValidMD5 - verify if valid md5
func isValidMD5(md5 string) bool {
if md5 == "" {
return true
// checkValidMD5 - verify if valid md5, returns md5 in bytes.
func checkValidMD5(md5 string) ([]byte, *probe.Error) {
md5Bytes, e := base64.StdEncoding.DecodeString(strings.TrimSpace(md5))
if e != nil {
return nil, probe.NewError(e)
}
_, err := base64.StdEncoding.DecodeString(strings.TrimSpace(md5))
if err != nil {
return false
}
return true
return md5Bytes, nil
}
/// http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadingObjects.html