You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Would you be open to a PR to replace the M2Crypto dependency with cryptography?
cryptography provides wheels for most platforms, whereas M2Crypto only provides a source tarball, meaning it has to be built from scratch every time.
M2Crypto needs swig to be installed in order to be built, which means installing with pip install openhtf[usb_plugs] will fail unless sudo apt install swig (or equivalent) is run before.
cryptography is actively maintained by the Python Cryptographic Authority
Since M2Crypto is only used to implement a adb_protocol.AuthSigner subclass (M2CryptoSigner), only needing to load RSA keys and sign with them, it could be easily replaced with something like:
fromcryptography.hazmat.primitivesimportserializationfromcryptography.hazmat.primitivesimporthashesdefget_passphrase() ->Optional[str]:
fromgetpassimportgetpasstry:
returngetpass('Enter passphrase:')
exceptKeyboardInterrupt:
returnNoneclassCryptographySigner(adb_protocol.AuthSigner):
"""AuthSigner using cryptography."""def__init__(self, rsa_key_path):
withopen(rsa_key_path+'.pub') asrsa_pub_file:
self.public_key=rsa_pub_file.read()
withopen(rsa_key_path, "rb") asrsa_file:
self.rsa_key=serialization.load_pem_private_key(rsa_file.read(),
password=get_passphrase())
defsign(self, data):
returnself.rsa_key.sign(data, hashes.SHA1)
defget_public_key(self):
"""Return the public key."""returnself.public_key
The text was updated successfully, but these errors were encountered:
Hi! Would you be open to a PR to replace the
M2Crypto
dependency withcryptography
?cryptography
provides wheels for most platforms, whereasM2Crypto
only provides a source tarball, meaning it has to be built from scratch every time.M2Crypto
needsswig
to be installed in order to be built, which means installing withpip install openhtf[usb_plugs]
will fail unlesssudo apt install swig
(or equivalent) is run before.cryptography
is actively maintained by the Python Cryptographic AuthoritySince
M2Crypto
is only used to implement aadb_protocol.AuthSigner
subclass (M2CryptoSigner
), only needing to load RSA keys and sign with them, it could be easily replaced with something like:The text was updated successfully, but these errors were encountered: