diff options
| author | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2011-09-21 00:01:36 +0200 |
|---|---|---|
| committer | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2011-09-21 00:01:36 +0200 |
| commit | b8dc2d95ea146d4ed77e48c33c1d731ff6ee5d50 (patch) | |
| tree | e91dc43c9df92a3f078058732ae91a5730fa5fad /lib/Crypto/SelfTest/PublicKey | |
| parent | b526fde09b8196d87809ba8d3e8b2d2f455170ae (diff) | |
| download | pycrypto-b8dc2d95ea146d4ed77e48c33c1d731ff6ee5d50.tar.gz | |
Add support for import of OpenSSH public keys
Diffstat (limited to 'lib/Crypto/SelfTest/PublicKey')
| -rw-r--r-- | lib/Crypto/SelfTest/PublicKey/test_importKey.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Crypto/SelfTest/PublicKey/test_importKey.py b/lib/Crypto/SelfTest/PublicKey/test_importKey.py index 23f1df7..4edc243 100644 --- a/lib/Crypto/SelfTest/PublicKey/test_importKey.py +++ b/lib/Crypto/SelfTest/PublicKey/test_importKey.py @@ -47,6 +47,9 @@ MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL8eJ5AKoIsjURpcEoGubZMxLD7+kT+T Lr7UkvEtFrRhDDKMtuIIq19FrL4pUIMymPMSLBn3hJLe30Dw48GQM4UCAwEAAQ== -----END PUBLIC KEY-----''' + # Obtained using 'ssh-keygen -i -m PKCS8 -f rsaPublicKeyPEM' + rsaPublicKeyOpenSSH = '''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQC/HieQCqCLI1EaXBKBrm2TMSw+/pE/ky6+1JLxLRa0YQwyjLbiCKtfRay+KVCDMpjzEiwZ94SS3t9A8OPBkDOF comment\n''' + rsaKeyDER = a2b_hex( '''3082013b020100024100bf1e27900aa08b23511a5c1281ae6d93312c3efe 913f932ebed492f12d16b4610c328cb6e208ab5f45acbe2950833298f312 @@ -121,6 +124,11 @@ Lr7UkvEtFrRhDDKMtuIIq19FrL4pUIMymPMSLBn3hJLe30Dw48GQM4UCAwEAAQ== idem = key.encrypt(key.decrypt("Test"),0) self.assertEqual(idem[0],"Test") + def testImportKey7(self): + key = self.rsa.importKey(self.rsaPublicKeyOpenSSH) + self.assertEqual(key.n, self.n) + self.assertEqual(key.e, self.e) + ### def testExportKey1(self): key = self.rsa.construct([self.n, self.e, self.d, self.p, self.q, self.pInv]) |
