[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-11 16:50:04 +03:00 committed by Alex Vanin
parent ba03f46316
commit 0e2c761481
2 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -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: