From 3338e6baa4ce37523e5859094bf7b758b926c2e3 Mon Sep 17 00:00:00 2001 From: Joe Leong Date: Tue, 11 Dec 2018 11:38:55 -0500 Subject: [PATCH] Fix RSA keyfile open mode (rb) for python3 (#141) --- adb/sign_m2crypto.py | 2 +- adb/sign_pythonrsa.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adb/sign_m2crypto.py b/adb/sign_m2crypto.py index b8b6d0d..aba981a 100644 --- a/adb/sign_m2crypto.py +++ b/adb/sign_m2crypto.py @@ -21,7 +21,7 @@ class M2CryptoSigner(adb_protocol.AuthSigner): """AuthSigner using M2Crypto.""" def __init__(self, rsa_key_path): - with open(rsa_key_path + '.pub') as rsa_pub_file: + with open(rsa_key_path + '.pub', 'rb') as rsa_pub_file: self.public_key = rsa_pub_file.read() self.rsa_key = RSA.load_key(rsa_key_path) diff --git a/adb/sign_pythonrsa.py b/adb/sign_pythonrsa.py index a401a4c..b159142 100644 --- a/adb/sign_pythonrsa.py +++ b/adb/sign_pythonrsa.py @@ -60,9 +60,9 @@ class PythonRSASigner(object): @classmethod def FromRSAKeyPath(cls, rsa_key_path): - with open(rsa_key_path + '.pub') as f: + with open(rsa_key_path + '.pub', 'rb') as f: pub = f.read() - with open(rsa_key_path) as f: + with open(rsa_key_path, 'rb') as f: priv = f.read() return cls(pub, priv)