-
Notifications
You must be signed in to change notification settings - Fork 187
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
Crypto lib changes and misc fixes #423
Conversation
The crypto library it's using as also been added to the set_debug() message: import tinytuya
tinytuya.set_debug() result in:
or
or
or
|
This should not be a breaking change, but does make sense to do a minor rev version upgrade with the introduction of the new crypto library support.
] | ||
|
||
CHOOSE_CRYPTO_LIB = [ | ||
'cryptography', # pyca/cryptography - https://cryptography.io/en/latest/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. It has good review, works well in my tests and is often listed above pycryptodome in ratings. However, it does not support Python 2.7. I suggest we officially remove 2.7 support with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. My computer died last month and I installed Debian 12 on my new one, so I can't even test against Python 2.7 anymore without copying it to another machine first.
tinytuya/core.py
Outdated
except ImportError: | ||
continue | ||
if CRYPTOLIB is None: | ||
raise ModuleNotFoundError('No crypto library found, please install one of: pyca/cryptography, PyCryptodome, or PyCrypto') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just message this as the pip install
equivalent?
No crypto library found, please install: cryptography, pycryptodome, or pyaes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I'm going to leave it as is. This is similar to README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too late...
except ImportError: | ||
continue | ||
if CRYPTOLIB is None: | ||
raise ModuleNotFoundError('No crypto library found, please "pip install" cryptography, pycryptodome, or pyaes') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sold ❤️
I'm going to test on a few more systems (Win11 and RPi). Any other updates you are thinking about before we merge? |
I'm sure I'll think of one 5 seconds after it's merged... But right now I think I'm done :) |
Ugh, I broke v3.5 devices, one moment... |
And that should fix it. Should be good to merge! |
One of these days I'll polish up my "fake v3.5 device" script and add it to tools/. Not going to be for this PR though. |
✅ MacOS During one snapshot scan test, Win11 is producing some errors but still worked and occasionally occurs in v1.12.11 as well.
I also tested pyca/cryptography on Win11 - successfully:
|
Python version warning for cryptography (Python 3.6 support):
|
Issue I just discovered... on an Linux box using Python 3.7, the
Upgrading to We should push a patch to include that in the requirements. |
Looking at the backtrace it looks like <=3.0 require a |
I like it! Thanks @uzlonewolf |
This PR reworks AESCipher() to make it a bit easier to add additional crypto libraries. It also adds pyca/cryptography ( https://cryptography.io/en/latest/ ) which uses OpenSSL under the hood. pyca/cryptography is preferred at runtime and in setup.py, but PyCryptodome is still preferred in requirements.txt.
An issue with tinytuya.find_device() for v3.1 devices has also been fixed, as has the infinite loop in Contrib/IRRemoteControlDevice.py (Closes #403).