Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PyCryptodome as alternative to PyCrypto #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions rauth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def __init__(self):
from Crypto.Signature import PKCS1_v1_5 as p
self.RSA, self.SHA, self.PKCS1_v1_5 = r, s, p
except ImportError: # pragma: no cover
raise NotImplementedError('PyCrypto is required for ' + self.NAME)
raise NotImplementedError('PyCrypto(dome) is required for '
+ self.NAME)

def sign(self,
consumer_secret,
Expand Down Expand Up @@ -208,7 +209,9 @@ def sign(self,
# resolve the key
if is_basestring(consumer_secret):
consumer_secret = self.RSA.importKey(consumer_secret)
if not isinstance(consumer_secret, self.RSA._RSAobj):
valid_cls = (getattr(self.RSA, '_RSAobj', False)
or getattr(self.RSA, 'RsaKey', False))
if not (valid_cls and isinstance(consumer_secret, valid_cls)):
raise ValueError('invalid consumer_secret')

# hash the string with RSA-SHA1
Expand Down