From 97424f008869d0635e44464a74c83841f476999f Mon Sep 17 00:00:00 2001 From: Dave Grijalva Date: Tue, 17 Apr 2012 22:50:26 -0700 Subject: [PATCH] it works --- jwt.go | 2 +- rs256.go | 4 ++-- rs256_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jwt.go b/jwt.go index 0b9347f..9931179 100644 --- a/jwt.go +++ b/jwt.go @@ -63,7 +63,7 @@ func Parse(tokenString string, keyFunc func(*Token)([]byte, error)) (token *Toke } // Perform validation - if err = token.Method.Verify(strings.Join(parts[0:1], "."), parts[2], key); err == nil { + if err = token.Method.Verify(strings.Join(parts[0:2], "."), parts[2], key); err == nil { token.Valid = true } diff --git a/rs256.go b/rs256.go index 7f4be64..11340bf 100644 --- a/rs256.go +++ b/rs256.go @@ -7,7 +7,7 @@ import ( "crypto" "crypto/x509" "crypto/rsa" - _ "crypto/sha256" + "crypto/sha256" ) type SigningMethodRS256 struct {} @@ -35,7 +35,7 @@ func (m *SigningMethodRS256) Verify(signingString, signature string, key []byte) var parsedKey interface{} if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err == nil { if rsaKey, ok := parsedKey.(*rsa.PublicKey); ok { - hasher := crypto.SHA256.New() + hasher := sha256.New() hasher.Write([]byte(signingString)) err = rsa.VerifyPKCS1v15(rsaKey, crypto.SHA256, hasher.Sum(nil), sig) diff --git a/rs256_test.go b/rs256_test.go index 41d2598..c829bfb 100644 --- a/rs256_test.go +++ b/rs256_test.go @@ -39,7 +39,7 @@ func TestRS256Verify(t *testing.T) { parts := strings.Split(data.tokenString, ".") method, _ := GetSigningMethod("RS256") - err := method.Verify(strings.Join(parts[0:1], "."), parts[2], key) + err := method.Verify(strings.Join(parts[0:2], "."), parts[2], key) if data.valid && err != nil { t.Errorf("[%v] Error while verifying key: %v", data.name, err) }