From d9ff221a9165eb645f64fa03893cc9b59599469f Mon Sep 17 00:00:00 2001 From: David Gouldin Date: Mon, 12 Mar 2012 21:35:35 -0700 Subject: Fixing a couple of bugs in RSA signing. --- oauthlib/oauth.py | 3 +++ oauthlib/signature.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/oauthlib/oauth.py b/oauthlib/oauth.py index 847ec0a..11850db 100644 --- a/oauthlib/oauth.py +++ b/oauthlib/oauth.py @@ -37,6 +37,9 @@ class OAuthClient(object): self.rsa_key = rsa_key self.verifier = verifier + if self.signature_method == SIGNATURE_RSA and self.rsa_key is None: + raise ValueError('rsa_key is required when using RSA signature method.') + def get_oauth_signature(self, uri, http_method=u'GET', body=None, authorization_header=None): """Get an OAuth signature to be used in signing a request""" diff --git a/oauthlib/signature.py b/oauthlib/signature.py index b1c5223..1499dfa 100644 --- a/oauthlib/signature.py +++ b/oauthlib/signature.py @@ -137,7 +137,7 @@ def sign_rsa_sha1(base_string, rsa_private_key): from Crypto.Signature import PKCS1_v1_5 from Crypto.Hash import SHA - key = RSA.importKey(private_rsa) + key = RSA.importKey(rsa_private_key) h = SHA.new(base_string) p = PKCS1_v1_5.new(key) return binascii.b2a_base64(p.sign(h))[:-1].decode('utf-8') -- cgit v1.2.1