summaryrefslogtreecommitdiff
path: root/paramiko/rsakey.py
diff options
context:
space:
mode:
authorScott Maxwell <scott@codecobblers.com>2013-11-01 00:37:11 -0700
committerScott Maxwell <scott@codecobblers.com>2013-11-01 00:37:11 -0700
commit8a7267beeb3435fa16c06d22c201650e1e593d89 (patch)
tree0f78c4a7d45f226abcb60cd53907d6be3ecd0656 /paramiko/rsakey.py
parentd5ce2b43d602282fe2aa826481759c48d18c9b38 (diff)
downloadparamiko-8a7267beeb3435fa16c06d22c201650e1e593d89.tar.gz
Eliminate all uses of b'' syntax to allow for Python 2.5 support
Diffstat (limited to 'paramiko/rsakey.py')
-rw-r--r--paramiko/rsakey.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py
index 90945031..4bc94e0b 100644
--- a/paramiko/rsakey.py
+++ b/paramiko/rsakey.py
@@ -20,6 +20,7 @@
L{RSAKey}
"""
+from binascii import unhexlify
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA, MD5
from Crypto.Cipher import DES3
@@ -152,26 +153,15 @@ class RSAKey (PKey):
### internals...
- if PY3:
- def _pkcs1imify(self, data):
- """
- turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
- using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre.
- """
- SHA1_DIGESTINFO = b'\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14'
- size = len(util.deflate_long(self.n, 0))
- filler = b'\xff' * (size - len(SHA1_DIGESTINFO) - len(data) - 3)
- return b'\x00\x01' + filler + b'\x00' + SHA1_DIGESTINFO + data
- else:
- def _pkcs1imify(self, data):
- """
- turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
- using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre.
- """
- SHA1_DIGESTINFO = b('\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14')
- size = len(util.deflate_long(self.n, 0))
- filler = b('\xff') * (size - len(SHA1_DIGESTINFO) - len(data) - 3)
- return b('\x00\x01') + filler + b('\x00') + SHA1_DIGESTINFO + b(data)
+ def _pkcs1imify(self, data):
+ """
+ turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
+ using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre.
+ """
+ SHA1_DIGESTINFO = unhexlify('3021300906052b0e03021a05000414')
+ size = len(util.deflate_long(self.n, 0))
+ filler = max_byte * (size - len(SHA1_DIGESTINFO) - len(data) - 3)
+ return zero_byte + one_byte + filler + zero_byte + SHA1_DIGESTINFO + data
def _from_private_key_file(self, filename, password):
data = self._read_private_key_file('RSA', filename, password)