File: 0006-fix-py3-errors.patch

package info (click to toggle)
python-crypto 2.6.1-9
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,052 kB
  • sloc: ansic: 12,466; python: 10,478; sh: 35; makefile: 14
file content (41 lines) | stat: -rw-r--r-- 2,168 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Sebastian Ramacher <s.ramacher@gmx.at>
Date: Mon, 16 Apr 2018 01:02:09 +0200
Subject: Fix Python 3 erros uncovered by reenable-redefined-tests.patch.

Last-Update: 2012-05-28
Forwarded: https://github.com/dlitz/pycrypto/pull/16
---
 lib/Crypto/PublicKey/RSA.py                     | 6 +++---
 lib/Crypto/SelfTest/PublicKey/test_importKey.py | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/Crypto/PublicKey/RSA.py b/lib/Crypto/PublicKey/RSA.py
index 99d851d..ec04625 100644
--- a/lib/Crypto/PublicKey/RSA.py
+++ b/lib/Crypto/PublicKey/RSA.py
@@ -348,9 +348,9 @@ class _RSAobj(pubkey.pubkey):
                nb = long_to_bytes(self.n)
                if bord(eb[0]) & 0x80: eb=bchr(0x00)+eb
                if bord(nb[0]) & 0x80: nb=bchr(0x00)+nb
-               keyparts = [ 'ssh-rsa', eb, nb ]
-               keystring = ''.join([ struct.pack(">I",len(kp))+kp for kp in keyparts]) 
-               return 'ssh-rsa '+binascii.b2a_base64(keystring)[:-1]
+               keyparts = [ b('ssh-rsa'), eb, nb ]
+               keystring = b('').join([ struct.pack(">I",len(kp))+kp for kp in keyparts])
+               return b('ssh-rsa ')+binascii.b2a_base64(keystring)[:-1]
 
         # DER format is always used, even in case of PEM, which simply
         # encodes it into BASE64.
diff --git a/lib/Crypto/SelfTest/PublicKey/test_importKey.py b/lib/Crypto/SelfTest/PublicKey/test_importKey.py
index f7c1edc..0e41577 100644
--- a/lib/Crypto/SelfTest/PublicKey/test_importKey.py
+++ b/lib/Crypto/SelfTest/PublicKey/test_importKey.py
@@ -104,7 +104,7 @@ Lr7UkvEtFrRhDDKMtuIIq19FrL4pUIMymPMSLBn3hJLe30Dw48GQM4UCAwEAAQ==
 -----END PUBLIC KEY-----'''
 
     # Obtained using 'ssh-keygen -i -m PKCS8 -f rsaPublicKeyPEM'
-    rsaPublicKeyOpenSSH = '''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQC/HieQCqCLI1EaXBKBrm2TMSw+/pE/ky6+1JLxLRa0YQwyjLbiCKtfRay+KVCDMpjzEiwZ94SS3t9A8OPBkDOF comment\n'''
+    rsaPublicKeyOpenSSH = b('''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQC/HieQCqCLI1EaXBKBrm2TMSw+/pE/ky6+1JLxLRa0YQwyjLbiCKtfRay+KVCDMpjzEiwZ94SS3t9A8OPBkDOF comment\n''')
 
     # The private key, in PKCS#1 format encoded with DER
     rsaKeyDER = a2b_hex(