From 3a7f6701d8e44585798faa6daeef2bcc7c3bcf6e Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 11 Jan 2021 16:50:49 +0300 Subject: [PATCH] [#290] object/rangehash: Apply salt to data before hashing Signed-off-by: Leonard Lyubich --- pkg/services/object/get/get.go | 3 ++- pkg/services/object/get/util.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/services/object/get/get.go b/pkg/services/object/get/get.go index 1e0ae0110..43e7d50b6 100644 --- a/pkg/services/object/get/get.go +++ b/pkg/services/object/get/get.go @@ -4,6 +4,7 @@ import ( "context" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" + "github.com/nspcc-dev/neofs-node/pkg/util" "go.uber.org/zap" ) @@ -33,7 +34,7 @@ func (s *Service) GetRangeHash(ctx context.Context, prm RangeHashPrm) (*RangeHas rngPrm.SetRange(rng) rngPrm.SetChunkWriter(&hasherWrapper{ - hash: h, + hash: util.NewSaltingWriter(h, prm.salt), }) if err := s.GetRange(ctx, rngPrm); err != nil { diff --git a/pkg/services/object/get/util.go b/pkg/services/object/get/util.go index 82a20ec1b..4c6a63593 100644 --- a/pkg/services/object/get/util.go +++ b/pkg/services/object/get/util.go @@ -2,7 +2,7 @@ package getsvc import ( "crypto/ecdsa" - "hash" + "io" "github.com/nspcc-dev/neofs-api-go/pkg/client" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" @@ -40,7 +40,7 @@ type partWriter struct { } type hasherWrapper struct { - hash hash.Hash + hash io.Writer } func NewSimpleObjectWriter() *SimpleObjectWriter {