Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses new 42.0.1 version Cryptography Incompatible. #2337

Open
Ghawken opened this issue Jan 25, 2024 · 2 comments
Open

Uses new 42.0.1 version Cryptography Incompatible. #2337

Ghawken opened this issue Jan 25, 2024 · 2 comments
Labels

Comments

@Ghawken
Copy link

Ghawken commented Jan 25, 2024

Describe the bug

Hey! If haven't mentioned before well done on this library, it is very impressive and I am very successfully using it here https://www.indigodomo.com/pluginstore/283/ in replace of Karls (kw123) older indigo plugin (and with his blessing) I think you link karls plugin somewhere - that could be updated.

Anyway - new release of Cryptography library is leading to complete failure.

pip3 install pyatv

Automatically uses 42.0.1 Cryptography which has in the last 2 days been released and has a lot of breaking changes.
It appears incompatible with pyatv.

The Dist Wheel has these entries:

https://files.pythonhosted.org/packages/64/8f/149fed04fcd9fa709d0840cf191a4b91f4da74ee7b451bab5ba371cc07fc/pyatv-0.14.5-py3-none-any.whl.metadata

Requires-Dist: aiohttp <5,>=3.8.3
Requires-Dist: async-timeout >=4.0.2
Requires-Dist: cryptography >=36.0.2
Requires-Dist: chacha20poly1305-reuseable >=0.0.3
Requires-Dist: ifaddr >=0.1.7
Requires-Dist: mediafile >=0.8.1
Requires-Dist: miniaudio >=1.45
Requires-Dist: protobuf >=4.23.4
Requires-Dist: pydantic >=1.10.10
Requires-Dist: requests >=2.23.0
Requires-Dist: srptools >=0.2.0
Requires-Dist: tabulate >=0.9.0
Requires-Dist: zeroconf >=0.129.0

This leads to cryptography 42.0.1 being installed (if used in --target fashion, or not other cryptography installs) which leads to multiple crashes with cipher/communication.

Something seems up with the distribution wheel packaging?

setup.py


def get_requirements():
    """Retuen requirements with loose version restrictions."""
    return read("base_versions.txt").replace("==", ">=").split("\n")

Is replacing the == with >= leading to this change in the Dist wheel - and now incompatible cryptography…

Thanks!

Error log

Exc_info: (<class 'pyatv.exceptions.AuthenticationError'>, AuthenticationError(''), <traceback object at 0x10ef17680>) 
Exc_Text: Traceback (most recent call last):
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/pyatv/protocols/companion/protocol.py", line 121, in _setup_encryption
    await pair_verifier.verify_credentials()
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/pyatv/protocols/companion/auth.py", line 150, in verify_credentials
    encrypted_data = self.srp.verify1(self.credentials, server_pub_key, encrypted)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/pyatv/auth/hap_srp.py", line 94, in verify1
    chacha = chacha20.Chacha20Cipher(session_key, session_key)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/pyatv/support/chacha20.py", line 14, in __init__
    self._enc_out = ChaCha20Poly1305(out_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/chacha20poly1305_reuseable/__init__.py", line 82, in __init__
    if not AEAD_CIPHER_SUPPORTED(TEST_CIPHER):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/cryptography/hazmat/backends/openssl/backend.py", line 572, in aead_cipher_supported
    return aead._aead_cipher_supported(self, cipher)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/cryptography/hazmat/backends/openssl/aead.py", line 22, in _aead_cipher_supported
    cipher_name = _evp_cipher_cipher_name(cipher)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Application Support/Perceptive Automation/Indigo 2023.2/Plugins/appleTV.indigoPlugin/Contents/Packages/cryptography/hazmat/backends/openssl/aead.py", line 66, in _evp_cipher_cipher_name
    assert isinstance(cipher, AESGCM)
AssertionError

No response

How to reproduce the bug?

pip3 install pyatv -t /test/directory --verbose

Fix;
Make sure cryptography==41.0.7 available prior to pip installing pyatv

What is expected behavior?

Follow requirements.txt which has cryptography==41.0.7

Operating System

macOS

Python

Other

pyatv

0.14.5

Device

pyatv installs

Additional context

Mac OSX Intel
Python dist wheel as above

@Ghawken Ghawken added the bug label Jan 25, 2024
@thevrownguy
Copy link

Yes this is an issue and I downgraded to 41.07 and it worked perfect.

@DooMMasteR
Copy link

I am also affected by this issue, for me the Aqara FP2 home kit integration stopped working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants