Skip to content

Commit 8ac3634

Browse files
committed
Move pythonrsa's key_path constructor to classmethod
1 parent ebf8817 commit 8ac3634

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

adb/adb_debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def GetRSAKwargs():
5252
sys.exit(1)
5353
signer = (
5454
sign_m2crypto.M2CryptoSigner if sign_m2crypto
55-
else sign_pythonrsa.PythonRSASigner)
55+
else sign_pythonrsa.PythonRSASigner.FromRSAKeyPath)
5656
return {
5757
'rsa_keys': [signer(os.path.expanduser(path))
5858
for path in FLAGS.rsa_key_path],

adb/sign_pythonrsa.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ def _load_rsa_private_key(pem):
5353

5454
class PythonRSASigner(object):
5555
"""Implements adb_protocol.AuthSigner using http://stuvel.eu/rsa."""
56-
def __init__(self, rsa_key_path=None, pub=None, priv=None):
57-
if rsa_key_path:
58-
with open(rsa_key_path + '.pub') as f:
59-
pub = f.read()
60-
with open(rsa_key_path) as f:
61-
priv = f.read()
56+
@classmethod
57+
def FromRSAKeyPath(cls, rsa_key_path):
58+
with open(rsa_key_path + '.pub') as f:
59+
pub = f.read()
60+
with open(rsa_key_path) as f:
61+
priv = f.read()
62+
return cls(pub, priv)
63+
64+
def __init__(self, pub=None, priv=None):
6265
self.priv_key = _load_rsa_private_key(priv)
6366
self.pub_key = pub
6467

0 commit comments

Comments
 (0)