From 311bdd186bc0ba1da029533af95f4b87b6e2417d Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Fri, 10 Nov 2023 09:13:52 +0900 Subject: [PATCH] feat: change the default checksum algorithm to sha256 (#2445) --- pkg/config/registry/checksum.go | 2 +- pkg/controller/updatechecksum/update.go | 6 +++--- pkg/installpackage/checksum.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/config/registry/checksum.go b/pkg/config/registry/checksum.go index 63cead1a1..197a1238e 100644 --- a/pkg/config/registry/checksum.go +++ b/pkg/config/registry/checksum.go @@ -36,7 +36,7 @@ func (c *Checksum) GetEnabled() bool { func (c *Checksum) GetAlgorithm() string { if !c.GetEnabled() { - return "sha512" + return "sha256" } return c.Algorithm } diff --git a/pkg/controller/updatechecksum/update.go b/pkg/controller/updatechecksum/update.go index ae6f049e7..26e0238d2 100644 --- a/pkg/controller/updatechecksum/update.go +++ b/pkg/controller/updatechecksum/update.go @@ -126,8 +126,8 @@ func (c *Controller) updateRegistry(ctx context.Context, logE *logrus.Entry, che } defer ghContentFile.Close() content := ghContentFile.Reader() - algorithm := "sha512" - chk, err := checksum.CalculateReader(content, "sha512") + algorithm := "sha256" + chk, err := checksum.CalculateReader(content, algorithm) if err != nil { return fmt.Errorf("calculate a checksum of Registry: %w", err) } @@ -322,7 +322,7 @@ func (c *Controller) dlAssetAndGetChecksum(ctx context.Context, logE *logrus.Ent return fmt.Errorf("download an asset: %w", err) } defer file.Close() - algorithm := "sha512" + algorithm := "sha256" fields["algorithm"] = algorithm chk, err := checksum.CalculateReader(file, algorithm) if err != nil { diff --git a/pkg/installpackage/checksum.go b/pkg/installpackage/checksum.go index c1e2e74c8..742907f69 100644 --- a/pkg/installpackage/checksum.go +++ b/pkg/installpackage/checksum.go @@ -144,7 +144,7 @@ func (is *Installer) verifyChecksum(ctx context.Context, logE *logrus.Entry, par checksums.Set(checksumID, chksum) } - algorithm := "sha512" + algorithm := "sha256" if chksum != nil { algorithm = chksum.Algorithm }