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]