From 2ccfe34a20493729435c260fbc2a86d9cf46d28f Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 12 Aug 2020 18:20:04 +0300 Subject: [PATCH] service/signature: Rename interface methods Signed-off-by: Leonard Lyubich --- service/signature/data.go | 2 +- service/signature/request.go | 12 ++++++------ service/signature/util.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/service/signature/data.go b/service/signature/data.go index f42b06f2..00d591e2 100644 --- a/service/signature/data.go +++ b/service/signature/data.go @@ -8,7 +8,7 @@ import ( type DataSource interface { ReadSignedData([]byte) ([]byte, error) - SignedDataLength() int + SignedDataSize() int } type DataWithSignature interface { diff --git a/service/signature/request.go b/service/signature/request.go index 9dd34a96..fc72be75 100644 --- a/service/signature/request.go +++ b/service/signature/request.go @@ -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") } diff --git a/service/signature/util.go b/service/signature/util.go index c86fd00a..9033eab3 100644 --- a/service/signature/util.go +++ b/service/signature/util.go @@ -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]