aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-10-12 00:27:52 +0200
committerLorenz Diener <[email protected]>2019-10-12 00:27:52 +0200
commit87630e66e4990c1087edabb6bf31291be49942da (patch)
tree80357d038f9397581761a45efffc4006702271a3 /mastodon/Mastodon.py
parentff160ec40180608e223153ca60bb41cc42fbb85c (diff)
downloadmastodon.py-87630e66e4990c1087edabb6bf31291be49942da.tar.gz
Attempt 2 at fixing crypto
Diffstat (limited to 'mastodon/Mastodon.py')
-rw-r--r--mastodon/Mastodon.py9
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
30except: 31except:
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)
Powered by cgit v1.2.3 (git 2.41.0)