change hashing algorithm to HMAC-SHA256-128 for kopia repo

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2026-09-24 16:57:39 +08:00
parent dfabab70bf
commit 0171e17b5c
3 changed files with 8 additions and 8 deletions
+1
View File
@@ -0,0 +1 @@
Fix issue #10576, change hashing algorithm to HMAC-SHA256-128 for kopia repo
@@ -26,15 +26,15 @@ import (
"github.com/kopia/kopia/repo/content"
"github.com/kopia/kopia/repo/encryption"
"github.com/kopia/kopia/repo/format"
"github.com/kopia/kopia/repo/hashing"
"github.com/kopia/kopia/repo/splitter"
"github.com/vmware-tanzu/velero/pkg/repository/udmrepo"
)
const (
DefaultCacheLimitMB = 5000
maxCacheDurationSecond = 30
DefaultCacheLimitMB = 5000
maxCacheDurationSecond = 30
defaultHashingAlgorithm = "HMAC-SHA256-128"
)
func setupLimits(ctx context.Context, flags map[string]string) throttling.Limits {
@@ -51,7 +51,7 @@ func setupLimits(ctx context.Context, flags map[string]string) throttling.Limits
func SetupNewRepositoryOptions(ctx context.Context, flags map[string]string) repo.NewRepositoryOptions {
return repo.NewRepositoryOptions{
BlockFormat: format.ContentFormat{
Hash: optionalHaveStringWithDefault(udmrepo.StoreOptionGenHashAlgo, flags, hashing.DefaultAlgorithm),
Hash: optionalHaveStringWithDefault(udmrepo.StoreOptionGenHashAlgo, flags, defaultHashingAlgorithm),
Encryption: optionalHaveStringWithDefault(udmrepo.StoreOptionGenEncryptAlgo, flags, encryption.DefaultAlgorithm),
},
@@ -24,7 +24,6 @@ import (
"github.com/kopia/kopia/repo/content"
"github.com/kopia/kopia/repo/encryption"
"github.com/kopia/kopia/repo/format"
"github.com/kopia/kopia/repo/hashing"
"github.com/kopia/kopia/repo/splitter"
"github.com/stretchr/testify/assert"
@@ -59,7 +58,7 @@ func TestSetupNewRepositoryOptions(t *testing.T) {
},
expected: repo.NewRepositoryOptions{
BlockFormat: format.ContentFormat{
Hash: hashing.DefaultAlgorithm,
Hash: defaultHashingAlgorithm,
Encryption: "fake-encrypt",
},
ObjectFormat: format.ObjectFormat{
@@ -74,7 +73,7 @@ func TestSetupNewRepositoryOptions(t *testing.T) {
},
expected: repo.NewRepositoryOptions{
BlockFormat: format.ContentFormat{
Hash: hashing.DefaultAlgorithm,
Hash: defaultHashingAlgorithm,
Encryption: encryption.DefaultAlgorithm,
},
ObjectFormat: format.ObjectFormat{
@@ -89,7 +88,7 @@ func TestSetupNewRepositoryOptions(t *testing.T) {
},
expected: repo.NewRepositoryOptions{
BlockFormat: format.ContentFormat{
Hash: hashing.DefaultAlgorithm,
Hash: defaultHashingAlgorithm,
Encryption: encryption.DefaultAlgorithm,
},
ObjectFormat: format.ObjectFormat{