This repository was archived by the owner on Jan 10, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change 11from adb import adb_protocol
22
3- from Crypto .Hash import SHA256
43from Crypto .PublicKey import RSA
5- from Crypto .Signature import pkcs1_15
4+ from Crypto .Signature import PKCS1_v1_5
65
6+ class FakeSHA1 :
7+ oid = "1.3.14.3.2.26" # SHA-1 OID
78
8- class PycryptodomeAuthSigner (adb_protocol .AuthSigner ):
9+ def __init__ (self , data : (bytes , bytearray )) -> None :
10+ self .reset ()
11+ self ._data = data
912
13+ def reset (self ) -> None :
14+ self ._data = b""
15+
16+ def update (self , data : (bytes , bytearray )) -> None :
17+ self ._data += data
18+
19+ def digest (self ) -> (bytes , bytearray ):
20+ return self ._data
21+
22+ class PycryptodomeSigner (adb_protocol .AuthSigner ):
1023 def __init__ (self , rsa_key_path = None ):
11- super (PycryptodomeAuthSigner , self ).__init__ ()
24+ super (PycryptodomeSigner , self ).__init__ ()
1225
1326 if rsa_key_path :
1427 with open (rsa_key_path + '.pub' , 'rb' ) as rsa_pub_file :
@@ -18,8 +31,8 @@ def __init__(self, rsa_key_path=None):
1831 self .rsa_key = RSA .import_key (rsa_priv_file .read ())
1932
2033 def Sign (self , data ):
21- h = SHA256 . new (data )
22- return pkcs1_15 .new (self .rsa_key ).sign (h )
34+ h = FakeSHA1 (data )
35+ return PKCS1_v1_5 .new (self .rsa_key ).sign (h )
2336
2437 def GetPublicKey (self ):
25- return self .public_key
38+ return self .public_key
You can’t perform that action at this time.
0 commit comments