mirror of https://github.com/docker/docs.git
fix hash compare on verfy to be bytewise
Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
This commit is contained in:
parent
c0b0593247
commit
6ffcb134d7
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
|
||||
"crypto/subtle"
|
||||
"github.com/Sirupsen/logrus"
|
||||
notaryclient "github.com/docker/notary/client"
|
||||
"github.com/docker/notary/pkg/passphrase"
|
||||
|
@ -257,9 +258,10 @@ func verify(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
// Create hasher and hash data
|
||||
stdinHash := fmt.Sprintf("sha256:%x", sha256.Sum256(payload))
|
||||
serverHash := fmt.Sprintf("sha256:%s", target.Hashes["sha256"])
|
||||
if stdinHash != serverHash {
|
||||
stdinHash := sha256.Sum256(payload)
|
||||
serverHash := target.Hashes["sha256"]
|
||||
|
||||
if subtle.ConstantTimeCompare(stdinHash[:], serverHash) == 0 {
|
||||
logrus.Error("notary: data not present in the trusted collection.")
|
||||
os.Exit(1)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue