Applied Modern Cryptography in Python (PyCon 2017)

  • Cryptography is ubiquitous today
  • From mobile phones to wireless communication
  • Supported in almost every programming language
  • It is even embedded in the CPUs
  • It is not hard to do crypto right but...

We will look at the basic blocks of modern crypto using Python. There are a number of crypto libraries in Python:

  • pycrypto (oldest and most widely used)
  • m2crypto (SWIG binding)
  • cryptography (PY2, PY3, PyPy, OpenSSL CFFI binding)

We will use the cryptography library. You can download the library from here and follow the instructions. You should be able to install the library using the following command. You need to have pip installed.

pip install cryptography

To install pip, follow the instructions here

Cyrptography.io

Cryptography components are divided into different submodules. Following is a list of these submodules (not exhaustive)

  • Primitive Crypto Blocks (cryptography.hazmat)
    • Message Digest and Hashing algorithms (cryptography.hazmat.primitives.hashes)
    • Symmetric encryption algorithms (cryptography.hazmat.primitives.ciphers)
    • Asymmetric encryption algorithms (cryptography.hazmat.primitives.asymmetric)
    • Key derivation functions (cryptography.hazmat.primitives.kdf)
  • X.509 Ecosystem (cryptography.x509)
  • Full high level crypto recipe (cryptography.fernet)