summaryrefslogtreecommitdiff
path: root/lib/Crypto/Util/py21compat.py
diff options
context:
space:
mode:
authorLegrandin <helderijs@gmail.com>2013-06-15 23:25:49 +0200
committerDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 21:16:46 -0700
commit90d6d3dbcfb02fc441edafe6fafe6e6800009e35 (patch)
treea47b22eea2560392a673d8cba675579459452482 /lib/Crypto/Util/py21compat.py
parent5a0ee14e9904335cb90c0dd7a4e10f1523435c52 (diff)
downloadpycrypto-90d6d3dbcfb02fc441edafe6fafe6e6800009e35.tar.gz
Added support for PKCS#8-encrypted private keys.
The patch contains the following changes: - Private RSA keys can be imported/exported in encrypted form, protected according to PKCS#8 and: * PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC. * PBKDF2WithHMAC-SHA1AndAES128-CBC * PBKDF2WithHMAC-SHA1AndAES192-CBC * PBKDF2WithHMAC-SHA1AndAES256-CBC In addition to that, it is possible to import keys i the following weak formats: * pbeWithMD5AndDES-CBC * pbeWithSHA1AndRC2-CBC * pbeWithMD5AndRC2-CBC * pbeWithSHA1AndDES-CBC - The following new module (and 1 new package) are added: * Crypto.Util.Padding for simple padding/unpadding logic * Crypto.IO._PBES for PBE-related PKCS#5 logic * Crypto.IO.PEM for PEM wrapping/unwrapping * Crypto.IO.PKCS8 for PKCS#8 wrapping/unwrapping - All Object ID (OIDs) are now in dotted form to increase readability. - Add AES support to PEM format (decode only). The PEM module can decrypt messages protected with AES-CBC. - Update RSA import test cases. - Updated to PKCS8 test cases
Diffstat (limited to 'lib/Crypto/Util/py21compat.py')
-rw-r--r--lib/Crypto/Util/py21compat.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Crypto/Util/py21compat.py b/lib/Crypto/Util/py21compat.py
index 624408b..658fd36 100644
--- a/lib/Crypto/Util/py21compat.py
+++ b/lib/Crypto/Util/py21compat.py
@@ -81,4 +81,21 @@ except TypeError:
return True
return False
+#
+# Python 2.2 introduces the built-in staticmethod(). Python 2.4 turns
+# it into a function decorator (@staticmethod).
+#
+# The following recipe for achieving the same thing in Python 2.1 comes
+# from the Python Cookbok ("Implementanting Static Methods").
+#
+try:
+ class A:
+ def a(): pass
+ a = staticmethod(a)
+except NameError:
+ class staticmethod:
+ def __init__(self, anycallable):
+ self.__call__ = anycallable
+ __all__ += ['staticmethod']
+
# vim:set ts=4 sw=4 sts=4 expandtab: