From 439c0da5fac5b208fa42aa3bfd34d38fdba01b43 Mon Sep 17 00:00:00 2001 From: blacktemplar Date: Mon, 6 Apr 2020 12:28:47 +0200 Subject: [PATCH 1/3] make own module --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2dbb7f7..bda1899 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/go-fed/httpsig +module github.com/blacktemplar/httpsig require ( golang.org/x/crypto v0.0.0-20180527072434-ab813273cd59 From eddf81763d34344770b046b81f8da94df527bd80 Mon Sep 17 00:00:00 2001 From: blacktemplar Date: Tue, 7 Apr 2020 13:03:35 +0200 Subject: [PATCH 2/3] fix bug --- digest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digest.go b/digest.go index bf9e3a9..40caf8d 100644 --- a/digest.go +++ b/digest.go @@ -14,7 +14,7 @@ type DigestAlgorithm string const ( DigestSha256 DigestAlgorithm = "SHA-256" - DigestSha512 = "SHA-512" + DigestSha512 DigestAlgorithm = "SHA-512" ) var digestToDef = map[DigestAlgorithm]crypto.Hash{ From 06307a5a75f7741fff9bef2ee531f26f772691e4 Mon Sep 17 00:00:00 2001 From: blacktemplar Date: Wed, 15 Apr 2020 17:11:39 +0200 Subject: [PATCH 3/3] add getter in verifier for signature, created, and expires --- go.mod | 2 ++ httpsig.go | 6 ++++++ verifying.go | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/go.mod b/go.mod index bda1899..ed03218 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/blacktemplar/httpsig +go 1.14 + require ( golang.org/x/crypto v0.0.0-20180527072434-ab813273cd59 golang.org/x/sys v0.0.0-20180525142821-c11f84a56e43 diff --git a/httpsig.go b/httpsig.go index c5c57d8..07eff0e 100644 --- a/httpsig.go +++ b/httpsig.go @@ -192,6 +192,12 @@ type Verifier interface { // using an RSA based algorithm, then the public key is expected to be // of type *rsa.PublicKey. Verify(pKey crypto.PublicKey, algo Algorithm) error + // Gets the parsed Signature + Signature() string + // Gets the parsed Created value or 0 if no created value was given + Created() int64 + // Gets the parsed Expires value or 0 if no expires value was given + Expires() int64 } const ( diff --git a/verifying.go b/verifying.go index 7b827f3..754bded 100644 --- a/verifying.go +++ b/verifying.go @@ -23,6 +23,18 @@ type verifier struct { sigStringFn func(http.Header, []string, int64, int64) (string, error) } +func (v *verifier) Signature() string { + return v.signature +} + +func (v *verifier) Created() int64 { + return v.created +} + +func (v *verifier) Expires() int64 { + return v.expires +} + func newVerifier(h http.Header, sigStringFn func(http.Header, []string, int64, int64) (string, error)) (*verifier, error) { scheme, s, err := getSignatureScheme(h) if err != nil {