mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
Replacing fastsha256 with crypto/sha256 package from golang standard package (#1584)
This commit is contained in:
parent
b044336329
commit
26e2c4bf4d
@ -19,13 +19,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
fastSha256 "github.com/minio/minio/pkg/crypto/sha256"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Verify if request has JWT.
|
// Verify if request has JWT.
|
||||||
@ -97,7 +96,7 @@ func getRequestAuthType(r *http.Request) authType {
|
|||||||
|
|
||||||
// sum256 calculate sha256 sum for an input byte array
|
// sum256 calculate sha256 sum for an input byte array
|
||||||
func sum256(data []byte) []byte {
|
func sum256(data []byte) []byte {
|
||||||
hash := fastSha256.New()
|
hash := sha256.New()
|
||||||
hash.Write(data)
|
hash.Write(data)
|
||||||
return hash.Sum(nil)
|
return hash.Sum(nil)
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -29,8 +30,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fastSha256 "github.com/minio/minio/pkg/crypto/sha256"
|
|
||||||
|
|
||||||
mux "github.com/gorilla/mux"
|
mux "github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -574,7 +573,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
|
|
||||||
// Start writing in a routine.
|
// Start writing in a routine.
|
||||||
go func() {
|
go func() {
|
||||||
shaWriter := fastSha256.New()
|
shaWriter := sha256.New()
|
||||||
multiWriter := io.MultiWriter(shaWriter, writer)
|
multiWriter := io.MultiWriter(shaWriter, writer)
|
||||||
if _, cerr := io.CopyN(multiWriter, r.Body, size); cerr != nil {
|
if _, cerr := io.CopyN(multiWriter, r.Body, size); cerr != nil {
|
||||||
errorIf(cerr, "Unable to read HTTP body.", nil)
|
errorIf(cerr, "Unable to read HTTP body.", nil)
|
||||||
@ -719,7 +718,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http
|
|||||||
|
|
||||||
// Start writing in a routine.
|
// Start writing in a routine.
|
||||||
go func() {
|
go func() {
|
||||||
shaWriter := fastSha256.New()
|
shaWriter := sha256.New()
|
||||||
multiWriter := io.MultiWriter(shaWriter, writer)
|
multiWriter := io.MultiWriter(shaWriter, writer)
|
||||||
if _, err = io.CopyN(multiWriter, r.Body, size); err != nil {
|
if _, err = io.CopyN(multiWriter, r.Body, size); err != nil {
|
||||||
errorIf(err, "Unable to read HTTP body.", nil)
|
errorIf(err, "Unable to read HTTP body.", nil)
|
||||||
|
BIN
pkg/.DS_Store
vendored
Normal file
BIN
pkg/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
pkg/crypto/sha1/sha1_sse3_amd64.syso
Normal file
BIN
pkg/crypto/sha1/sha1_sse3_amd64.syso
Normal file
Binary file not shown.
@ -18,13 +18,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
fastSha256 "github.com/minio/minio/pkg/crypto/sha256"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// isValidRegion - verify if incoming region value is valid with configured Region.
|
// isValidRegion - verify if incoming region value is valid with configured Region.
|
||||||
@ -42,7 +41,7 @@ func isValidRegion(reqRegion string, confRegion string) bool {
|
|||||||
|
|
||||||
// sumHMAC calculate hmac between two input byte array.
|
// sumHMAC calculate hmac between two input byte array.
|
||||||
func sumHMAC(key []byte, data []byte) []byte {
|
func sumHMAC(key []byte, data []byte) []byte {
|
||||||
hash := hmac.New(fastSha256.New, key)
|
hash := hmac.New(sha256.New, key)
|
||||||
hash.Write(data)
|
hash.Write(data)
|
||||||
return hash.Sum(nil)
|
return hash.Sum(nil)
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -33,8 +34,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/crypto/sha256"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AWS Signature Version '4' constants.
|
// AWS Signature Version '4' constants.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user