diff options
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 2a9833b..a3903df 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -24,6 +24,7 @@ import hashlib | |||
24 | 24 | ||
25 | IMPL_HAS_CRYPTO = True | 25 | IMPL_HAS_CRYPTO = True |
26 | try: | 26 | try: |
27 | import cryptography | ||
27 | from cryptography.hazmat.backends import default_backend | 28 | from cryptography.hazmat.backends import default_backend |
28 | from cryptography.hazmat.primitives.asymmetric import ec | 29 | from cryptography.hazmat.primitives.asymmetric import ec |
29 | except: | 30 | except: |
@@ -2587,7 +2588,10 @@ class Mastodon: | |||
2587 | 2588 | ||
2588 | push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend()) | 2589 | push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend()) |
2589 | push_key_priv = push_key_pair.private_numbers().private_value | 2590 | push_key_priv = push_key_pair.private_numbers().private_value |
2590 | push_key_pub = push_key_pair.public_key().public_numbers().encode_point() | 2591 | if bigger_version(cryptography.__version__, "2.5.0") == cryptography.__version__: |
2592 | push_key_pub = push_key_pair.public_key().public_numbers().public_bytes() | ||
2593 | else: | ||
2594 | push_key_pub = push_key_pair.public_key().public_numbers().encode_point() | ||
2591 | push_shared_secret = os.urandom(16) | 2595 | push_shared_secret = os.urandom(16) |
2592 | 2596 | ||
2593 | priv_dict = { | 2597 | priv_dict = { |