~seanlynch/pynacl

Python wrapper for http://nacl.cace-project.eu/ Topics Resources
f9109230 — Sean Richard Lynch 9 years ago
Merge pull request #6 from glaslos/master
229a0291 — glaslos 9 years ago
Test fixed and minor README changes
67251bb8 — Brian Warner 11 years ago
turn off unoptimized compilers to save build time

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~seanlynch/pynacl
read/write
git@git.sr.ht:~seanlynch/pynacl

You can also use your local clone with git send-email.

#PyNaCl: A Python Wrapper for NaCl

#Overview

This is a simple wrapper for the NaCl cryptographic library (not Google's NativeClient).

#Features

PyNaCl currently wraps the following NaCl functions:

  • crypto_hash_sha256
  • crypto_hash_sha512
  • crypto_randombytes

And the following groups of functions (if not otherwise specified by the suffix, it just wraps the default primitive):

  • crypto_scalarmult_curve25519
  • crypto_box
  • crypto_sign
  • crypto_secretbox
  • crypto_stream
  • crypto_auth
  • crypto_onetimeauth

#API

The API is a very straightforward translation of NaCl's C API. Any function that returns an error code will raise ValueError if it returns anything but zero. Output arguments are returned, with keypair functions returning 2-tuples and everything else returning strings. The wrapper handles all padding, so you can just ignore that part of NaCl's documentation.

Eventually I'll translate the documentation over, but for now look at test.py and the NaCl documentation.

#Installation

SWIG is required to generate the wrapper:

apt-get install swig

Download pynacl with the embedded NaCL (verify it's the latest version):

git clone git@github.com:seanlynch/pynacl.git

NaCl does not build with the -fPIC flag and therefore you must modify a file:

cd pynacl/nacl-20110221
sed -i "s/$/ -fPIC/" okcompilers/c*

If you want the build status output printed to screen, you may also do:

sed -i "s/exec 2\?>.*//" do

You can then build NaCl with:

./do

Once NaCl is successfully built, you can run:

cd ../
python setup.py build
sudo python setup.py install

#Testing

To run the tests, just run the script "test.py" in the distribution directory.

#License

PyNaCl is released under version 2.0 of the Apache license.

#To do

  • Convert to a package so I can add Python code
  • Implement a higher-level API
  • Implement fromseed versions of other key generation functions