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"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"crypto/subtle"
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
notaryclient "github.com/docker/notary/client"
|
notaryclient "github.com/docker/notary/client"
|
||||||
"github.com/docker/notary/pkg/passphrase"
|
"github.com/docker/notary/pkg/passphrase"
|
||||||
|
@ -257,9 +258,10 @@ func verify(cmd *cobra.Command, args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create hasher and hash data
|
// Create hasher and hash data
|
||||||
stdinHash := fmt.Sprintf("sha256:%x", sha256.Sum256(payload))
|
stdinHash := sha256.Sum256(payload)
|
||||||
serverHash := fmt.Sprintf("sha256:%s", target.Hashes["sha256"])
|
serverHash := target.Hashes["sha256"]
|
||||||
if stdinHash != serverHash {
|
|
||||||
|
if subtle.ConstantTimeCompare(stdinHash[:], serverHash) == 0 {
|
||||||
logrus.Error("notary: data not present in the trusted collection.")
|
logrus.Error("notary: data not present in the trusted collection.")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue