object: implement SignedData() and AddSignKey() methods on IntegrityHeader

This commit is contained in:
Leonard Lyubich 2020-05-18 13:44:32 +03:00
parent ab796b81d2
commit 96a6bb4842
4 changed files with 64 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package object
import (
"crypto/ecdsa"
"encoding/binary"
"io"
@ -259,3 +260,13 @@ func addressSize(addr Address) int {
func addressBytes(addr Address) []byte {
return append(addr.CID.Bytes(), addr.ObjectID.Bytes()...)
}
// SignedData returns the result of the ChecksumSignature field getter.
func (m IntegrityHeader) SignedData() ([]byte, error) {
return m.GetHeadersChecksum(), nil
}
// AddSignKey calls the ChecksumSignature field setter with signature argument.
func (m *IntegrityHeader) AddSignKey(sign []byte, _ *ecdsa.PublicKey) {
m.SetSignature(sign)
}