ActiveBlog

Python Crypto: State of the Art (Part 1)
by Mike Ivanov

Mike Ivanov, February 20, 2010

There is a lot of interest in doing cryptography using Python these days which has resulted in quite an impressive number of cryptography related Python modules out there. PyPI package index alone has about 50 'cryptography'-tagged entries.

Unfortunately, the quality and scope of those packages, well, varies. So instead of putting together a list of All The Crypo Stuff Out There, I tried to discover cryptography toolkits an enterprise Python developer could be interested in.

By “cryptography toolkit” I mean what people usually refer as a "crypto system", though that is not quite a correct term. In other words, Cryptography Toolkit is a software system featuring a set of:

  • encryption algorithms
  • hash functions
  • cryptography protocols
  • random number generators
  • key/certificate manipulation tools
  • I/O routines

All that, of course, should be packaged together as a Python module. An ideal toolkit is expected to be:

extensible
there should be a way to add new or substitute existing algorithms with alternative implementations
interoperable
it should be able to "understand" other toolkits like MS Crypto API/CNG and JCA
secure
for example, the standard Python SSL implementation is using insecure SSLv2 which ignores certificates completely. Guess what that means?
cover a range of cryptography algorithms, protocols and schemes
the bare minimum is DES and RSA support, ECC is highly desired
certified
FIPS-140 is a minimum, NSA Suite B is ideal

Certain algorithm implementations (like a standalone SEAL2 library) limited to specific host platforms (like bindings for Mozilla's PKCS#11 DLL) are left out of this article, as well as alpha-quality software.

Given these parameters, the search yielded six results presented in the following table.


(click to enlarge)

Observations

  • Only NSS and OpenSSL are implementing Elliptic Curve algorithms
  • There is only one toolkit compatible with Google App Engine: cryptopy
  • None of the listed toolkits is Python 3 compatible
  • All toolkits except one are governed by the US export law
  • Not a single toolkit is compliant to the NSA Suite B

(Part 2...)

Subscribe to ActiveState Blogs by Email

Share this post:

About the Author: RSS

Mike Ivanov is a senior developer with significant experience building scalable web applications using Python, PostgreSQL and Linux, and a special interest in cloud computing and distributed systems. He has a Masters Degree in Computer Science (Large-Scale System Control) from the Krasnojarskij Gosudarstvennyj Tehniceskij university (really!).

Comments

7 comments for Python Crypto: State of the Art (Part 1)
Permalink

M2Crypto actually does support EC algorithms if OpenSSL is compiled with EC support: http://www.heikkitoivonen.net/m2crypto/api/M2Crypto.EC-module.html

Permalink

Oh, and M2Crypto supports more ciphers than listed in your table. Basically, anything OpenSSL supports is exposed by M2Crypto. For AES, see for example the test_AES method here: http://svn.osafoundation.org/m2crypto/trunk/tests/test_evp.py

You might also want to include a row for smart card support. M2Crypto supports them through the Engine interface. I know NSS supports smartcards, but I am not sure if this is exposed to Python yet.

Permalink

With standard Python using SSLv2 which ignores certificates completely, that would open up huge vulnerabilities that would render the encryption useless. While I like the idea of using Python to add encryption, it's well agreed that any toolkit would definitely need to address this issue.

targeted traffic

Permalink

@Hekki

Thanks for the suggestions and links. You know, one common problem with most of the open source software is documentation, or more precisely, lack of it :-)

I'm actually working on head-to-head comparision of M2Crypto and NSS bindings. I would appreciate more suggestions/comments on these two.

Permalink

@Kenneth: you're absolutely right.

Permalink

By the way, everyone is invited to join the python-crypto group at http://groups.google.com/group/python-crypto

Permalink

I have updated the table: included some other OpenSSL's algorithms