Index: charm/repo.go |
=== modified file 'charm/repo.go' |
--- charm/repo.go 2014-01-22 16:48:19 +0000 |
+++ charm/repo.go 2014-01-28 17:07:55 +0000 |
@@ -4,8 +4,6 @@ |
package charm |
import ( |
- "crypto/sha256" |
- "encoding/hex" |
"encoding/json" |
"fmt" |
"io" |
@@ -299,16 +297,11 @@ |
// verify returns an error unless a file exists at path with a hex-encoded |
// SHA256 matching digest. |
func verify(path, digest string) error { |
- f, err := os.Open(path) |
+ hash, _, err := utils.ReadFileSHA256(path) |
if err != nil { |
return err |
} |
- defer f.Close() |
- h := sha256.New() |
- if _, err := io.Copy(h, f); err != nil { |
- return err |
- } |
- if hex.EncodeToString(h.Sum(nil)) != digest { |
+ if hash != digest { |
return fmt.Errorf("bad SHA256 of %q", path) |
} |
return nil |