diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2011-07-20 01:11:34 +0200 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2011-07-20 01:11:34 +0200 |
commit | f6a107324a774aa933eb8e1a6c80b37bb64372b6 (patch) | |
tree | 7c452e7f655c28386b289847b12b6e48cfbdc352 /tests | |
parent | fa34679a8da7ef536772494be860e9ebeff2641e (diff) | |
download | rsa-git-f6a107324a774aa933eb8e1a6c80b37bb64372b6.tar.gz |
Added support for saving private keys in DER and PEM format
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_load_save_keys.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_load_save_keys.py b/tests/test_load_save_keys.py index 695de72..c13d059 100644 --- a/tests/test_load_save_keys.py +++ b/tests/test_load_save_keys.py @@ -20,6 +20,12 @@ Stuff after the key -----END CONFUSING STUFF----- ''' % B64PRIV_DER +CLEAN_PRIVATE_PEM = '''\ +-----BEGIN RSA PRIVATE KEY----- +%s +-----END RSA PRIVATE KEY----- +''' % B64PRIV_DER + class DerTest(unittest.TestCase): '''Test saving and loading DER keys.''' @@ -32,6 +38,13 @@ class DerTest(unittest.TestCase): self.assertEqual(expected, key) + def test_save_private_key(self): + '''Test saving private DER keys.''' + + key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287) + der = rsa.key.save_private_key_der(key) + + self.assertEqual(PRIVATE_DER, der) class PemTest(unittest.TestCase): '''Test saving and loading PEM keys.''' @@ -45,3 +58,11 @@ class PemTest(unittest.TestCase): self.assertEqual(expected, key) + def test_save_private_key(self): + '''Test saving private PEM files.''' + + key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287) + pem = rsa.key.save_private_key_pem(key) + + self.assertEqual(CLEAN_PRIVATE_PEM, pem) + |