summaryrefslogtreecommitdiff
path: root/tests/test_crypto.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-06-29 18:43:42 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2017-06-29 16:43:42 -0700
commitcded993dbbff8e8c777b95f4de0597cdf3f75c0d (patch)
tree25bdb719b081caf7d3765aa104cf77468ca83d87 /tests/test_crypto.py
parent41c1024c4664fbd81afebae22cf923b9f6352b74 (diff)
downloadpyopenssl-git-cded993dbbff8e8c777b95f4de0597cdf3f75c0d.tar.gz
dump_privatekey with FILETYPE_TEXT only supports RSA keys (#646)
* dump_privatekey with FILETYPE_TEXT only supports RSA keys FILETYPE_TEXT is terrible but everyone hold their nose * also verify it's a pkey
Diffstat (limited to 'tests/test_crypto.py')
-rw-r--r--tests/test_crypto.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
index 4197f11..916186b 100644
--- a/tests/test_crypto.py
+++ b/tests/test_crypto.py
@@ -2631,6 +2631,20 @@ class TestFunction(object):
with pytest.raises(TypeError):
dump_privatekey(FILETYPE_PEM, key, cipher=GOOD_CIPHER)
+ def test_dump_privatekey_not_rsa_key(self):
+ """
+ `dump_privatekey` raises `TypeError` if called with a key that is
+ not RSA.
+ """
+ key = PKey()
+ key.generate_key(TYPE_DSA, 512)
+ with pytest.raises(TypeError):
+ dump_privatekey(FILETYPE_TEXT, key)
+
+ def test_dump_privatekey_invalid_pkey(self):
+ with pytest.raises(TypeError):
+ dump_privatekey(FILETYPE_TEXT, object())
+
def test_dump_privatekey_unknown_cipher(self):
"""
`dump_privatekey` raises `ValueError` if called with an unrecognized