diff options
| author | Sebastian Ramacher <s.ramacher@gmx.at> | 2012-05-28 13:19:22 +0200 |
|---|---|---|
| committer | Sebastian Ramacher <s.ramacher@gmx.at> | 2012-05-28 13:19:22 +0200 |
| commit | ab25c6fe95ee92fac3187dcd90e0560ccacb084a (patch) | |
| tree | c6895ea05ed080bc58ad4886fbce798f87a33480 /lib/Crypto | |
| parent | fa930881d6f16d7058bcbfab1c537e0e3a78e22b (diff) | |
| download | pycrypto-ab25c6fe95ee92fac3187dcd90e0560ccacb084a.tar.gz | |
Return a byte string if format is set to OpenSSH.
RSA.exportKey claims to return a byte string, so really return one.
Diffstat (limited to 'lib/Crypto')
| -rw-r--r-- | lib/Crypto/PublicKey/RSA.py | 6 | ||||
| -rw-r--r-- | 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( |
