forked from TrueCloudLab/frostfs-api-go
service/signature: Rename interface methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
746419e85f
commit
2ccfe34a20
3 changed files with 8 additions and 8 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
type DataSource interface {
|
||||
ReadSignedData([]byte) ([]byte, error)
|
||||
SignedDataLength() int
|
||||
SignedDataSize() int
|
||||
}
|
||||
|
||||
type DataWithSignature interface {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
)
|
||||
|
||||
type SignedRequest interface {
|
||||
Body() DataSource
|
||||
MetaHeader() DataSource
|
||||
RequestBody() DataSource
|
||||
RequestMetaHeader() DataSource
|
||||
OriginVerificationHeader() DataSource
|
||||
|
||||
SetBodySignatureWithKey(key, sig []byte)
|
||||
|
@ -27,12 +27,12 @@ func SignRequest(key *ecdsa.PrivateKey, src SignedRequest) error {
|
|||
}
|
||||
|
||||
// sign body
|
||||
if err := SignDataWithHandler(key, src.Body(), src.SetBodySignatureWithKey); err != nil {
|
||||
if err := SignDataWithHandler(key, src.RequestBody(), src.SetBodySignatureWithKey); err != nil {
|
||||
return errors.Wrap(err, "could not sign body")
|
||||
}
|
||||
|
||||
// sign meta
|
||||
if err := SignDataWithHandler(key, src.Body(), src.SetMetaSignatureWithKey); err != nil {
|
||||
if err := SignDataWithHandler(key, src.RequestMetaHeader(), src.SetMetaSignatureWithKey); err != nil {
|
||||
return errors.Wrap(err, "could not sign meta header")
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ func SignRequest(key *ecdsa.PrivateKey, src SignedRequest) error {
|
|||
|
||||
func VerifyRequest(src SignedRequest) error {
|
||||
// verify body signature
|
||||
if err := VerifyDataWithSource(src.Body(), src.BodySignatureWithKey); err != nil {
|
||||
if err := VerifyDataWithSource(src.RequestBody(), src.BodySignatureWithKey); err != nil {
|
||||
return errors.Wrap(err, "could not verify body")
|
||||
}
|
||||
|
||||
// verify meta header
|
||||
if err := VerifyDataWithSource(src.MetaHeader(), src.MetaSignatureWithKey); err != nil {
|
||||
if err := VerifyDataWithSource(src.RequestMetaHeader(), src.MetaSignatureWithKey); err != nil {
|
||||
return errors.Wrap(err, "could not verify meta header")
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ func dataForSignature(src DataSource) ([]byte, error) {
|
|||
|
||||
buf := bytesPool.Get().([]byte)
|
||||
|
||||
if size := src.SignedDataLength(); size < 0 {
|
||||
if size := src.SignedDataSize(); size < 0 {
|
||||
return nil, errors.New("negative length")
|
||||
} else if size <= cap(buf) {
|
||||
buf = buf[:size]
|
||||
|
|
Loading…
Reference in a new issue