diff options
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index a3903df..1d41551 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -27,6 +27,7 @@ try: | |||
27 | import cryptography | 27 | import cryptography |
28 | from cryptography.hazmat.backends import default_backend | 28 | from cryptography.hazmat.backends import default_backend |
29 | from cryptography.hazmat.primitives.asymmetric import ec | 29 | from cryptography.hazmat.primitives.asymmetric import ec |
30 | from cryptography.hazmat.primitives import serialization | ||
30 | except: | 31 | except: |
31 | IMPL_HAS_CRYPTO = False | 32 | IMPL_HAS_CRYPTO = False |
32 | 33 | ||
@@ -2588,8 +2589,12 @@ class Mastodon: | |||
2588 | 2589 | ||
2589 | push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend()) | 2590 | push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend()) |
2590 | push_key_priv = push_key_pair.private_numbers().private_value | 2591 | push_key_priv = push_key_pair.private_numbers().private_value |
2591 | if bigger_version(cryptography.__version__, "2.5.0") == cryptography.__version__: | 2592 | |
2592 | push_key_pub = push_key_pair.public_key().public_numbers().public_bytes() | 2593 | crypto_ver = cryptography.__version__ |
2594 | if len(crypto_ver) > 5: | ||
2595 | crypto_ver += ".0" | ||
2596 | if bigger_version(crypto_ver, "2.5.0") == crypto_ver: | ||
2597 | push_key_pub = push_key_pair.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint) | ||
2593 | else: | 2598 | else: |
2594 | push_key_pub = push_key_pair.public_key().public_numbers().encode_point() | 2599 | push_key_pub = push_key_pair.public_key().public_numbers().encode_point() |
2595 | push_shared_secret = os.urandom(16) | 2600 | push_shared_secret = os.urandom(16) |