|
Line 0
Link Here
|
|
|
1 |
commit 7fb3b7bf1a1869a52cf59ee3eb607d318e97265c |
| 2 |
Author: John W. O'Brien <john@saltant.com> |
| 3 |
Date: Mon Jul 27 14:56:02 2020 -0400 |
| 4 |
|
| 5 |
Support PyCryptodome as alternative to PyCrypto |
| 6 |
|
| 7 |
--- rauth/oauth.py.orig 2015-11-05 16:01:31 UTC |
| 8 |
+++ rauth/oauth.py |
| 9 |
@@ -171,7 +171,8 @@ class RsaSha1Signature(SignatureMethod): |
| 10 |
from Crypto.Signature import PKCS1_v1_5 as p |
| 11 |
self.RSA, self.SHA, self.PKCS1_v1_5 = r, s, p |
| 12 |
except ImportError: # pragma: no cover |
| 13 |
- raise NotImplementedError('PyCrypto is required for ' + self.NAME) |
| 14 |
+ raise NotImplementedError('PyCrypto(dome) is required for ' |
| 15 |
+ + self.NAME) |
| 16 |
|
| 17 |
def sign(self, |
| 18 |
consumer_secret, |
| 19 |
@@ -208,7 +209,9 @@ class RsaSha1Signature(SignatureMethod): |
| 20 |
# resolve the key |
| 21 |
if is_basestring(consumer_secret): |
| 22 |
consumer_secret = self.RSA.importKey(consumer_secret) |
| 23 |
- if not isinstance(consumer_secret, self.RSA._RSAobj): |
| 24 |
+ valid_cls = (getattr(self.RSA, '_RSAobj', False) |
| 25 |
+ or getattr(self.RSA, 'RsaKey', False)) |
| 26 |
+ if not (valid_cls and isinstance(consumer_secret, valid_cls)): |
| 27 |
raise ValueError('invalid consumer_secret') |
| 28 |
|
| 29 |
# hash the string with RSA-SHA1 |