From 0e2c76148169c7c9897f44c644f536f43405e49b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 11 Jan 2021 16:50:04 +0300 Subject: [PATCH] [#290] object/rangehash: Add salt to RangeHashPrm structure Add binary salt field to RangeHashPrm struct. Implement field setter. Set salt from the request in v2 service. Signed-off-by: Leonard Lyubich --- pkg/services/object/get/prm.go | 7 +++++++ pkg/services/object/get/v2/util.go | 1 + 2 files changed, 8 insertions(+) diff --git a/pkg/services/object/get/prm.go b/pkg/services/object/get/prm.go index 8d859df0e..7ee493549 100644 --- a/pkg/services/object/get/prm.go +++ b/pkg/services/object/get/prm.go @@ -28,6 +28,8 @@ type RangeHashPrm struct { hashGen func() hash.Hash rngs []*objectSDK.Range + + salt []byte } // HeadPrm groups parameters of Head service call. @@ -88,6 +90,11 @@ func (p *RangeHashPrm) SetHashGenerator(v func() hash.Hash) { p.hashGen = v } +// SetSalt sets binary salt to XOR object's payload ranges before hash calculation. +func (p *RangeHashPrm) SetSalt(salt []byte) { + p.salt = salt +} + // SetCommonParameters sets common parameters of the operation. func (p *commonPrm) SetCommonParameters(common *util.CommonPrm) { p.common = common diff --git a/pkg/services/object/get/v2/util.go b/pkg/services/object/get/v2/util.go index 4515c3914..a40a3bf54 100644 --- a/pkg/services/object/get/v2/util.go +++ b/pkg/services/object/get/v2/util.go @@ -83,6 +83,7 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran } p.SetRangeList(rngs) + p.SetSalt(body.GetSalt()) switch t := body.GetType(); t { default: