forked from TrueCloudLab/frostfs-api-go
object: implement signing payload methods on GetRequest message
This commit is contained in:
parent
78f435a905
commit
439221cea8
2 changed files with 59 additions and 6 deletions
|
@ -1,5 +1,9 @@
|
|||
package object
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// SignedData returns marshaled payload of the Put request.
|
||||
//
|
||||
// If payload is nil, ErrHeaderNotFound returns.
|
||||
|
@ -43,3 +47,39 @@ func (m PutRequest) SignedDataSize() int {
|
|||
|
||||
return r.Size()
|
||||
}
|
||||
|
||||
// SignedData returns marshaled Address field.
|
||||
//
|
||||
// Resulting error is always nil.
|
||||
func (m GetRequest) SignedData() ([]byte, error) {
|
||||
addr := m.GetAddress()
|
||||
|
||||
return append(
|
||||
addr.CID.Bytes(),
|
||||
addr.ObjectID.Bytes()...,
|
||||
), nil
|
||||
}
|
||||
|
||||
// ReadSignedData copies marshaled Address field to passed buffer.
|
||||
//
|
||||
// If the buffer size is insufficient, io.ErrUnexpectedEOF returns.
|
||||
func (m GetRequest) ReadSignedData(p []byte) error {
|
||||
addr := m.GetAddress()
|
||||
|
||||
if len(p) < addr.CID.Size()+addr.ObjectID.Size() {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
off := copy(p, addr.CID.Bytes())
|
||||
|
||||
copy(p[off:], addr.ObjectID.Bytes())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SignedDataSize returns the size of object address.
|
||||
func (m GetRequest) SignedDataSize() int {
|
||||
addr := m.GetAddress()
|
||||
|
||||
return addr.CID.Size() + addr.ObjectID.Size()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue