summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rsa/key.py16
-rw-r--r--tests/test_load_save_keys.py16
2 files changed, 16 insertions, 16 deletions
diff --git a/rsa/key.py b/rsa/key.py
index 7b13fa6..9e01958 100644
--- a/rsa/key.py
+++ b/rsa/key.py
@@ -38,18 +38,18 @@ class AbstractKey(object):
'''Abstract superclass for private and public keys.'''
@classmethod
- def load_pkcs1(cls, keyfile, format='pem'):
+ def load_pkcs1(cls, keyfile, format='PEM'):
r'''Loads a key in PKCS#1 DER or PEM format.
@param keyfile: contents of a DER- or PEM-encoded file that contains
the public key.
- @param format: the format of the file to load; 'pem' or 'der'
+ @param format: the format of the file to load; 'PEM' or 'DER'
@return: a PublicKey object
'''
methods = {
- 'pem': cls.load_pkcs1_pem,
- 'der': cls.load_pkcs1_der,
+ 'PEM': cls.load_pkcs1_pem,
+ 'DER': cls.load_pkcs1_der,
}
if format not in methods:
@@ -60,16 +60,16 @@ class AbstractKey(object):
method = methods[format]
return method(keyfile)
- def save_pkcs1(self, format='pem'):
+ def save_pkcs1(self, format='PEM'):
'''Saves the public key in PKCS#1 DER or PEM format.
- @param format: the format to save; 'pem' or 'der'
+ @param format: the format to save; 'PEM' or 'DER'
@returns: the DER- or PEM-encoded public key.
'''
methods = {
- 'pem': self.save_pkcs1_pem,
- 'der': self.save_pkcs1_der,
+ 'PEM': self.save_pkcs1_pem,
+ 'DER': self.save_pkcs1_der,
}
if format not in methods:
diff --git a/tests/test_load_save_keys.py b/tests/test_load_save_keys.py
index abcfb18..facb826 100644
--- a/tests/test_load_save_keys.py
+++ b/tests/test_load_save_keys.py
@@ -54,7 +54,7 @@ class DerTest(unittest.TestCase):
def test_load_private_key(self):
'''Test loading private DER keys.'''
- key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_DER, 'der')
+ key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_DER, 'DER')
expected = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
self.assertEqual(expected, key)
@@ -63,14 +63,14 @@ class DerTest(unittest.TestCase):
'''Test saving private DER keys.'''
key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
- der = key.save_pkcs1('der')
+ der = key.save_pkcs1('DER')
self.assertEqual(PRIVATE_DER, der)
def test_load_public_key(self):
'''Test loading public DER keys.'''
- key = rsa.key.PublicKey.load_pkcs1(PUBLIC_DER, 'der')
+ key = rsa.key.PublicKey.load_pkcs1(PUBLIC_DER, 'DER')
expected = rsa.key.PublicKey(3727264081, 65537)
self.assertEqual(expected, key)
@@ -79,7 +79,7 @@ class DerTest(unittest.TestCase):
'''Test saving public DER keys.'''
key = rsa.key.PublicKey(3727264081, 65537)
- der = key.save_pkcs1('der')
+ der = key.save_pkcs1('DER')
self.assertEqual(PUBLIC_DER, der)
@@ -90,7 +90,7 @@ class PemTest(unittest.TestCase):
def test_load_private_key(self):
'''Test loading private PEM files.'''
- key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_PEM, 'pem')
+ key = rsa.key.PrivateKey.load_pkcs1(PRIVATE_PEM, 'PEM')
expected = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
self.assertEqual(expected, key)
@@ -99,14 +99,14 @@ class PemTest(unittest.TestCase):
'''Test saving private PEM files.'''
key = rsa.key.PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
- pem = key.save_pkcs1('pem')
+ pem = key.save_pkcs1('PEM')
self.assertEqual(CLEAN_PRIVATE_PEM, pem)
def test_load_public_key(self):
'''Test loading public PEM files.'''
- key = rsa.key.PublicKey.load_pkcs1(PUBLIC_PEM, 'pem')
+ key = rsa.key.PublicKey.load_pkcs1(PUBLIC_PEM, 'PEM')
expected = rsa.key.PublicKey(3727264081, 65537)
self.assertEqual(expected, key)
@@ -115,7 +115,7 @@ class PemTest(unittest.TestCase):
'''Test saving public PEM files.'''
key = rsa.key.PublicKey(3727264081, 65537)
- pem = key.save_pkcs1('pem')
+ pem = key.save_pkcs1('PEM')
self.assertEqual(CLEAN_PUBLIC_PEM, pem)