diff options
author | Casey Deccio <casey@deccio.net> | 2015-12-17 04:05:47 -0500 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2016-02-02 21:03:01 +0100 |
commit | 5fc5ba2dc5c9dbe75056856f04ef6c03effecf10 (patch) | |
tree | f13094a2e0a6d9d9faded5c8ddf290548a8ba309 /tests/test_evp.py | |
parent | 528fda169dc657d5f20e97d218d5fbedc962fae0 (diff) | |
download | m2crypto-5fc5ba2dc5c9dbe75056856f04ef6c03effecf10.tar.gz |
Add load_key_string_pubkey() function
Add EVP.load_key_string_pubkey() function, as well as helper functions
m2.pkey_read_pem_pubkey() and EVP.load_key_bio_pubkey().
Diffstat (limited to 'tests/test_evp.py')
-rw-r--r-- | tests/test_evp.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_evp.py b/tests/test_evp.py index 07417b8..c272b6b 100644 --- a/tests/test_evp.py +++ b/tests/test_evp.py @@ -140,6 +140,26 @@ class EVPTestCase(unittest.TestCase): rsa3 = RSA.gen_key(1024, 3, callback=self._gen_callback) self.assertNotEqual(rsa.sign(digest), rsa3.sign(digest)) + def test_load_key_string_pubkey(self): + """ + Testing creating a PKey instance from PEM string. + """ + rsa = RSA.gen_key(1024, 3, callback=self._gen_callback) + self.assertIsInstance(rsa, RSA.RSA) + + rsa_pem = BIO.MemoryBuffer() + rsa.save_pub_key_bio(rsa_pem) + pkey = EVP.load_key_string_pubkey(rsa_pem.read()) + rsa2 = pkey.get_rsa() + self.assertIsInstance(rsa2, RSA.RSA_pub) + self.assertEqual(rsa.e, rsa2.e) + self.assertEqual(rsa.n, rsa2.n) + pem = rsa.as_pem(callback=self._pass_callback) + pem2 = rsa2.as_pem() + assert pem + assert pem2 + self.assertNotEqual(pem, pem2) + def test_get_rsa_fail(self): """ Testing trying to retrieve the RSA key from the PKey instance |