summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. St?vel <s.a.stuvel@uu.nl>2014-03-02 08:00:37 +0000
committerSybren A. St?vel <s.a.stuvel@uu.nl>2014-03-02 08:00:37 +0000
commitcb86fc50508390a523683a7ef5f70965b2858e94 (patch)
treeb13bcb0c1583f94bcdcc8edd6210927c4bc9e28b
parent643372ef43510bbeab71ee8864e5b8129ff261bd (diff)
downloadrsa-pkcs1_v21.tar.gz
Started explicitly mentioning PKCS#1 v1.5 or v2.1pkcs1_v21
-rw-r--r--rsa/key.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/rsa/key.py b/rsa/key.py
index b6de7b3..25ca6e1 100644
--- a/rsa/key.py
+++ b/rsa/key.py
@@ -202,7 +202,11 @@ class PublicKey(AbstractKey):
@classmethod
def load_pkcs1_openssl_pem(cls, keyfile):
- '''Loads a PKCS#1.5 PEM-encoded public key file from OpenSSL.
+ return cls.load_pkcs1_v2_1(keyfile)
+
+ @classmethod
+ def load_pkcs1_v2_1_pem(cls, keyfile):
+ '''Loads a PKCS#1 v2.1 PEM-encoded public key file.
These files can be recognised in that they start with BEGIN PUBLIC KEY
rather than BEGIN RSA PUBLIC KEY.
@@ -211,19 +215,23 @@ class PublicKey(AbstractKey):
after the "-----END PUBLIC KEY-----" lines is ignored.
@param keyfile: contents of a PEM-encoded file that contains the public
- key, from OpenSSL.
+ key in PKCS#1 v2.1 format.
@return: a PublicKey object
'''
der = rsa.pem.load_pem(keyfile, 'PUBLIC KEY')
- return cls.load_pkcs1_openssl_der(der)
+ return cls.load_pkcs1_v2_1_der(der)
@classmethod
def load_pkcs1_openssl_der(cls, keyfile):
- '''Loads a PKCS#1 DER-encoded public key file from OpenSSL.
+ return cls.load_pkcs1_v2_1_der(keyfile)
+
+ @classmethod
+ def load_pkcs1_v2_1_der(cls, keyfile):
+ '''Loads a PKCS#1 v2.1 DER-encoded public key file.
@param keyfile: contents of a DER-encoded file that contains the public
- key, from OpenSSL.
+ key in PKCS#1 v2.1 format.
@return: a PublicKey object
'''
@@ -234,7 +242,7 @@ class PublicKey(AbstractKey):
(keyinfo, _) = decoder.decode(keyfile, asn1Spec=OpenSSLPubKey())
if keyinfo['header']['oid'] != univ.ObjectIdentifier('1.2.840.113549.1.1.1'):
- raise TypeError("This is not a DER-encoded OpenSSL-compatible public key")
+ raise TypeError("This is not a DER-encoded PKCS#1 v2.1 public key")
return cls._load_pkcs1_der(keyinfo['key'][1:])