From 3097059f85ddd8b6661b00dacd5678974d932571 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 16 Nov 2020 17:33:04 +0300 Subject: [PATCH] [#199] sdk/client: Verify header signature in GetObjectHeader method Signed-off-by: Leonard Lyubich --- pkg/client/object.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/client/object.go b/pkg/client/object.go index 527a619..197fd93 100644 --- a/pkg/client/object.go +++ b/pkg/client/object.go @@ -569,7 +569,19 @@ func (c *Client) getObjectHeaderV2(ctx context.Context, p *ObjectHeaderParams, o return nil, errors.New("got nil instead of header with signature") } hdr = hdrWithSig.GetHeader() - // todo: check signature there + + if err := signer.VerifyDataWithSource( + signature.StableMarshalerWrapper{ + SM: hdrWithSig.GetHeader(), + }, + func() (key, sig []byte) { + s := hdrWithSig.GetSignature() + + return s.GetKey(), s.GetSign() + }, + ); err != nil { + return nil, errors.Wrap(err, "incorrect object header signature") + } default: panic(fmt.Sprintf("unexpected Head object type %T", v)) }