aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2021-03-17 22:22:49 +0100
committerGitHub <noreply@github.com>2021-03-17 22:22:49 +0100
commitf4372710bfa57abd9ae22d8de6d22c38c25b01eb (patch)
treec1a7615d560df8389ecdf556275b04347709bdd5 /test
parentf39477bbd57d866daa505185e5c4803338ff0955 (diff)
downloadsyncthing-f4372710bfa57abd9ae22d8de6d22c38c25b01eb.tar.gz
syncthing-f4372710bfa57abd9ae22d8de6d22c38c25b01eb.zip
all: Remove crypto/md5 (#7493)
This is a mostly pointless change to make security scanners and static analysis tools happy, as they all hate seeing md5. None of our md5 uses were security relevant, but still. Only visible effect of this change is that our temp file names for very long file names become slightly longer than they were previously...
Diffstat (limited to 'test')
-rw-r--r--test/util.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/test/util.go b/test/util.go
index 8865619ac..5612cdf07 100644
--- a/test/util.go
+++ b/test/util.go
@@ -9,7 +9,6 @@
package integration
import (
- "crypto/md5"
cr "crypto/rand"
"errors"
"fmt"
@@ -27,6 +26,7 @@ import (
"unicode"
"github.com/syncthing/syncthing/lib/rc"
+ "github.com/syncthing/syncthing/lib/sha256"
)
func init() {
@@ -395,7 +395,7 @@ type fileInfo struct {
name string
mode os.FileMode
mod int64
- hash [16]byte
+ hash [sha256.Size]byte
size int64
}
@@ -442,11 +442,7 @@ func startWalker(dir string, res chan<- fileInfo, abort <-chan struct{}) chan er
if err != nil {
return err
}
- h := md5.New()
- h.Write([]byte(tgt))
- hash := h.Sum(nil)
-
- copy(f.hash[:], hash)
+ f.hash = sha256.Sum256([]byte(tgt))
} else if info.IsDir() {
f = fileInfo{
name: rn,
@@ -463,7 +459,7 @@ func startWalker(dir string, res chan<- fileInfo, abort <-chan struct{}) chan er
mod: info.ModTime().Unix(),
size: info.Size(),
}
- sum, err := md5file(path)
+ sum, err := sha256file(path)
if err != nil {
return err
}
@@ -490,14 +486,14 @@ func startWalker(dir string, res chan<- fileInfo, abort <-chan struct{}) chan er
return errc
}
-func md5file(fname string) (hash [16]byte, err error) {
+func sha256file(fname string) (hash [sha256.Size]byte, err error) {
f, err := os.Open(fname)
if err != nil {
return
}
defer f.Close()
- h := md5.New()
+ h := sha256.New()
io.Copy(h, f)
hb := h.Sum(nil)
copy(hash[:], hb)