Attempt 2 at fixing crypto
This commit is contained in:
pare
ff160ec401
commit
87630e66e4
S'han modificat 1 arxius amb 7 adicions i 2 eliminacions
|
@ -27,6 +27,7 @@ try:
|
||||||
import cryptography
|
import cryptography
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives.asymmetric import ec
|
from cryptography.hazmat.primitives.asymmetric import ec
|
||||||
|
from cryptography.hazmat.primitives import serialization
|
||||||
except:
|
except:
|
||||||
IMPL_HAS_CRYPTO = False
|
IMPL_HAS_CRYPTO = False
|
||||||
|
|
||||||
|
@ -2588,8 +2589,12 @@ class Mastodon:
|
||||||
|
|
||||||
push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend())
|
push_key_pair = ec.generate_private_key(ec.SECP256R1(), default_backend())
|
||||||
push_key_priv = push_key_pair.private_numbers().private_value
|
push_key_priv = push_key_pair.private_numbers().private_value
|
||||||
if bigger_version(cryptography.__version__, "2.5.0") == cryptography.__version__:
|
|
||||||
push_key_pub = push_key_pair.public_key().public_numbers().public_bytes()
|
crypto_ver = cryptography.__version__
|
||||||
|
if len(crypto_ver) > 5:
|
||||||
|
crypto_ver += ".0"
|
||||||
|
if bigger_version(crypto_ver, "2.5.0") == crypto_ver:
|
||||||
|
push_key_pub = push_key_pair.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint)
|
||||||
else:
|
else:
|
||||||
push_key_pub = push_key_pair.public_key().public_numbers().encode_point()
|
push_key_pub = push_key_pair.public_key().public_numbers().encode_point()
|
||||||
push_shared_secret = os.urandom(16)
|
push_shared_secret = os.urandom(16)
|
||||||
|
|
Loading…
Referencia en una nova incidència