libnacl-1.6.1/0000755000175000001440000000000013200105202013536 5ustar thatchusers00000000000000libnacl-1.6.1/pkg/0000755000175000001440000000000013200105202014317 5ustar thatchusers00000000000000libnacl-1.6.1/pkg/suse/0000755000175000001440000000000013200105202015276 5ustar thatchusers00000000000000libnacl-1.6.1/pkg/suse/python-libnacl.spec0000644000175000001440000000416113133731616021122 0ustar thatchusers00000000000000# # spec file for package python-libnacl # # Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: python-libnacl Version: 1.4.3 Release: 0 License: Apache-2.0 Summary: Python bindings for libsodium based on ctypes Url: https://github.com/saltstack/libnacl Group: Development/Languages/Python Source0: https://pypi.python.org/packages/source/l/libnacl/libnacl-%{version}.tar.gz BuildRoot: %{_tmppath}/libnacl-%{version}-build BuildRequires: python-setuptools BuildRequires: python-devel BuildRequires: libsodium-devel BuildRequires: fdupes BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?suse_version} && 0%{?suse_version} <= 1110 %{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %else BuildArch: noarch %endif %description This library is used to gain direct access to the functions exposed by Daniel J. Bernstein's nacl library via libsodium. It has been constructed to maintain extensive documentation on how to use nacl as well as being completely portable. The file in libnacl/__init__.py can be pulled out and placed directly in any project to give a single file binding to all of nacl. %prep %setup -q -n libnacl-%{version} %build python setup.py build %install python setup.py install --prefix=%{_prefix} --root=%{buildroot} --optimize=1 %fdupes %{buildroot}%{_prefix} %files %defattr(-,root,root) %{python_sitelib}/* %changeloglibnacl-1.6.1/pkg/suse/python-libnacl.changes0000644000175000001440000000067113133731616021602 0ustar thatchusers00000000000000------------------------------------------------------------------- Wed Jul 2 18:28:08 UTC 2014 - aboe76@gmail.com - Updated to 1.1.0 ------------------------------------------------------------------- Fri Jun 20 15:10:52 UTC 2014 - aboe76@gmail.com - Simplified BuildRequirements to libsodium-devel ------------------------------------------------------------------- Mon Jun 9 10:53:12 UTC 2014 - aboe76@gmail.com - initial package libnacl-1.6.1/pkg/rpm/0000755000175000001440000000000013200105202015115 5ustar thatchusers00000000000000libnacl-1.6.1/pkg/rpm/python-libnacl.spec0000644000175000001440000001033013133731616020734 0ustar thatchusers00000000000000%if 0%{?fedora} > 12 || 0%{?rhel} > 6 %global with_python3 1 %endif %if 0%{?rhel} == 5 %global pybasever 2.6 %endif %{!?__python2: %global __python2 /usr/bin/python%{?pybasever}} %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} %{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %global srcname libnacl Name: python-%{srcname} Version: 1.4.3 Release: 1%{?dist} Summary: Python bindings for libsodium based on ctypes Group: Development/Libraries License: ASL 2.0 URL: https://github.com/saltstack/libnacl Source0: https://pypi.python.org/packages/source/l/%{srcname}/%{srcname}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{srcname}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: libsodium Requires: libsodium >= 0.5.0 %if ! (0%{?rhel} == 5) BuildRequires: python BuildRequires: python-devel BuildRequires: python-setuptools %endif %if 0%{?with_python3} BuildRequires: python3-devel BuildRequires: python3-setuptools %endif %description This library is used to gain direct access to the functions exposed by Daniel J. Bernstein's nacl library via libsodium. It has been constructed to maintain extensive documentation on how to use nacl as well as being completely portable. The file in libnacl/__init__.py can be pulled out and placed directly in any project to give a single file binding to all of nacl. This is the Python 2 build of the module. %if 0%{?with_python3} %package -n python3-%{srcname} Summary: Python bindings for libsodium based on ctypes Group: Development/Libraries Requires: libsodium %description -n python3-%{srcname} This library is used to gain direct access to the functions exposed by Daniel J. Bernstein's nacl library via libsodium. It has been constructed to maintain extensive documentation on how to use nacl as well as being completely portable. The file in libnacl/__init__.py can be pulled out and placed directly in any project to give a single file binding to all of nacl. This is the Python 3 build of the module. %endif %if 0%{?rhel} == 5 %package -n python26-%{srcname} Summary: Python bindings for libsodium based on ctypes Group: Development/Libraries BuildRequires: python26 BuildRequires: libsodium BuildRequires: python26-devel Requires: python26 Requires: libsodium %description -n python26-%{srcname} This library is used to gain direct access to the functions exposed by Daniel J. Bernstein's nacl library via libsodium. It has been constructed to maintain extensive documentation on how to use nacl as well as being completely portable. The file in libnacl/__init__.py can be pulled out and placed directly in any project to give a single file binding to all of nacl. This is the Python 2 build of the module. %endif %prep %setup -q -n %{srcname}-%{version} %if 0%{?with_python3} rm -rf %{py3dir} cp -a . %{py3dir} %endif %build %{__python2} setup.py build %if 0%{?with_python3} pushd %{py3dir} %{__python3} setup.py build popd %endif %install rm -rf %{buildroot} %{__python2} setup.py install --skip-build --root %{buildroot} %if 0%{?with_python3} pushd %{py3dir} %{__python3} setup.py install --skip-build --root %{buildroot} popd %endif %clean rm -rf %{buildroot} %if 0%{?rhel} == 5 %files -n python26-%{srcname} %defattr(-,root,root,-) %{python2_sitelib}/* %else %files %defattr(-,root,root,-) %{python2_sitelib}/* %endif %if 0%{?with_python3} %files -n python3-%{srcname} %defattr(-,root,root,-) %{python3_sitelib}/* %endif %changelog * Thu Sep 4 2014 Erik Johnson - 1.3.5-1 - Updated to 1.3.5 * Fri Aug 22 2014 Erik Johnson - 1.3.3-1 - Updated to 1.3.3 * Fri Aug 8 2014 Erik Johnson - 1.3.2-1 - Updated to 1.3.2 * Fri Aug 8 2014 Erik Johnson - 1.3.1-1 - Updated to 1.3.1 * Thu Aug 7 2014 Erik Johnson - 1.3.0-1 - Updated to 1.3.0 * Fri Jun 20 2014 Erik Johnson - 1.1.0-1 - Updated to 1.1.0 * Fri Jun 20 2014 Erik Johnson - 1.0.0-1 - Initial build libnacl-1.6.1/README.rst0000644000175000001440000000330113134223407015240 0ustar thatchusers00000000000000============== Python libnacl ============== This library is used to gain direct access to the functions exposed by Daniel J. Bernstein's nacl library via libsodium. It has been constructed to maintain extensive documentation on how to use nacl as well as being completely portable. The file in libnacl/__init__.py can be pulled out and placed directly in any project to give a single file binding to all of nacl. Higher Level Classes ==================== The libnacl code also ships with many high level classes which make nacl cryptography easy and safe, for documentation please see: http://libnacl.readthedocs.org/ Why libnacl =========== There are a number of libraries out there binding to libsodium, so why make libnacl? 1. libnacl does not have any non-python hard deps outside of libsodium 2. libnacl does not need to be compiled 3. libnacl is easy to package and very portable 4. Inclusion of high level pythonic encryption classes 5. Ability to have a single embeddable and transferable bindings file that can be added directly to python applications without needing to dep libnacl This makes libnacl very portable, very easy to use and easy to distribute. Install ======= The libnacl code is easiy installed via a setup.py from the source or via pip. From Source: .. code-block:: bash tar xvf libnacl-1.5.2.tar.gz cd libnacl-1.5.2 python setup.py install Via Pip: .. code-block:: bash pip install libnacl Remember that libnacl can be installed for python 2 and 3. Linux distributions ------------------- Libnacl is shiped with many linux distributions, check your distribution package manager for the package ``python-libnacl``, ``python2-libnacl`` and/or ``python3-libnacl``. libnacl-1.6.1/AUTHORS0000644000175000001440000000005013133731616014624 0ustar thatchusers00000000000000Thomas S Hatch Sam Smith Pedro Algarvio libnacl-1.6.1/tests/0000755000175000001440000000000013200105202014700 5ustar thatchusers00000000000000libnacl-1.6.1/tests/runtests.py0000644000175000001440000000104513133731616017164 0ustar thatchusers00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # Import python libs import os import sys import unittest NACL_ROOT = os.path.abspath(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) UNIT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), 'unit')) sys.path.insert(0, NACL_ROOT) def run_suite(path=UNIT_ROOT): ''' Execute the unttest suite ''' loader = unittest.TestLoader() tests = loader.discover(path) unittest.TextTestRunner(verbosity=2).run(tests) if __name__ == '__main__': run_suite() libnacl-1.6.1/tests/unit/0000755000175000001440000000000013200105202015657 5ustar thatchusers00000000000000libnacl-1.6.1/tests/unit/test_raw_generichash.pyc0000644000175000001440000000320213134221741022576 0ustar thatchusers00000000000000ó Ž³oYc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNtTestGenericHashcBs eZdZd„Zd„ZRS(s Test sign functions cCs^d}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.(tlibnacltcrypto_generichashtassertNotEqual(tselftmsg1tmsg2tchash1tchash2((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyttest_keyless_generichash sc Csd}d}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.(Rtutilst rand_nonceRRt assertEqual( RRRtkey1tkey2tkhash1_1t khash1_1_2tkhash1_2tkhash2_1tkhash2_2((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyttest_key_generichashs$(t__name__t __module__t__doc__R R(((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyRs (RtunittesttTestCaseR(((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyts  libnacl-1.6.1/tests/unit/test_raw_random.py0000644000175000001440000000136113133731616021445 0ustar thatchusers00000000000000""" Basic tests for randombytes_* functions """ import libnacl import unittest class TestRandomBytes(unittest.TestCase): def test_randombytes_random(self): self.assertIsInstance(libnacl.randombytes_random(), int) def test_randombytes_uniform(self): self.assertIsInstance(libnacl.randombytes_uniform(200), int) freq = {libnacl.randombytes_uniform(256): 1 for _ in range(65536)} self.assertEqual(256, len(freq)) self.assertTrue(all(freq.values())) def test_randombytes(self): 'copied from libsodium default/randombytes.c' data = libnacl.randombytes(65536) freq = {x: 1 for x in data} self.assertEqual(256, len(freq)) self.assertTrue(all(freq.values())) libnacl-1.6.1/tests/unit/test_secret.pyc0000644000175000001440000000204713134221741020740 0ustar thatchusers00000000000000ó Ž³oYc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestSecretcBseZdZd„ZRS(s c Cs¹d}tjjƒ}|j|ƒ}|j||ƒtjj|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒ|j|ƒ}|j|ƒ}|j||ƒdS(Ns6But then of course African swallows are not migratory.(tlibnacltsecrett SecretBoxtencrypttassertNotEqualtsktdecryptt assertEqual( tselftmsgtboxtctxttbox2tclear1tclear2tctxt2tclear3((s7/home/thatch/projects/libnacl/tests/unit/test_secret.pyt test_secret s(t__name__t __module__t__doc__R(((s7/home/thatch/projects/libnacl/tests/unit/test_secret.pyRs(tlibnacl.secretRtunittesttTestCaseR(((s7/home/thatch/projects/libnacl/tests/unit/test_secret.pyts  libnacl-1.6.1/tests/unit/test_raw_auth_sym.pyc0000644000175000001440000000201013134221741022143 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestSecretBoxcBseZdZd„ZRS(s Test sign functions cCsrd}tjjƒ}tjjƒ}tj|||ƒ}|j||ƒtj|||ƒ}|j||ƒdS(Ns$Are you suggesting coconuts migrate?(tlibnacltutilst salsa_keyt rand_noncetcrypto_secretboxtassertNotEqualtcrypto_secretbox_opent assertEqual(tselftmsgtsk1tnonce1tenc_msgt clear_msg((s=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyttest_secret_box s(t__name__t __module__t__doc__R(((s=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyR s(Rt libnacl.utilstunittesttTestCaseR(((s=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyts   libnacl-1.6.1/tests/unit/test_raw_sign.pyc0000644000175000001440000000311713134221741021263 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNtTestSigncBs eZdZd„Zd„ZRS(s Test sign functions cCs@tjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS(N(tlibnacltcrypto_sign_keypairt assertEqualtlentcrypto_sign_PUBLICKEYBYTEStcrypto_sign_SECRETKEYBYTEStassertNotEqual(tselftvk1tsk1tvk2tsk2tvk3tsk3((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyttest_gen s cCsgd}tjƒ\}}tj||ƒ}|j||tjƒtj||ƒ}|j||ƒdS(Ns$Are you suggesting coconuts migrate?(RRt crypto_signRtcrypto_sign_BYTEStcrypto_sign_open(RtmsgR R tsigtsig_msg((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyttest_boxs (t__name__t __module__t__doc__RR(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyR s (Rt libnacl.utilstunittesttTestCaseR(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyts   libnacl-1.6.1/tests/unit/test_auth_verify.pyc0000644000175000001440000000433013134221741021775 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNtTestAuthVerifycBs eZdZd„Zd„ZRS(s$ Test onetimeauth functions c Cs d}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}|jtj|||ƒƒ|jtj|||ƒƒ|jtƒ}tj|||ƒWdQX|jd|jj kƒ|jtƒ}tj|||ƒWdQX|jd|jj kƒdS(NsQAnybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.sFailed to auth msg( tlibnacltutilst salsa_keyt crypto_autht assertTruetcrypto_auth_verifyt assertRaisest ValueErrort exceptiontargs(tselftmsgtkey1tkey2tsig1tsig2tcontext((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyttest_auth_verify sc Cs |jdtjƒƒd}tjtjƒ}tjtjƒ}tj||ƒ}tj||ƒ}|jtƒtj|dƒWdQX|jtƒtj||dƒWdQX|jtƒtjd||ƒWdQX|j tj|||ƒƒ|j tj|||ƒƒ|jtƒ}tj|||ƒWdQX|j d|j j kƒ|jtƒ}tj|||ƒWdQX|j d|j j kƒdS(Ntpoly1305sQAnybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.t too_shortsFailed to auth message( t assertEqualRtcrypto_onetimeauth_primitivet randombytestcrypto_onetimeauth_KEYBYTEStcrypto_onetimeauthRRtcrypto_onetimeauth_verifyRR R (R R R RRRR((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyttest_onetimeauth_verifys((t__name__t __module__t__doc__RR(((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyR s (Rt libnacl.utilstunittesttTestCaseR(((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyts   libnacl-1.6.1/tests/unit/test_save.pyc0000644000175000001440000000664613134221741020422 0ustar thatchusers00000000000000ó Ž³oYc@s‰ddlZddlZddlZddlZddlZddlZddlZddlZddl Z dej fd„ƒYZ dS(iÿÿÿÿNtTestSavecBs2eZdZd„Zd„Zd„Zd„ZRS(s cCs~d}tjjƒ}tjjƒ}tjƒ\}}tj|ƒtjƒ\}}tj|ƒ|j|ƒ|j|ƒtjj ||j ƒ}tjj ||j ƒ}|j |ƒ} |j |ƒ} tj j |ƒ} tj j |ƒ} tjj | | j ƒ} tjj | | j ƒ}|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j| ƒ}| j| ƒ}|j||ƒ|j||ƒtj j |ƒ}|j|j|jƒ|j|j |j ƒ|j|j|jƒtj|ƒtj|ƒdS(Ns:then leap out of the rabbit, taking the French by surprise(tlibnacltdualt DualSecretttempfiletmkstemptostclosetsavetpublictBoxtpktencrypttutilstload_keyt assertEqualtsktvktseedtdecrypttremove(tselftmsgtbobtalicetfh_tbob_patht alice_pathtbob_boxt alice_boxtbob_enct alice_enctbob_loadt alice_loadt bob_load_boxtalice_load_boxtbob_dect alice_dectbob2((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_loadsF     cCs…d}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j |ƒ}|j |ƒ}|j ||ƒdS(Ns:then leap out of the rabbit, taking the French by surprise( Rtsecrett SecretBoxRRRRRR RR RR(RRtboxRtbox_pathtlboxtctxttout_msg((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_load_secret9s  cCs’d}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j|ƒ}|j|ƒ}|j ||ƒtj |ƒdS(Ns:then leap out of the rabbit, taking the French by surprise( RtsigntSignerRRRRRR RRR(RRtsignerRt sign_patht signer_loadtsigned1tsigned2((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_load_signDs  cCstjjƒ}tjƒ\}}tj|ƒ|j|ƒtj|ƒ}t j dkr_dnd}|j |tj |ƒtj |ƒdS(Ntwin32i€i¶(RRRRRRRRtstattsystplatformRtST_MODER(RRRRtstatstexpected_perms((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_permsPs  (t__name__t __module__t__doc__R'R/R7R?(((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyRs  ' ( t libnacl.dualRtlibnacl.secrett libnacl.signt libnacl.utilsRR9tunittestRR:tTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyts         libnacl-1.6.1/tests/unit/test_raw_hash.py0000644000175000001440000000161013133731616021105 0ustar thatchusers00000000000000# Import nacl libs import libnacl from hashlib import sha256, sha512 # Import python libs import unittest class TestHash(unittest.TestCase): """ Test sign functions """ def test_hash(self): msg1 = b'Are you suggesting coconuts migrate?' msg2 = b'Not at all, they could be carried.' chash1 = libnacl.crypto_hash(msg1) chash2 = libnacl.crypto_hash(msg2) self.assertNotEqual(msg1, chash1) self.assertNotEqual(msg2, chash2) self.assertNotEqual(chash2, chash1) ref256 = sha256(msg1) self.assertEqual(ref256.digest_size, libnacl.crypto_hash_sha256_BYTES) self.assertEqual(ref256.digest(), libnacl.crypto_hash_sha256(msg1)) ref512 = sha512(msg1) self.assertEqual(ref512.digest_size, libnacl.crypto_hash_sha512_BYTES) self.assertEqual(ref512.digest(), libnacl.crypto_hash_sha512(msg1)) libnacl-1.6.1/tests/unit/test_sign.py0000644000175000001440000000126113133731616020253 0ustar thatchusers00000000000000# Import libnacl libs import libnacl.sign # Import pythonlibs import unittest class TestSigning(unittest.TestCase): ''' ''' def test_sign(self): msg = (b'Well, that\'s no ordinary rabbit. That\'s the most foul, ' b'cruel, and bad-tempered rodent you ever set eyes on.') signer = libnacl.sign.Signer() signed = signer.sign(msg) signature = signer.signature(msg) self.assertNotEqual(msg, signed) veri = libnacl.sign.Verifier(signer.hex_vk()) verified = veri.verify(signed) verified2 = veri.verify(signature + msg) self.assertEqual(verified, msg) self.assertEqual(verified2, msg) libnacl-1.6.1/tests/unit/test_dual.py0000644000175000001440000000372513133731616020247 0ustar thatchusers00000000000000# Import libnacl libs import libnacl.public import libnacl.dual # Import python libs import unittest class TestDual(unittest.TestCase): ''' ''' def test_secretkey(self): ''' ''' msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' bob = libnacl.dual.DualSecret() alice = libnacl.dual.DualSecret() bob_box = libnacl.public.Box(bob.sk, alice.pk) alice_box = libnacl.public.Box(alice.sk, bob.pk) bob_ctxt = bob_box.encrypt(msg) self.assertNotEqual(msg, bob_ctxt) bclear = alice_box.decrypt(bob_ctxt) self.assertEqual(msg, bclear) alice_ctxt = alice_box.encrypt(msg) self.assertNotEqual(msg, alice_ctxt) aclear = alice_box.decrypt(alice_ctxt) self.assertEqual(msg, aclear) self.assertNotEqual(bob_ctxt, alice_ctxt) def test_publickey(self): ''' ''' msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' bob = libnacl.dual.DualSecret() alice = libnacl.dual.DualSecret() alice_pk = libnacl.public.PublicKey(alice.pk) bob_box = libnacl.public.Box(bob.sk, alice_pk) alice_box = libnacl.public.Box(alice.sk, bob.pk) bob_ctxt = bob_box.encrypt(msg) self.assertNotEqual(msg, bob_ctxt) bclear = alice_box.decrypt(bob_ctxt) self.assertEqual(msg, bclear) def test_sign(self): msg = (b'Well, that\'s no ordinary rabbit. That\'s the most foul, ' b'cruel, and bad-tempered rodent you ever set eyes on.') signer = libnacl.dual.DualSecret() signed = signer.sign(msg) signature = signer.signature(msg) self.assertNotEqual(msg, signed) veri = libnacl.sign.Verifier(signer.hex_vk()) verified = veri.verify(signed) verified2 = veri.verify(signature + msg) self.assertEqual(verified, msg) self.assertEqual(verified2, msg) libnacl-1.6.1/tests/unit/test_raw_generichash.py0000644000175000001440000000267413133731616022455 0ustar thatchusers00000000000000# Import nacl libs import libnacl # Import python libs import unittest class TestGenericHash(unittest.TestCase): ''' Test sign functions ''' def test_keyless_generichash(self): msg1 = b'Are you suggesting coconuts migrate?' msg2 = b'Not at all, they could be carried.' chash1 = libnacl.crypto_generichash(msg1) chash2 = libnacl.crypto_generichash(msg2) self.assertNotEqual(msg1, chash1) self.assertNotEqual(msg2, chash2) self.assertNotEqual(chash2, chash1) def test_key_generichash(self): msg1 = b'Are you suggesting coconuts migrate?' msg2 = b'Not at all, they could be carried.' key1 = libnacl.utils.rand_nonce() key2 = libnacl.utils.rand_nonce() khash1_1 = libnacl.crypto_generichash(msg1, key1) khash1_1_2 = libnacl.crypto_generichash(msg1, key1) khash1_2 = libnacl.crypto_generichash(msg1, key2) khash2_1 = libnacl.crypto_generichash(msg2, key1) khash2_2 = libnacl.crypto_generichash(msg2, key2) self.assertNotEqual(msg1, khash1_1) self.assertNotEqual(msg1, khash1_2) self.assertNotEqual(msg2, khash2_1) self.assertNotEqual(msg2, khash2_2) self.assertNotEqual(khash1_1, khash1_2) self.assertNotEqual(khash2_1, khash2_2) self.assertNotEqual(khash1_1, khash2_1) self.assertNotEqual(khash1_2, khash2_2) self.assertEqual(khash1_1, khash1_1_2) libnacl-1.6.1/tests/unit/test_raw_sign.py0000644000175000001440000000254313133731616021130 0ustar thatchusers00000000000000# Import libnacl libs import libnacl import libnacl.utils # Import python libs import unittest class TestSign(unittest.TestCase): ''' Test sign functions ''' def test_gen(self): vk1, sk1 = libnacl.crypto_sign_keypair() vk2, sk2 = libnacl.crypto_sign_keypair() vk3, sk3 = libnacl.crypto_sign_keypair() self.assertEqual(len(vk1), libnacl.crypto_sign_PUBLICKEYBYTES) self.assertEqual(len(sk1), libnacl.crypto_sign_SECRETKEYBYTES) self.assertEqual(len(vk2), libnacl.crypto_sign_PUBLICKEYBYTES) self.assertEqual(len(sk2), libnacl.crypto_sign_SECRETKEYBYTES) self.assertEqual(len(vk3), libnacl.crypto_sign_PUBLICKEYBYTES) self.assertEqual(len(sk3), libnacl.crypto_sign_SECRETKEYBYTES) self.assertNotEqual(vk1, sk1) self.assertNotEqual(vk2, sk2) self.assertNotEqual(vk3, sk3) self.assertNotEqual(vk1, vk2) self.assertNotEqual(vk1, vk3) self.assertNotEqual(sk1, sk2) self.assertNotEqual(sk2, sk3) def test_box(self): msg = b'Are you suggesting coconuts migrate?' # run 1 vk1, sk1 = libnacl.crypto_sign_keypair() sig = libnacl.crypto_sign(msg, sk1) self.assertEqual(msg, sig[libnacl.crypto_sign_BYTES:]) sig_msg = libnacl.crypto_sign_open(sig, vk1) self.assertEqual(msg, sig_msg) libnacl-1.6.1/tests/unit/test_raw_public.pyc0000644000175000001440000000567613134221741021615 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestPubliccBs2eZdZd„Zd„Zd„Zd„ZRS(s Test public functions cCs@tjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS(N(tlibnacltcrypto_box_keypairt assertEqualtlentcrypto_box_PUBLICKEYBYTEStassertNotEqual(tselftpk1tsk1tpk2tsk2tpk3tsk3((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyttest_gen s cCs0d}tjjƒ}tjƒ\}}tjƒ\}}tj||||ƒ}|j||ƒtj||||ƒ}|j||ƒtjjƒ} tjƒ\} } tjƒ\} } tj|| | | ƒ}|j||ƒtj|| | | ƒ}|j||ƒ|j|| ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?(Rtutilst rand_nonceRt crypto_boxRtcrypto_box_openR(Rtmsgtnonce1RR R R tenc_msgt clear_msgtnonce2R R tpk4tsk4tenc_msg2t clear_msg2((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyttest_boxs"c Cs«d}tjjƒ}tjƒ\}}tjƒ\}}tj||ƒ}tj||ƒ}tj|||ƒ} |j|| ƒtj| ||ƒ} |j| |ƒdS(Ns$Are you suggesting coconuts migrate?( RRRRtcrypto_box_beforenmtcrypto_box_afternmRtcrypto_box_open_afternmR( RRRRR R R tk1tk2RR((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyt test_boxnm5sc CsÌd}tjƒ\}}tj||ƒ}|j||ƒtj|||ƒ}|j||ƒtjƒ\}}tj||ƒ}|j||ƒtj|||ƒ} |j| |ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?(RRtcrypto_box_sealRtcrypto_box_seal_openR( RRtpktskRRR R RR((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyt test_box_sealBs(t__name__t __module__t__doc__RRR"R'(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyR s    (Rt libnacl.utilstunittesttTestCaseR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyts   libnacl-1.6.1/tests/unit/__init__.pyc0000644000175000001440000000021313173442023020145 0ustar thatchusers00000000000000ó Ž³oYc@sdS(N((((s4/home/thatch/projects/libnacl/tests/unit/__init__.pytslibnacl-1.6.1/tests/unit/test_blake.py0000644000175000001440000000270413133731616020374 0ustar thatchusers00000000000000# Import nacl libs import libnacl.blake # Import python libs import unittest class TestBlake(unittest.TestCase): ''' Test sign functions ''' def test_keyless_blake(self): msg1 = b'Are you suggesting coconuts migrate?' msg2 = b'Not at all, they could be carried.' chash1 = libnacl.crypto_generichash(msg1) chash2 = libnacl.crypto_generichash(msg2) self.assertNotEqual(msg1, chash1) self.assertNotEqual(msg2, chash2) self.assertNotEqual(chash2, chash1) def test_key_blake(self): msg1 = b'Are you suggesting coconuts migrate?' msg2 = b'Not at all, they could be carried.' key1 = libnacl.utils.rand_nonce() key2 = libnacl.utils.rand_nonce() khash1_1 = libnacl.blake.Blake2b(msg1, key1).digest() khash1_1_2 = libnacl.blake.Blake2b(msg1, key1).digest() khash1_2 = libnacl.blake.Blake2b(msg1, key2).digest() khash2_1 = libnacl.blake.blake2b(msg2, key1).digest() khash2_2 = libnacl.blake.blake2b(msg2, key2).digest() self.assertNotEqual(msg1, khash1_1) self.assertNotEqual(msg1, khash1_2) self.assertNotEqual(msg2, khash2_1) self.assertNotEqual(msg2, khash2_2) self.assertNotEqual(khash1_1, khash1_2) self.assertNotEqual(khash2_1, khash2_2) self.assertNotEqual(khash1_1, khash2_1) self.assertNotEqual(khash1_2, khash2_2) self.assertEqual(khash1_1, khash1_1_2) libnacl-1.6.1/tests/unit/test_aead.pyc0000644000175000001440000000357613165437024020364 0ustar thatchusers00000000000000ó =ÖYc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNtTestAEADcBsJeZdZejejdƒd„ƒZejejdƒd„ƒZ RS(s sAES256-GCM AEAD not availablec Csìd}d}tjjƒjƒ}|j||ƒ}|j||ƒtjj|jƒjƒ}|j|t|ƒƒ}|j ||ƒ|j|t|ƒƒ}|j ||ƒ|j||ƒ}|j|t|ƒƒ} |j | |ƒdS(NsFYou've got two empty halves of coconuts and your bangin' 'em together.s"3( tlibnacltaeadtAEADt useAESGCMtencrypttassertNotEqualtsktdecrypttlent assertEqual( tselftmsgtaadtboxtctxttbox2tclear1tclear2tctxt2tclear3((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyt test_gcm_aead ss3IETF variant of ChaCha20Poly1305 AEAD not availablec Csàd}d}tjjƒ}|j||ƒ}|j||ƒtjj|jƒ}|j|t|ƒƒ}|j||ƒ|j|t|ƒƒ}|j||ƒ|j||ƒ}|j|t|ƒƒ} |j| |ƒdS(Ns&Our King? Well i didn't vote for you!!s"3( RRRRRRRR R ( R R R RRRRRRR((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyttest_ietf_aeads( t__name__t __module__t__doc__tunittestt skipUnlessRtHAS_AEAD_AES256GCMRtHAS_AEAD_CHACHA20POLY1305_IETFR(((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyRs(t libnacl.aeadRRtTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyts  libnacl-1.6.1/tests/unit/test_verify.pyc0000644000175000001440000000644613134221741020766 0ustar thatchusers00000000000000ó Ž³oYc@sTdZddlZddlZdejfd„ƒYZdejfd„ƒYZdS(s" Basic tests for verify functions iÿÿÿÿNt TestVerifycBs#eZd„Zd„Zd„ZRS(cCsÃtjdƒ}|}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@cd7s  )libnacl-1.6.1/tests/unit/test_raw_hash.pyc0000644000175000001440000000241313134221741021244 0ustar thatchusers00000000000000ó Ž³oYc@sKddlZddlmZmZddlZdejfd„ƒYZdS(iÿÿÿÿN(tsha256tsha512tTestHashcBseZdZd„ZRS(s Test sign functions cCsàd}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒt|ƒ}|j|jtjƒ|j|jƒtj|ƒƒt |ƒ}|j|jtj ƒ|j|jƒtj |ƒƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.( tlibnaclt crypto_hashtassertNotEqualRt assertEqualt digest_sizetcrypto_hash_sha256_BYTEStdigesttcrypto_hash_sha256Rtcrypto_hash_sha512_BYTEStcrypto_hash_sha512(tselftmsg1tmsg2tchash1tchash2tref256tref512((s9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyt test_hash s  (t__name__t __module__t__doc__R(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyR s(RthashlibRRtunittesttTestCaseR(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyts  libnacl-1.6.1/tests/unit/test_public.py0000644000175000001440000000263213133731616020574 0ustar thatchusers00000000000000# Import libnacl libs import libnacl.public # Import python libs import unittest class TestPublic(unittest.TestCase): ''' ''' def test_secretkey(self): ''' ''' msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' bob = libnacl.public.SecretKey() alice = libnacl.public.SecretKey() bob_box = libnacl.public.Box(bob.sk, alice.pk) alice_box = libnacl.public.Box(alice.sk, bob.pk) bob_ctxt = bob_box.encrypt(msg) self.assertNotEqual(msg, bob_ctxt) bclear = alice_box.decrypt(bob_ctxt) self.assertEqual(msg, bclear) alice_ctxt = alice_box.encrypt(msg) self.assertNotEqual(msg, alice_ctxt) aclear = alice_box.decrypt(alice_ctxt) self.assertEqual(msg, aclear) self.assertNotEqual(bob_ctxt, alice_ctxt) def test_publickey(self): ''' ''' msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' bob = libnacl.public.SecretKey() alice = libnacl.public.SecretKey() alice_pk = libnacl.public.PublicKey(alice.pk) bob_box = libnacl.public.Box(bob.sk, alice_pk) alice_box = libnacl.public.Box(alice.sk, bob.pk) bob_ctxt = bob_box.encrypt(msg) self.assertNotEqual(msg, bob_ctxt) bclear = alice_box.decrypt(bob_ctxt) self.assertEqual(msg, bclear) libnacl-1.6.1/tests/unit/__init__.py0000644000175000001440000000003013133731616020004 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- libnacl-1.6.1/tests/unit/test_version.py0000644000175000001440000000133613133731616021003 0ustar thatchusers00000000000000""" Basic tests for version functions """ import libnacl import unittest # These are copied from libsodium test suite class TestSodiumVersion(unittest.TestCase): def test_version_string(self): self.assertIsNotNone(libnacl.sodium_version_string()) def test_library_version_major(self): # Using assertTrue to keep tests "uniform" and keep compatibility with # Python 2.6 self.assertTrue(libnacl.sodium_library_version_major() > 0) def test_library_version_minor(self): # Using assertTrue to keep tests "uniform" and keep compatibility with # Python 2.6 (assertGreaterEqual appeared in Python 2.7 only) self.assertTrue(libnacl.sodium_library_version_minor() >= 0) libnacl-1.6.1/tests/unit/test_public.pyc0000644000175000001440000000331713134221741020732 0ustar thatchusers00000000000000ó Ž³oYc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestPubliccBs eZdZd„Zd„ZRS(s c Csêd}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j|ƒ} |j || ƒ|j||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( tlibnacltpublict SecretKeytBoxtsktpktencrypttassertNotEqualtdecryptt assertEqual( tselftmsgtbobtalicetbob_boxt alice_boxtbob_ctxttbcleart alice_ctxttaclear((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyttest_secretkey sc Cs®d}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( RRRt PublicKeyRRRRRR R ( R R R Rtalice_pkRRRR((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyttest_publickeys(t__name__t __module__t__doc__RR(((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyRs (tlibnacl.publicRtunittesttTestCaseR(((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyts  libnacl-1.6.1/tests/unit/test_secret.py0000644000175000001440000000121513133731616020577 0ustar thatchusers00000000000000# Import libnacl libs import libnacl.secret # Import python libs import unittest class TestSecret(unittest.TestCase): ''' ''' def test_secret(self): msg = b'But then of course African swallows are not migratory.' box = libnacl.secret.SecretBox() ctxt = box.encrypt(msg) self.assertNotEqual(msg, ctxt) box2 = libnacl.secret.SecretBox(box.sk) clear1 = box.decrypt(ctxt) self.assertEqual(msg, clear1) clear2 = box2.decrypt(ctxt) self.assertEqual(clear1, clear2) ctxt2 = box2.encrypt(msg) clear3 = box.decrypt(ctxt2) self.assertEqual(clear3, msg) libnacl-1.6.1/tests/unit/test_raw_random.pyc0000644000175000001440000000357213134221741021610 0ustar thatchusers00000000000000ó Ž³oYc@s;dZddlZddlZdejfd„ƒYZdS(s) Basic tests for randombytes_* functions iÿÿÿÿNtTestRandomBytescBs#eZd„Zd„Zd„ZRS(cCs|jtjƒtƒdS(N(tassertIsInstancetlibnacltrandombytes_randomtint(tself((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyttest_randombytes_random scCsb|jtjdƒtƒd„tdƒDƒ}|jdt|ƒƒ|jt|j ƒƒƒdS(NiÈcSs"i|]}dtjdƒ“qS(ii(Rtrandombytes_uniform(t.0t_((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pys s ii( RRRRtranget assertEqualtlent assertTruetalltvalues(Rtfreq((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyttest_randombytes_uniform scCsRtjdƒ}d„|Dƒ}|jdt|ƒƒ|jt|jƒƒƒdS(s+copied from libsodium default/randombytes.cicSsi|]}d|“qS(i((Rtx((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pys s iN(Rt randombytesR R R RR(RtdataR((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyttest_randombytess(t__name__t __module__RRR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyR s  (t__doc__RtunittesttTestCaseR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyts  libnacl-1.6.1/tests/unit/test_seal.py0000644000175000001440000000202613133731616020237 0ustar thatchusers00000000000000# Import libnacl libs import libnacl.sealed import libnacl.public # Import python libs import unittest class TestSealed(unittest.TestCase): ''' ''' def test_secretkey(self): ''' ''' msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' key = libnacl.public.SecretKey() box = libnacl.sealed.SealedBox(key) ctxt = box.encrypt(msg) self.assertNotEqual(msg, ctxt) bclear = box.decrypt(ctxt) self.assertEqual(msg, bclear) def test_publickey_only(self): ''' ''' msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' key = libnacl.public.SecretKey() key_public = libnacl.public.PublicKey(key.pk) box = libnacl.sealed.SealedBox(key_public) ctxt = box.encrypt(msg) self.assertNotEqual(msg, ctxt) decrypting_box = libnacl.sealed.SealedBox(key) bclear = decrypting_box.decrypt(ctxt) self.assertEqual(msg, bclear) libnacl-1.6.1/tests/unit/test_raw_secret.py0000644000175000001440000000163413133731616021455 0ustar thatchusers00000000000000# Import libnacl libs import libnacl import libnacl.utils # Import python libs import unittest class TestSecret(unittest.TestCase): """ Test secret functions """ def test_secretbox(self): msg = b'Are you suggesting coconuts migrate?' nonce = libnacl.utils.rand_nonce() key = libnacl.utils.salsa_key() c = libnacl.crypto_secretbox(msg, nonce, key) m = libnacl.crypto_secretbox_open(c, nonce, key) self.assertEqual(msg, m) with self.assertRaises(ValueError): libnacl.crypto_secretbox(msg, b'too_short', key) with self.assertRaises(ValueError): libnacl.crypto_secretbox(msg, nonce, b'too_short') with self.assertRaises(ValueError): libnacl.crypto_secretbox_open(c, b'too_short', key) with self.assertRaises(ValueError): libnacl.crypto_secretbox_open(c, nonce, b'too_short') libnacl-1.6.1/tests/unit/test_raw_auth_sym.py0000644000175000001440000000106013133731616022012 0ustar thatchusers00000000000000# Import nacl libs import libnacl import libnacl.utils # Import python libs import unittest class TestSecretBox(unittest.TestCase): ''' Test sign functions ''' def test_secret_box(self): msg = b'Are you suggesting coconuts migrate?' sk1 = libnacl.utils.salsa_key() nonce1 = libnacl.utils.rand_nonce() enc_msg = libnacl.crypto_secretbox(msg, nonce1, sk1) self.assertNotEqual(msg, enc_msg) clear_msg = libnacl.crypto_secretbox_open(enc_msg, nonce1, sk1) self.assertEqual(msg, clear_msg) libnacl-1.6.1/tests/unit/test_blake.pyc0000644000175000001440000000325713134221741020535 0ustar thatchusers00000000000000ó Ž³oYc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestBlakecBs eZdZd„Zd„ZRS(s Test sign functions cCs^d}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.(tlibnacltcrypto_generichashtassertNotEqual(tselftmsg1tmsg2tchash1tchash2((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyttest_keyless_blake sc CsEd}d}tjjƒ}tjjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.( Rtutilst rand_noncetblaketBlake2btdigesttblake2bRt assertEqual( RRRtkey1tkey2tkhash1_1t khash1_1_2tkhash1_2tkhash2_1tkhash2_2((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyttest_key_blakes$(t__name__t __module__t__doc__R R(((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyRs (t libnacl.blakeRtunittesttTestCaseR(((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyts  libnacl-1.6.1/tests/unit/test_dual.pyc0000644000175000001440000000450613134221741020402 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNtTestDualcBs)eZdZd„Zd„Zd„ZRS(s c Csêd}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j |ƒ} |j || ƒ|j||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( tlibnacltdualt DualSecrettpublictBoxtsktpktencrypttassertNotEqualtdecryptt assertEqual( tselftmsgtbobtalicetbob_boxt alice_boxtbob_ctxttbcleart alice_ctxttaclear((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyttest_secretkey sc Cs®d}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j ||ƒ|j |ƒ}|j ||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( RRRRt PublicKeyRRRRR R R ( R R RRtalice_pkRRRR((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyttest_publickeyscCs¡d}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j ||ƒ|j ||ƒdS(NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.( RRRtsignt signatureR tVerifierthex_vktverifyR (R R tsignertsignedRtveritverifiedt verified2((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyt test_sign+s(t__name__t __module__t__doc__RRR$(((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyRs  (tlibnacl.publicRt libnacl.dualtunittesttTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyts   libnacl-1.6.1/tests/unit/test_sign.pyc0000644000175000001440000000207713134221741020416 0ustar thatchusers00000000000000ó Ž³oYc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestSigningcBseZdZd„ZRS(s cCs¡d}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j||ƒ|j||ƒdS(NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.( tlibnacltsigntSignert signaturetassertNotEqualtVerifierthex_vktverifyt assertEqual(tselftmsgtsignertsignedRtveritverifiedt verified2((s5/home/thatch/projects/libnacl/tests/unit/test_sign.pyt test_sign s(t__name__t __module__t__doc__R(((s5/home/thatch/projects/libnacl/tests/unit/test_sign.pyRs(t libnacl.signRtunittesttTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_sign.pyts  libnacl-1.6.1/tests/unit/test_auth_verify.py0000644000175000001440000000444513133731616021647 0ustar thatchusers00000000000000# Import nacl libs import libnacl import libnacl.utils # Import python libs import unittest class TestAuthVerify(unittest.TestCase): ''' Test onetimeauth functions ''' def test_auth_verify(self): msg = b'Anybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.' key1 = libnacl.utils.salsa_key() key2 = libnacl.utils.salsa_key() sig1 = libnacl.crypto_auth(msg, key1) sig2 = libnacl.crypto_auth(msg, key2) self.assertTrue(libnacl.crypto_auth_verify(sig1, msg, key1)) self.assertTrue(libnacl.crypto_auth_verify(sig2, msg, key2)) with self.assertRaises(ValueError) as context: libnacl.crypto_auth_verify(sig1, msg, key2) self.assertTrue('Failed to auth msg' in context.exception.args) with self.assertRaises(ValueError) as context: libnacl.crypto_auth_verify(sig2, msg, key1) self.assertTrue('Failed to auth msg' in context.exception.args) def test_onetimeauth_verify(self): self.assertEqual("poly1305", libnacl.crypto_onetimeauth_primitive()) msg = b'Anybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.' key1 = libnacl.randombytes(libnacl.crypto_onetimeauth_KEYBYTES) key2 = libnacl.randombytes(libnacl.crypto_onetimeauth_KEYBYTES) sig1 = libnacl.crypto_onetimeauth(msg, key1) sig2 = libnacl.crypto_onetimeauth(msg, key2) with self.assertRaises(ValueError): libnacl.crypto_onetimeauth(msg, b'too_short') with self.assertRaises(ValueError): libnacl.crypto_onetimeauth_verify(sig1, msg, b'too_short') with self.assertRaises(ValueError): libnacl.crypto_onetimeauth_verify(b'too_short', msg, key1) self.assertTrue(libnacl.crypto_onetimeauth_verify(sig1, msg, key1)) self.assertTrue(libnacl.crypto_onetimeauth_verify(sig2, msg, key2)) with self.assertRaises(ValueError) as context: libnacl.crypto_onetimeauth_verify(sig1, msg, key2) self.assertTrue('Failed to auth message' in context.exception.args) with self.assertRaises(ValueError) as context: libnacl.crypto_onetimeauth_verify(sig2, msg, key1) self.assertTrue('Failed to auth message' in context.exception.args) libnacl-1.6.1/tests/unit/test_aead.py0000644000175000001440000000276313165436407020222 0ustar thatchusers00000000000000# Import libnacl libs import libnacl.aead # Import python libs import unittest class TestAEAD(unittest.TestCase): ''' ''' @unittest.skipUnless(libnacl.HAS_AEAD_AES256GCM, 'AES256-GCM AEAD not available') def test_gcm_aead(self): msg = b"You've got two empty halves of coconuts and your bangin' 'em together." aad = b'\x00\x11\x22\x33' box = libnacl.aead.AEAD().useAESGCM() ctxt = box.encrypt(msg, aad) self.assertNotEqual(msg, ctxt) box2 = libnacl.aead.AEAD(box.sk).useAESGCM() clear1 = box.decrypt(ctxt, len(aad)) self.assertEqual(msg, clear1) clear2 = box2.decrypt(ctxt, len(aad)) self.assertEqual(clear1, clear2) ctxt2 = box2.encrypt(msg, aad) clear3 = box.decrypt(ctxt2, len(aad)) self.assertEqual(clear3, msg) @unittest.skipUnless(libnacl.HAS_AEAD_CHACHA20POLY1305_IETF, 'IETF variant of ChaCha20Poly1305 AEAD not available') def test_ietf_aead(self): msg = b"Our King? Well i didn't vote for you!!" aad = b'\x00\x11\x22\x33' box = libnacl.aead.AEAD() ctxt = box.encrypt(msg, aad) self.assertNotEqual(msg, ctxt) box2 = libnacl.aead.AEAD(box.sk) clear1 = box.decrypt(ctxt, len(aad)) self.assertEqual(msg, clear1) clear2 = box2.decrypt(ctxt, len(aad)) self.assertEqual(clear1, clear2) ctxt2 = box2.encrypt(msg, aad) clear3 = box.decrypt(ctxt2, len(aad)) self.assertEqual(clear3, msg) libnacl-1.6.1/tests/unit/test_raw_public.py0000644000175000001440000000621213133731616021443 0ustar thatchusers00000000000000# Import libnacl libs import libnacl import libnacl.utils # Import python libs import unittest class TestPublic(unittest.TestCase): ''' Test public functions ''' def test_gen(self): pk1, sk1 = libnacl.crypto_box_keypair() pk2, sk2 = libnacl.crypto_box_keypair() pk3, sk3 = libnacl.crypto_box_keypair() self.assertEqual(len(pk1), libnacl.crypto_box_PUBLICKEYBYTES) self.assertEqual(len(sk1), libnacl.crypto_box_PUBLICKEYBYTES) self.assertEqual(len(pk2), libnacl.crypto_box_PUBLICKEYBYTES) self.assertEqual(len(sk2), libnacl.crypto_box_PUBLICKEYBYTES) self.assertEqual(len(pk3), libnacl.crypto_box_PUBLICKEYBYTES) self.assertEqual(len(sk3), libnacl.crypto_box_PUBLICKEYBYTES) self.assertNotEqual(pk1, sk1) self.assertNotEqual(pk2, sk2) self.assertNotEqual(pk3, sk3) self.assertNotEqual(pk1, pk2) self.assertNotEqual(pk1, pk3) self.assertNotEqual(sk1, sk2) self.assertNotEqual(sk2, sk3) def test_box(self): msg = b'Are you suggesting coconuts migrate?' # run 1 nonce1 = libnacl.utils.rand_nonce() pk1, sk1 = libnacl.crypto_box_keypair() pk2, sk2 = libnacl.crypto_box_keypair() enc_msg = libnacl.crypto_box(msg, nonce1, pk2, sk1) self.assertNotEqual(msg, enc_msg) clear_msg = libnacl.crypto_box_open(enc_msg, nonce1, pk1, sk2) self.assertEqual(clear_msg, msg) # run 2 nonce2 = libnacl.utils.rand_nonce() pk3, sk3 = libnacl.crypto_box_keypair() pk4, sk4 = libnacl.crypto_box_keypair() enc_msg2 = libnacl.crypto_box(msg, nonce2, pk4, sk3) self.assertNotEqual(msg, enc_msg2) clear_msg2 = libnacl.crypto_box_open(enc_msg2, nonce2, pk3, sk4) self.assertEqual(clear_msg2, msg) # Check bits self.assertNotEqual(nonce1, nonce2) self.assertNotEqual(enc_msg, enc_msg2) def test_boxnm(self): msg = b'Are you suggesting coconuts migrate?' # run 1 nonce1 = libnacl.utils.rand_nonce() pk1, sk1 = libnacl.crypto_box_keypair() pk2, sk2 = libnacl.crypto_box_keypair() k1 = libnacl.crypto_box_beforenm(pk2, sk1) k2 = libnacl.crypto_box_beforenm(pk1, sk2) enc_msg = libnacl.crypto_box_afternm(msg, nonce1, k1) self.assertNotEqual(msg, enc_msg) clear_msg = libnacl.crypto_box_open_afternm(enc_msg, nonce1, k2) self.assertEqual(clear_msg, msg) def test_box_seal(self): msg = b'Are you suggesting coconuts migrate?' # run 1 pk, sk = libnacl.crypto_box_keypair() enc_msg = libnacl.crypto_box_seal(msg, pk) self.assertNotEqual(msg, enc_msg) clear_msg = libnacl.crypto_box_seal_open(enc_msg, pk, sk) self.assertEqual(clear_msg, msg) # run 2 pk2, sk2 = libnacl.crypto_box_keypair() enc_msg2 = libnacl.crypto_box_seal(msg, pk2) self.assertNotEqual(msg, enc_msg2) clear_msg2 = libnacl.crypto_box_seal_open(enc_msg2, pk2, sk2) self.assertEqual(clear_msg2, msg) # Check bits self.assertNotEqual(enc_msg, enc_msg2) libnacl-1.6.1/tests/unit/test_seal.pyc0000644000175000001440000000302413134221741020373 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestSealedcBs eZdZd„Zd„ZRS(s cCsid}tjjƒ}tjj|ƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( tlibnacltpublict SecretKeytsealedt SealedBoxtencrypttassertNotEqualtdecryptt assertEqual(tselftmsgtkeytboxtctxttbclear((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyttest_secretkey scCsd}tjjƒ}tjj|jƒ}tjj|ƒ}|j|ƒ}|j||ƒtjj|ƒ}|j |ƒ}|j ||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( RRRt PublicKeytpkRRRRRR (R R R t key_publicR Rtdecrypting_boxR((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyttest_publickey_onlys(t__name__t __module__t__doc__RR(((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyRs (tlibnacl.sealedRtlibnacl.publictunittesttTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyts   libnacl-1.6.1/tests/unit/test_raw_secret.pyc0000644000175000001440000000225613134221741021613 0ustar thatchusers00000000000000ó Ž³oYc@sAddlZddlZddlZdejfd„ƒYZdS(iÿÿÿÿNt TestSecretcBseZdZd„ZRS(s Test secret functions c Csd}tjjƒ}tjjƒ}tj|||ƒ}tj|||ƒ}|j||ƒ|jtƒtj|d|ƒWdQX|jtƒtj||dƒWdQX|jtƒtj|d|ƒWdQX|jtƒtj||dƒWdQXdS(Ns$Are you suggesting coconuts migrate?t too_short( tlibnacltutilst rand_noncet salsa_keytcrypto_secretboxtcrypto_secretbox_opent assertEqualt assertRaisest ValueError(tselftmsgtnoncetkeytctm((s;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyttest_secretbox s(t__name__t __module__t__doc__R(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyR s(Rt libnacl.utilstunittesttTestCaseR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyts   libnacl-1.6.1/tests/unit/test_save.py0000644000175000001440000000603613133731616020256 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- # Import libnacl libs import libnacl.dual import libnacl.secret import libnacl.sign import libnacl.utils # Import pythonlibs import os import stat import unittest import tempfile import sys class TestSave(unittest.TestCase): ''' ''' def test_save_load(self): msg = b'then leap out of the rabbit, taking the French by surprise' bob = libnacl.dual.DualSecret() alice = libnacl.dual.DualSecret() fh_, bob_path = tempfile.mkstemp() os.close(fh_) fh_, alice_path = tempfile.mkstemp() os.close(fh_) bob.save(bob_path) alice.save(alice_path) bob_box = libnacl.public.Box(bob, alice.pk) alice_box = libnacl.public.Box(alice, bob.pk) bob_enc = bob_box.encrypt(msg) alice_enc = alice_box.encrypt(msg) bob_load = libnacl.utils.load_key(bob_path) alice_load = libnacl.utils.load_key(alice_path) bob_load_box = libnacl.public.Box(bob_load, alice_load.pk) alice_load_box = libnacl.public.Box(alice_load, bob_load.pk) self.assertEqual(bob.sk, bob_load.sk) self.assertEqual(bob.pk, bob_load.pk) self.assertEqual(bob.vk, bob_load.vk) self.assertEqual(bob.seed, bob_load.seed) self.assertEqual(alice.sk, alice_load.sk) self.assertEqual(alice.pk, alice_load.pk) self.assertEqual(alice.vk, alice_load.vk) self.assertEqual(alice.seed, alice_load.seed) bob_dec = alice_load_box.decrypt(bob_enc) alice_dec = bob_load_box.decrypt(alice_enc) self.assertEqual(bob_dec, msg) self.assertEqual(alice_dec, msg) bob2 = libnacl.utils.load_key(bob_path) self.assertEqual(bob.sk, bob2.sk) self.assertEqual(bob.pk, bob2.pk) self.assertEqual(bob.vk, bob2.vk) os.remove(bob_path) os.remove(alice_path) def test_save_load_secret(self): msg = b'then leap out of the rabbit, taking the French by surprise' box = libnacl.secret.SecretBox() fh_, box_path = tempfile.mkstemp() os.close(fh_) box.save(box_path) lbox = libnacl.utils.load_key(box_path) ctxt = box.encrypt(msg) out_msg = lbox.decrypt(ctxt) self.assertEqual(msg, out_msg) def test_save_load_sign(self): msg = b'then leap out of the rabbit, taking the French by surprise' signer = libnacl.sign.Signer() fh_, sign_path = tempfile.mkstemp() os.close(fh_) signer.save(sign_path) signer_load = libnacl.utils.load_key(sign_path) signed1 = signer.sign(msg) signed2 = signer_load.sign(msg) self.assertEqual(signed1, signed2) os.remove(sign_path) def test_save_perms(self): bob = libnacl.dual.DualSecret() fh_, bob_path = tempfile.mkstemp() os.close(fh_) bob.save(bob_path) stats = os.stat(bob_path) expected_perms = 0o100600 if sys.platform != 'win32' else 0o100666 self.assertEqual(stats[stat.ST_MODE], expected_perms) os.remove(bob_path) libnacl-1.6.1/tests/unit/test_verify.py0000644000175000001440000000455113133731616020624 0ustar thatchusers00000000000000""" Basic tests for verify functions """ import libnacl import unittest # These are copied from libsodium test suite class TestVerify(unittest.TestCase): def test_verify16(self): v16 = libnacl.randombytes_buf(16) v16x = v16[:] self.assertTrue(libnacl.crypto_verify_16(v16, v16x)) self.assertTrue(libnacl.bytes_eq(v16, v16x)) v16x = bytearray(v16x) v16x[libnacl.randombytes_random() & 15] += 1 v16x = bytes(v16x) self.assertFalse(libnacl.crypto_verify_16(v16, v16x)) self.assertFalse(libnacl.bytes_eq(v16, v16x)) self.assertEqual(libnacl.crypto_verify_16_BYTES, 16) def test_verify32(self): v32 = libnacl.randombytes_buf(32) v32x = v32[:] self.assertTrue(libnacl.crypto_verify_32(v32, v32x)) self.assertTrue(libnacl.bytes_eq(v32, v32x)) v32x = bytearray(v32x) v32x[libnacl.randombytes_random() & 31] += 1 v32x = bytes(v32x) self.assertFalse(libnacl.crypto_verify_32(v32, v32x)) self.assertFalse(libnacl.bytes_eq(v32, v32x)) self.assertEqual(libnacl.crypto_verify_32_BYTES, 32) def test_verify64(self): v64 = libnacl.randombytes_buf(64) v64x = v64[:] self.assertTrue(libnacl.crypto_verify_64(v64, v64x)) self.assertTrue(libnacl.bytes_eq(v64, v64x)) v64x = bytearray(v64x) v64x[libnacl.randombytes_random() & 63] += 1 v64x = bytes(v64x) self.assertFalse(libnacl.crypto_verify_64(v64, v64x)) self.assertFalse(libnacl.bytes_eq(v64, v64x)) self.assertEqual(libnacl.crypto_verify_64_BYTES, 64) class TestVerifyBytesEq(unittest.TestCase): def test_equal(self): a = libnacl.randombytes_buf(122) b = a[:] self.assertTrue(libnacl.bytes_eq(a, b)) def test_different(self): a = libnacl.randombytes_buf(122) b = bytearray(a) b[87] += 1 b = bytes(b) self.assertFalse(libnacl.bytes_eq(a, b)) def test_invalid_type(self): a = libnacl.randombytes_buf(122) b = bytearray(a) with self.assertRaises(TypeError): libnacl.bytes_eq(a, b) def test_different_length(self): a = libnacl.randombytes_buf(122) b = a[:-1] self.assertFalse(libnacl.bytes_eq(a, b)) libnacl-1.6.1/tests/unit/test_version.pyc0000644000175000001440000000232313134221741021135 0ustar thatchusers00000000000000ó Ž³oYc@s;dZddlZddlZdejfd„ƒYZdS(s# Basic tests for version functions iÿÿÿÿNtTestSodiumVersioncBs#eZd„Zd„Zd„ZRS(cCs|jtjƒƒdS(N(tassertIsNotNonetlibnacltsodium_version_string(tself((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyttest_version_string scCs|jtjƒdkƒdS(Ni(t assertTrueRtsodium_library_version_major(R((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyttest_library_version_majorscCs|jtjƒdkƒdS(Ni(RRtsodium_library_version_minor(R((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyttest_library_version_minors(t__name__t __module__RRR (((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyR s  (t__doc__RtunittesttTestCaseR(((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyts  libnacl-1.6.1/tests/unit/__pycache__/0000755000175000001440000000000013200105202020067 5ustar thatchusers00000000000000libnacl-1.6.1/tests/unit/__pycache__/test_raw_secret.cpython-36-PYTEST.pyc0000644000175000001440000000207013173435433026764 0ustar thatchusers000000000000003 ޳oYœã@sBddlZddljjZddlZddlZddlZGdd„dej ƒZ dS)éNc@seZdZdZdd„ZdS)Ú TestSecretz Test secret functions c CsÔd}tjjƒ}tjjƒ}tj|||ƒ}tj|||ƒ}|j||ƒ|jtƒtj|d|ƒWdQRX|jtƒtj||dƒWdQRX|jtƒtj|d|ƒWdQRX|jtƒtj||dƒWdQRXdS)Ns$Are you suggesting coconuts migrate?s too_short) ÚlibnaclÚutilsÚ rand_nonceÚ salsa_keyÚcrypto_secretboxÚcrypto_secretbox_openÚ assertEqualÚ assertRaisesÚ ValueError)ÚselfÚmsgÚnonceÚkeyÚcÚm©rú;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyÚtest_secretbox s       zTestSecret.test_secretboxN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr sr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚ libnacl.utilsÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_sign.cpython-36-PYTEST.pyc0000644000175000001440000000172513173435433025574 0ustar thatchusers000000000000003 ޳oY±ã@s:ddlZddljjZddlZddlZGdd„dej ƒZ dS)éNc@seZdZdZdd„ZdS)Ú TestSigningz cCsrd}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j||ƒ|j||ƒdS)NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.) ÚlibnaclÚsignÚSignerÚ signatureÚassertNotEqualÚVerifierÚhex_vkÚverifyÚ assertEqual)ÚselfÚmsgÚsignerÚsignedrÚveriÚverifiedÚ verified2©rú5/home/thatch/projects/libnacl/tests/unit/test_sign.pyÚ test_sign s      zTestSigning.test_signN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrsr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arÚ libnacl.signrÚunittestÚTestCaserrrrrÚs libnacl-1.6.1/tests/unit/__pycache__/test_aead.cpython-36-PYTEST.pyc0000644000175000001440000000315213173435433025522 0ustar thatchusers000000000000003 =ÖYóã@s:ddlZddljjZddlZddlZGdd„dej ƒZ dS)éNc@s<eZdZdZejejdƒdd„ƒZejej dƒdd„ƒZ dS) ÚTestAEADz zAES256-GCM AEAD not availablec Cs¤d}d}tjjƒjƒ}|j||ƒ}|j||ƒtjj|jƒjƒ}|j|t|ƒƒ}|j ||ƒ|j|t|ƒƒ}|j ||ƒ|j||ƒ}|j|t|ƒƒ} |j | |ƒdS)NsFYou've got two empty halves of coconuts and your bangin' 'em together.s"3) ÚlibnaclÚaeadÚAEADZ useAESGCMÚencryptÚassertNotEqualÚskÚdecryptÚlenÚ assertEqual) ÚselfÚmsgÚaadÚboxÚctxtÚbox2Úclear1Úclear2Úctxt2Úclear3©rú5/home/thatch/projects/libnacl/tests/unit/test_aead.pyÚ test_gcm_aead s     zTestAEAD.test_gcm_aeadz3IETF variant of ChaCha20Poly1305 AEAD not availablec Csœd}d}tjjƒ}|j||ƒ}|j||ƒtjj|jƒ}|j|t|ƒƒ}|j||ƒ|j|t|ƒƒ}|j||ƒ|j||ƒ}|j|t|ƒƒ} |j| |ƒdS)Ns&Our King? Well i didn't vote for you!!s"3) rrrrrrr r r ) r r rrrrrrrrrrrÚtest_ietf_aeads      zTestAEAD.test_ietf_aeadN) Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚunittestZ skipUnlessrZHAS_AEAD_AES256GCMrZHAS_AEAD_CHACHA20POLY1305_IETFrrrrrrsr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arZ libnacl.aeadrrÚTestCaserrrrrÚs libnacl-1.6.1/tests/unit/__pycache__/test_save.cpython-36.pyc0000644000175000001440000000531013134221747024534 0ustar thatchusers000000000000003 ޳oY ã@s^ddlZddlZddlZddlZddlZddlZddlZddlZddl Z Gdd„dej ƒZ dS)éNc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ÚTestSavez cCsÄd}tjjƒ}tjjƒ}tjƒ\}}tj|ƒtjƒ\}}tj|ƒ|j|ƒ|j|ƒtjj ||j ƒ}tjj ||j ƒ}|j |ƒ} |j |ƒ} tj j |ƒ} tj j |ƒ} tjj | | j ƒ} tjj | | j ƒ}|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j| ƒ}| j| ƒ}|j||ƒ|j||ƒtj j |ƒ}|j|j|jƒ|j|j |j ƒ|j|j|jƒtj|ƒtj|ƒdS)Ns:then leap out of the rabbit, taking the French by surprise)ÚlibnaclÚdualÚ DualSecretÚtempfileÚmkstempÚosÚcloseÚsaveÚpublicÚBoxÚpkÚencryptÚutilsÚload_keyÚ assertEqualÚskÚvkÚseedÚdecryptÚremove)ÚselfÚmsgÚbobÚaliceÚfh_Úbob_pathZ alice_pathÚbob_boxÚ alice_boxZbob_encZ alice_encZbob_loadZ alice_loadZ bob_load_boxZalice_load_boxZbob_decZ alice_decZbob2©rú5/home/thatch/projects/libnacl/tests/unit/test_save.pyÚtest_save_loadsF                  zTestSave.test_save_loadcCs^d}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j |ƒ}|j |ƒ}|j ||ƒdS)Ns:then leap out of the rabbit, taking the French by surprise) rÚsecretÚ SecretBoxrrrr r rrrrr)rrÚboxrZbox_pathZlboxÚctxtZout_msgrrr Útest_save_load_secret9s       zTestSave.test_save_load_secretcCshd}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j|ƒ}|j|ƒ}|j ||ƒtj |ƒdS)Ns:then leap out of the rabbit, taking the French by surprise) rÚsignÚSignerrrrr r rrrr)rrÚsignerrZ sign_pathZ signer_loadZsigned1Zsigned2rrr Útest_save_load_signDs        zTestSave.test_save_load_signcCsftjjƒ}tjƒ\}}tj|ƒ|j|ƒtj|ƒ}t j dkrBdnd}|j |tj |ƒtj |ƒdS)NÚwin32i€i¶)rrrrrrr r ÚstatÚsysÚplatformrÚST_MODEr)rrrrZstatsZexpected_permsrrr Útest_save_permsPs     zTestSave.test_save_permsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r!r&r*r0rrrr rs '  r) Ú libnacl.dualrÚlibnacl.secretÚ libnacl.signÚ libnacl.utilsrr,Úunittestrr-ÚTestCaserrrrr Úslibnacl-1.6.1/tests/unit/__pycache__/test_dual.cpython-36-PYTEST.pyc0000644000175000001440000000372313173435433025561 0ustar thatchusers000000000000003 ޳oYÕã@sBddlZddljjZddlZddlZddl Z Gdd„de j ƒZ dS)éNc@s(eZdZdZdd„Zdd„Zdd„ZdS) ÚTestDualz c Cs¤d}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j |ƒ} |j || ƒ|j||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) ÚlibnaclÚdualÚ DualSecretÚpublicÚBoxÚskÚpkÚencryptÚassertNotEqualÚdecryptÚ assertEqual) ÚselfÚmsgÚbobÚaliceÚbob_boxÚ alice_boxÚbob_ctxtÚbclearZ alice_ctxtZaclear©rú5/home/thatch/projects/libnacl/tests/unit/test_dual.pyÚtest_secretkey s          zTestDual.test_secretkeyc Csxd}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j ||ƒ|j |ƒ}|j ||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) rrrrÚ PublicKeyr rrr r r r ) rrrrZalice_pkrrrrrrrÚtest_publickeys     zTestDual.test_publickeycCsrd}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j ||ƒ|j ||ƒdS)NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.) rrrÚsignÚ signaturer ÚVerifierÚhex_vkÚverifyr )rrÚsignerÚsignedrZveriZverifiedZ verified2rrrÚ test_sign+s      zTestDual.test_signN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr"rrrrrsr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arÚlibnacl.publicrÚ libnacl.dualÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_dual.cpython-27-PYTEST.pyc0000644000175000001440000000472413173442023025554 0ustar thatchusers00000000000000ó Ž³oYÕc@s_ddlZddljjZddlZddlZddl Z de j fd„ƒYZ dS(iÿÿÿÿNtTestDualcBs)eZdZd„Zd„Zd„ZRS(s c Csêd}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j |ƒ} |j || ƒ|j||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( tlibnacltdualt DualSecrettpublictBoxtsktpktencrypttassertNotEqualtdecryptt assertEqual( tselftmsgtbobtalicetbob_boxt alice_boxtbob_ctxttbcleart alice_ctxttaclear((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyttest_secretkey sc Cs®d}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j ||ƒ|j |ƒ}|j ||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( RRRRt PublicKeyRRRRR R R ( R R RRtalice_pkRRRR((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyttest_publickeyscCs¡d}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j ||ƒ|j ||ƒdS(NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.( RRRtsignt signatureR tVerifierthex_vktverifyR (R R tsignertsignedRtveritverifiedt verified2((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyt test_sign+s(t__name__t __module__t__doc__RRR$(((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyRs  ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_artlibnacl.publicRt libnacl.dualtunittesttTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_dual.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_raw_hash.cpython-36-PYTEST.pyc0000644000175000001440000000216313173435433026425 0ustar thatchusers000000000000003 ޳oYˆã@sJddlZddljjZddlZddlmZm Z ddl Z Gdd„de j ƒZ dS)éN)Úsha256Úsha512c@seZdZdZdd„ZdS)ÚTestHashz Test sign functions cCs d}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒt|ƒ}|j|jtjƒ|j|jƒtj|ƒƒt |ƒ}|j|jtj ƒ|j|jƒtj |ƒƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.) ÚlibnaclÚ crypto_hashÚassertNotEqualrÚ assertEqualÚ digest_sizeÚcrypto_hash_sha256_BYTESÚdigestÚcrypto_hash_sha256rÚcrypto_hash_sha512_BYTESÚcrypto_hash_sha512)ÚselfÚmsg1Úmsg2Úchash1Úchash2Zref256Zref512©rú9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyÚ test_hash s     zTestHash.test_hashN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr sr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚhashlibrrÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_raw_public.cpython-27-PYTEST.pyc0000644000175000001440000000611413173442023026751 0ustar thatchusers00000000000000ó Ž³oYŠ c@s_ddlZddljjZddlZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestPubliccBs2eZdZd„Zd„Zd„Zd„ZRS(s Test public functions cCs@tjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS(N(tlibnacltcrypto_box_keypairt assertEqualtlentcrypto_box_PUBLICKEYBYTEStassertNotEqual(tselftpk1tsk1tpk2tsk2tpk3tsk3((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyttest_gen s cCs0d}tjjƒ}tjƒ\}}tjƒ\}}tj||||ƒ}|j||ƒtj||||ƒ}|j||ƒtjjƒ} tjƒ\} } tjƒ\} } tj|| | | ƒ}|j||ƒtj|| | | ƒ}|j||ƒ|j|| ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?(Rtutilst rand_nonceRt crypto_boxRtcrypto_box_openR(Rtmsgtnonce1RR R R tenc_msgt clear_msgtnonce2R R tpk4tsk4tenc_msg2t clear_msg2((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyttest_boxs"c Cs«d}tjjƒ}tjƒ\}}tjƒ\}}tj||ƒ}tj||ƒ}tj|||ƒ} |j|| ƒtj| ||ƒ} |j| |ƒdS(Ns$Are you suggesting coconuts migrate?( RRRRtcrypto_box_beforenmtcrypto_box_afternmRtcrypto_box_open_afternmR( RRRRR R R tk1tk2RR((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyt test_boxnm5sc CsÌd}tjƒ\}}tj||ƒ}|j||ƒtj|||ƒ}|j||ƒtjƒ\}}tj||ƒ}|j||ƒtj|||ƒ} |j| |ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?(RRtcrypto_box_sealRtcrypto_box_seal_openR( RRtpktskRRR R RR((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyt test_box_sealBs(t__name__t __module__t__doc__RRR"R'(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyR s    ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRt libnacl.utilstunittesttTestCaseR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_sign.cpython-36.pyc0000644000175000001440000000155213134221747024542 0ustar thatchusers000000000000003 ޳oY±ã@s&ddlZddlZGdd„dejƒZdS)éNc@seZdZdZdd„ZdS)Ú TestSigningz cCsrd}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j||ƒ|j||ƒdS)NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.) ÚlibnaclÚsignÚSignerÚ signatureÚassertNotEqualÚVerifierÚhex_vkÚverifyÚ assertEqual)ÚselfÚmsgÚsignerÚsignedrÚveriÚverifiedÚ verified2©rú5/home/thatch/projects/libnacl/tests/unit/test_sign.pyÚ test_sign s      zTestSigning.test_signN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrsr)Ú libnacl.signrÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_version.cpython-36-PYTEST.pyc0000644000175000001440000000220713173435433026315 0ustar thatchusers000000000000003 ޳oYÞã@s>dZddlZddljjZddlZddlZGdd„dej ƒZ dS)z# Basic tests for version functions éNc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestSodiumVersioncCs|jtjƒƒdS)N)ÚassertIsNotNoneÚlibnaclÚsodium_version_string)Úself©rú8/home/thatch/projects/libnacl/tests/unit/test_version.pyÚtest_version_string sz%TestSodiumVersion.test_version_stringcCs|jtjƒdkƒdS)Nr)Ú assertTruerÚsodium_library_version_major)rrrrÚtest_library_version_majorsz,TestSodiumVersion.test_library_version_majorcCs|jtjƒdkƒdS)Nr)r rÚsodium_library_version_minor)rrrrÚtest_library_version_minorsz,TestSodiumVersion.test_library_version_minorN)Ú__name__Ú __module__Ú __qualname__r r rrrrrr sr) Ú__doc__ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_verify.cpython-36-PYTEST.pyc0000644000175000001440000000545713173435433026146 0ustar thatchusers000000000000003 ޳oYi ã@sPdZddlZddljjZddlZddlZGdd„dej ƒZ Gdd„dej ƒZ dS)z" Basic tests for verify functions éNc@s$eZdZdd„Zdd„Zdd„ZdS)Ú TestVerifycCs˜tjdƒ}|dd…}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@d7<t|ƒ}|jtj||ƒƒ|jtj||ƒƒ|j tj dƒdS)Nééé) ÚlibnaclÚrandombytes_bufÚ assertTrueÚcrypto_verify_16Úbytes_eqÚ bytearrayÚrandombytes_randomÚbytesÚ assertFalseÚ assertEqualÚcrypto_verify_16_BYTES)ÚselfZv16Zv16x©rú7/home/thatch/projects/libnacl/tests/unit/test_verify.pyÚ test_verify16 s  zTestVerify.test_verify16cCs˜tjdƒ}|dd…}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@d7<t|ƒ}|jtj||ƒƒ|jtj||ƒƒ|j tj dƒdS)Né ér) rrrÚcrypto_verify_32r r r r rrÚcrypto_verify_32_BYTES)rZv32Zv32xrrrÚ test_verify32s  zTestVerify.test_verify32cCs˜tjdƒ}|dd…}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@d7<t|ƒ}|jtj||ƒƒ|jtj||ƒƒ|j tj dƒdS)Né@é?r) rrrÚcrypto_verify_64r r r r rrÚcrypto_verify_64_BYTES)rZv64Zv64xrrrÚ test_verify64%s  zTestVerify.test_verify64N)Ú__name__Ú __module__Ú __qualname__rrrrrrrr s  rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚTestVerifyBytesEqcCs,tjdƒ}|dd…}|jtj||ƒƒdS)Néz)rrrr )rÚaÚbrrrÚ test_equal4s  zTestVerifyBytesEq.test_equalcCs@tjdƒ}t|ƒ}|dd7<t|ƒ}|jtj||ƒƒdS)Nr#éWr)rrr r rr )rr$r%rrrÚtest_different9s  z TestVerifyBytesEq.test_differentc Cs8tjdƒ}t|ƒ}|jtƒtj||ƒWdQRXdS)Nr#)rrr Ú assertRaisesÚ TypeErrorr )rr$r%rrrÚtest_invalid_type@s  z#TestVerifyBytesEq.test_invalid_typecCs,tjdƒ}|dd…}|jtj||ƒƒdS)Nr#réÿÿÿÿ)rrrr )rr$r%rrrÚtest_different_lengthFs  z'TestVerifyBytesEq.test_different_lengthN)rr r!r&r(r+r-rrrrr"3sr") Ú__doc__ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚunittestÚTestCaserr"rrrrÚs  )libnacl-1.6.1/tests/unit/__pycache__/test_public.cpython-36-PYTEST.pyc0000644000175000001440000000273313173435433026112 0ustar thatchusers000000000000003 ޳oYšã@s:ddlZddljjZddlZddlZGdd„dej ƒZ dS)éNc@s eZdZdZdd„Zdd„ZdS)Ú TestPublicz c Cs¤d}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j|ƒ} |j || ƒ|j||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) ÚlibnaclÚpublicÚ SecretKeyÚBoxÚskÚpkÚencryptÚassertNotEqualÚdecryptÚ assertEqual) ÚselfÚmsgÚbobÚaliceÚbob_boxÚ alice_boxÚbob_ctxtÚbclearÚ alice_ctxtÚaclear©rú7/home/thatch/projects/libnacl/tests/unit/test_public.pyÚtest_secretkey s          zTestPublic.test_secretkeyc Csxd}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) rrrÚ PublicKeyrrrr r r r ) r rrrÚalice_pkrrrrrrrÚtest_publickeys     zTestPublic.test_publickeyN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrsr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arÚlibnacl.publicrÚunittestÚTestCaserrrrrÚs libnacl-1.6.1/tests/unit/__pycache__/test_raw_auth_sym.cpython-27-PYTEST.pyc0000644000175000001440000000222613173442023027324 0ustar thatchusers00000000000000ó Ž³oY0c@s_ddlZddljjZddlZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestSecretBoxcBseZdZd„ZRS(s Test sign functions cCsrd}tjjƒ}tjjƒ}tj|||ƒ}|j||ƒtj|||ƒ}|j||ƒdS(Ns$Are you suggesting coconuts migrate?(tlibnacltutilst salsa_keyt rand_noncetcrypto_secretboxtassertNotEqualtcrypto_secretbox_opent assertEqual(tselftmsgtsk1tnonce1tenc_msgt clear_msg((s=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyttest_secret_box s(t__name__t __module__t__doc__R(((s=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyR s( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRt libnacl.utilstunittesttTestCaseR(((s=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_secret.cpython-27-PYTEST.pyc0000644000175000001440000000226513173442023026112 0ustar thatchusers00000000000000ó Ž³oYc@sSddlZddljjZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestSecretcBseZdZd„ZRS(s c Cs¹d}tjjƒ}|j|ƒ}|j||ƒtjj|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒ|j|ƒ}|j|ƒ}|j||ƒdS(Ns6But then of course African swallows are not migratory.(tlibnacltsecrett SecretBoxtencrypttassertNotEqualtsktdecryptt assertEqual( tselftmsgtboxtctxttbox2tclear1tclear2tctxt2tclear3((s7/home/thatch/projects/libnacl/tests/unit/test_secret.pyt test_secret s(t__name__t __module__t__doc__R(((s7/home/thatch/projects/libnacl/tests/unit/test_secret.pyRs( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_artlibnacl.secretRtunittesttTestCaseR(((s7/home/thatch/projects/libnacl/tests/unit/test_secret.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_raw_hash.cpython-27-PYTEST.pyc0000644000175000001440000000263113173442023026416 0ustar thatchusers00000000000000ó Ž³oYˆc@siddlZddljjZddlZddlmZm Z ddl Z de j fd„ƒYZ dS(iÿÿÿÿN(tsha256tsha512tTestHashcBseZdZd„ZRS(s Test sign functions cCsàd}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒt|ƒ}|j|jtjƒ|j|jƒtj|ƒƒt |ƒ}|j|jtj ƒ|j|jƒtj |ƒƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.( tlibnaclt crypto_hashtassertNotEqualRt assertEqualt digest_sizetcrypto_hash_sha256_BYTEStdigesttcrypto_hash_sha256Rtcrypto_hash_sha512_BYTEStcrypto_hash_sha512(tselftmsg1tmsg2tchash1tchash2tref256tref512((s9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyt test_hash s  (t__name__t __module__t__doc__R(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyR s( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRthashlibRRtunittesttTestCaseR(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_raw_secret.cpython-36.pyc0000644000175000001440000000171513134221747025741 0ustar thatchusers000000000000003 ޳oYœã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@seZdZdZdd„ZdS)Ú TestSecretz Test secret functions c CsÔd}tjjƒ}tjjƒ}tj|||ƒ}tj|||ƒ}|j||ƒ|jtƒtj|d|ƒWdQRX|jtƒtj||dƒWdQRX|jtƒtj|d|ƒWdQRX|jtƒtj||dƒWdQRXdS)Ns$Are you suggesting coconuts migrate?s too_short) ÚlibnaclÚutilsÚ rand_nonceÚ salsa_keyÚcrypto_secretboxÚcrypto_secretbox_openÚ assertEqualÚ assertRaisesÚ ValueError)ÚselfÚmsgÚnonceÚkeyÚcÚm©rú;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyÚtest_secretbox s       zTestSecret.test_secretboxN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr sr)rÚ libnacl.utilsÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_raw_random.cpython-27-PYTEST.pyc0000644000175000001440000000401013173442023026744 0ustar thatchusers00000000000000ó Ž³oYñc@sYdZddlZddljjZddlZddlZdej fd„ƒYZ dS(s) Basic tests for randombytes_* functions iÿÿÿÿNtTestRandomBytescBs#eZd„Zd„Zd„ZRS(cCs|jtjƒtƒdS(N(tassertIsInstancetlibnacltrandombytes_randomtint(tself((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyttest_randombytes_random scCsb|jtjdƒtƒd„tdƒDƒ}|jdt|ƒƒ|jt|j ƒƒƒdS(NiÈcSs"i|]}dtjdƒ“qS(ii(Rtrandombytes_uniform(t.0t_((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pys s ii( RRRRtranget assertEqualtlent assertTruetalltvalues(Rtfreq((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyttest_randombytes_uniform scCsRtjdƒ}d„|Dƒ}|jdt|ƒƒ|jt|jƒƒƒdS(s+copied from libsodium default/randombytes.cicSsi|]}d|“qS(i((Rtx((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pys s iN(Rt randombytesR R R RR(RtdataR((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyttest_randombytess(t__name__t __module__RRR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyR s  ( t__doc__t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRtunittesttTestCaseR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_aead.cpython-36.pyc0000644000175000001440000000277713165437031024505 0ustar thatchusers000000000000003 =ÖYóã@s&ddlZddlZGdd„dejƒZdS)éNc@s<eZdZdZejejdƒdd„ƒZejej dƒdd„ƒZ dS) ÚTestAEADz zAES256-GCM AEAD not availablec Cs¤d}d}tjjƒjƒ}|j||ƒ}|j||ƒtjj|jƒjƒ}|j|t|ƒƒ}|j ||ƒ|j|t|ƒƒ}|j ||ƒ|j||ƒ}|j|t|ƒƒ} |j | |ƒdS)NsFYou've got two empty halves of coconuts and your bangin' 'em together.s"3) ÚlibnaclÚaeadÚAEADZ useAESGCMÚencryptÚassertNotEqualÚskÚdecryptÚlenÚ assertEqual) ÚselfÚmsgÚaadÚboxÚctxtÚbox2Úclear1Úclear2Úctxt2Úclear3©rú5/home/thatch/projects/libnacl/tests/unit/test_aead.pyÚ test_gcm_aead s     zTestAEAD.test_gcm_aeadz3IETF variant of ChaCha20Poly1305 AEAD not availablec Csœd}d}tjjƒ}|j||ƒ}|j||ƒtjj|jƒ}|j|t|ƒƒ}|j||ƒ|j|t|ƒƒ}|j||ƒ|j||ƒ}|j|t|ƒƒ} |j| |ƒdS)Ns&Our King? Well i didn't vote for you!!s"3) rrrrrrr r r ) r r rrrrrrrrrrrÚtest_ietf_aeads      zTestAEAD.test_ietf_aeadN) Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚunittestÚ skipUnlessrZHAS_AEAD_AES256GCMrZHAS_AEAD_CHACHA20POLY1305_IETFrrrrrrsr)Z libnacl.aeadrrÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_public.cpython-27-PYTEST.pyc0000644000175000001440000000353513173442023026104 0ustar thatchusers00000000000000ó Ž³oYšc@sSddlZddljjZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestPubliccBs eZdZd„Zd„ZRS(s c Csêd}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j|ƒ} |j || ƒ|j||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( tlibnacltpublict SecretKeytBoxtsktpktencrypttassertNotEqualtdecryptt assertEqual( tselftmsgtbobtalicetbob_boxt alice_boxtbob_ctxttbcleart alice_ctxttaclear((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyttest_secretkey sc Cs®d}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( RRRt PublicKeyRRRRRR R ( R R R Rtalice_pkRRRR((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyttest_publickeys(t__name__t __module__t__doc__RR(((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyRs ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_artlibnacl.publicRtunittesttTestCaseR(((s7/home/thatch/projects/libnacl/tests/unit/test_public.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_raw_hash.cpython-36.pyc0000644000175000001440000000201013134221747025364 0ustar thatchusers000000000000003 ޳oYˆã@s6ddlZddlmZmZddlZGdd„dejƒZdS)éN)Úsha256Úsha512c@seZdZdZdd„ZdS)ÚTestHashz Test sign functions cCs d}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒt|ƒ}|j|jtjƒ|j|jƒtj|ƒƒt |ƒ}|j|jtj ƒ|j|jƒtj |ƒƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.) ÚlibnaclÚ crypto_hashÚassertNotEqualrÚ assertEqualÚ digest_sizeÚcrypto_hash_sha256_BYTESÚdigestÚcrypto_hash_sha256rÚcrypto_hash_sha512_BYTESÚcrypto_hash_sha512)ÚselfÚmsg1Úmsg2Úchash1Úchash2Zref256Zref512©rú9/home/thatch/projects/libnacl/tests/unit/test_raw_hash.pyÚ test_hash s     zTestHash.test_hashN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr sr)rZhashlibrrÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_raw_auth_sym.cpython-36-PYTEST.pyc0000644000175000001440000000164513173435433027337 0ustar thatchusers000000000000003 ޳oY0ã@sBddlZddljjZddlZddlZddlZGdd„dej ƒZ dS)éNc@seZdZdZdd„ZdS)Ú TestSecretBoxz Test sign functions cCsPd}tjjƒ}tjjƒ}tj|||ƒ}|j||ƒtj|||ƒ}|j||ƒdS)Ns$Are you suggesting coconuts migrate?)ÚlibnaclÚutilsÚ salsa_keyÚ rand_nonceÚcrypto_secretboxÚassertNotEqualÚcrypto_secretbox_openÚ assertEqual)ÚselfÚmsgZsk1Znonce1Zenc_msgZ clear_msg©r ú=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyÚtest_secret_box s   zTestSecretBox.test_secret_boxN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr r r rr sr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚ libnacl.utilsÚunittestÚTestCaserr r r rÚs  libnacl-1.6.1/tests/unit/__pycache__/test_save.cpython-27-PYTEST.pyc0000644000175000001440000000706413173442023025565 0ustar thatchusers00000000000000ó Ž³oY c@s§ddlZddljjZddlZddlZddl Zddl Zddl Z ddl Z ddl Z ddlZddlZde jfd„ƒYZdS(iÿÿÿÿNtTestSavecBs2eZdZd„Zd„Zd„Zd„ZRS(s cCs~d}tjjƒ}tjjƒ}tjƒ\}}tj|ƒtjƒ\}}tj|ƒ|j|ƒ|j|ƒtjj ||j ƒ}tjj ||j ƒ}|j |ƒ} |j |ƒ} tj j |ƒ} tj j |ƒ} tjj | | j ƒ} tjj | | j ƒ}|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j| ƒ}| j| ƒ}|j||ƒ|j||ƒtj j |ƒ}|j|j|jƒ|j|j |j ƒ|j|j|jƒtj|ƒtj|ƒdS(Ns:then leap out of the rabbit, taking the French by surprise(tlibnacltdualt DualSecretttempfiletmkstemptostclosetsavetpublictBoxtpktencrypttutilstload_keyt assertEqualtsktvktseedtdecrypttremove(tselftmsgtbobtalicetfh_tbob_patht alice_pathtbob_boxt alice_boxtbob_enct alice_enctbob_loadt alice_loadt bob_load_boxtalice_load_boxtbob_dect alice_dectbob2((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_loadsF     cCs…d}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j |ƒ}|j |ƒ}|j ||ƒdS(Ns:then leap out of the rabbit, taking the French by surprise( Rtsecrett SecretBoxRRRRRR RR RR(RRtboxRtbox_pathtlboxtctxttout_msg((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_load_secret9s  cCs’d}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j|ƒ}|j|ƒ}|j ||ƒtj |ƒdS(Ns:then leap out of the rabbit, taking the French by surprise( RtsigntSignerRRRRRR RRR(RRtsignerRt sign_patht signer_loadtsigned1tsigned2((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_load_signDs  cCstjjƒ}tjƒ\}}tj|ƒ|j|ƒtj|ƒ}t j dkr_dnd}|j |tj |ƒtj |ƒdS(Ntwin32i€i¶(RRRRRRRRtstattsystplatformRtST_MODER(RRRRtstatstexpected_perms((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyttest_save_permsPs  (t__name__t __module__t__doc__R'R/R7R?(((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyRs  ' (t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_art libnacl.dualRtlibnacl.secrett libnacl.signt libnacl.utilsRR9tunittestRR:tTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_save.pyts          libnacl-1.6.1/tests/unit/__pycache__/test_raw_public.cpython-36.pyc0000644000175000001440000000444213134221747025732 0ustar thatchusers000000000000003 ޳oYŠ ã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú TestPublicz Test public functions cCsètjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS)N)ÚlibnaclÚcrypto_box_keypairÚ assertEqualÚlenÚcrypto_box_PUBLICKEYBYTESÚassertNotEqual)ÚselfÚpk1Úsk1Úpk2Úsk2Úpk3Úsk3©rú;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyÚtest_gen s          zTestPublic.test_gencCsÔd}tjjƒ}tjƒ\}}tjƒ\}}tj||||ƒ}|j||ƒtj||||ƒ}|j||ƒtjjƒ} tjƒ\} } tjƒ\} } tj|| | | ƒ}|j||ƒtj|| | | ƒ}|j||ƒ|j|| ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?)rÚutilsÚ rand_noncerÚ crypto_boxrÚcrypto_box_openr)r ÚmsgÚnonce1r r r r Úenc_msgÚ clear_msgZnonce2rrZpk4Zsk4Úenc_msg2Ú clear_msg2rrrÚtest_boxs"           zTestPublic.test_boxc Csvd}tjjƒ}tjƒ\}}tjƒ\}}tj||ƒ}tj||ƒ}tj|||ƒ} |j|| ƒtj| ||ƒ} |j| |ƒdS)Ns$Are you suggesting coconuts migrate?) rrrrÚcrypto_box_beforenmÚcrypto_box_afternmrÚcrypto_box_open_afternmr) r rrr r r r Úk1Úk2rrrrrÚ test_boxnm5s      zTestPublic.test_boxnmc Csd}tjƒ\}}tj||ƒ}|j||ƒtj|||ƒ}|j||ƒtjƒ\}}tj||ƒ}|j||ƒtj|||ƒ} |j| |ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?)rrÚcrypto_box_sealrÚcrypto_box_seal_openr) r rÚpkÚskrrr r rrrrrÚ test_box_sealBs        zTestPublic.test_box_sealN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr#r(rrrrr s  r)rÚ libnacl.utilsÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_raw_generichash.cpython-36.pyc0000644000175000001440000000251113134221747026727 0ustar thatchusers000000000000003 ޳oY¼ã@s&ddlZddlZGdd„dejƒZdS)éNc@s eZdZdZdd„Zdd„ZdS)ÚTestGenericHashz Test sign functions cCsDd}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.)ÚlibnaclÚcrypto_generichashÚassertNotEqual)ÚselfÚmsg1Úmsg2Úchash1Úchash2©r ú@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyÚtest_keyless_generichash s    z(TestGenericHash.test_keyless_generichashc CsÈd}d}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.)rÚutilsÚ rand_noncerrÚ assertEqual) rrrÚkey1Úkey2Úkhash1_1Ú khash1_1_2Úkhash1_2Úkhash2_1Úkhash2_2r r r Útest_key_generichashs$               z$TestGenericHash.test_key_generichashN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rr r r r rs r)rÚunittestÚTestCaserr r r r Úslibnacl-1.6.1/tests/unit/__pycache__/test_raw_auth_sym.cpython-36.pyc0000644000175000001440000000147213134221747026305 0ustar thatchusers000000000000003 ޳oY0ã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@seZdZdZdd„ZdS)Ú TestSecretBoxz Test sign functions cCsPd}tjjƒ}tjjƒ}tj|||ƒ}|j||ƒtj|||ƒ}|j||ƒdS)Ns$Are you suggesting coconuts migrate?)ÚlibnaclÚutilsÚ salsa_keyÚ rand_nonceÚcrypto_secretboxÚassertNotEqualÚcrypto_secretbox_openÚ assertEqual)ÚselfÚmsgZsk1Znonce1Zenc_msgZ clear_msg©r ú=/home/thatch/projects/libnacl/tests/unit/test_raw_auth_sym.pyÚtest_secret_box s   zTestSecretBox.test_secret_boxN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr r r rr sr)rÚ libnacl.utilsÚunittestÚTestCaserr r r rÚslibnacl-1.6.1/tests/unit/__pycache__/__init__.cpython-36.pyc0000644000175000001440000000020713173435433024300 0ustar thatchusers000000000000003 ޳oYã@sdS)N©rrrú4/home/thatch/projects/libnacl/tests/unit/__init__.pyÚslibnacl-1.6.1/tests/unit/__pycache__/test_raw_random.cpython-36-PYTEST.pyc0000644000175000001440000000325213173435433026762 0ustar thatchusers000000000000003 ޳oYñã@s>dZddlZddljjZddlZddlZGdd„dej ƒZ dS)z) Basic tests for randombytes_* functions éNc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestRandomBytescCs|jtjƒtƒdS)N)ÚassertIsInstanceÚlibnaclÚrandombytes_randomÚint)Úself©rú;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyÚtest_randombytes_random sz'TestRandomBytes.test_randombytes_randomcCsJ|jtjdƒtƒdd„tdƒDƒ}|jdt|ƒƒ|jt|j ƒƒƒdS)NéÈcSsi|]}dtjdƒ“qS)éé)rÚrandombytes_uniform)Ú.0Ú_rrr ú sz.ir ) rrrrÚrangeÚ assertEqualÚlenÚ assertTrueÚallÚvalues)rÚfreqrrr Útest_randombytes_uniform sz(TestRandomBytes.test_randombytes_uniformcCs>tjdƒ}dd„|Dƒ}|jdt|ƒƒ|jt|jƒƒƒdS)z+copied from libsodium default/randombytes.cicSsi|] }d|“qS)r r)rÚxrrr rsz4TestRandomBytes.test_randombytes..r N)rÚ randombytesrrrrr)rÚdatarrrr Útest_randombytess z TestRandomBytes.test_randombytesN)Ú__name__Ú __module__Ú __qualname__r rrrrrr r sr) Ú__doc__ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚunittestÚTestCaserrrrr Ús  libnacl-1.6.1/tests/unit/__pycache__/test_blake.cpython-36.pyc0000644000175000001440000000253613134221747024663 0ustar thatchusers000000000000003 ޳oYÄã@s&ddlZddlZGdd„dejƒZdS)éNc@s eZdZdZdd„Zdd„ZdS)Ú TestBlakez Test sign functions cCsDd}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.)ÚlibnaclÚcrypto_generichashÚassertNotEqual)ÚselfÚmsg1Úmsg2Zchash1Zchash2©r ú6/home/thatch/projects/libnacl/tests/unit/test_blake.pyÚtest_keyless_blake s    zTestBlake.test_keyless_blakec Csæd}d}tjjƒ}tjjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.) rÚutilsÚ rand_nonceZblakeZBlake2bZdigestZblake2brÚ assertEqual) rrrÚkey1Úkey2Zkhash1_1Z khash1_1_2Zkhash1_2Zkhash2_1Zkhash2_2r r r Útest_key_blakes$          zTestBlake.test_key_blakeN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rr r r r rs r)Z libnacl.blakerÚunittestÚTestCaserr r r r Úslibnacl-1.6.1/tests/unit/__pycache__/test_raw_secret.cpython-27-PYTEST.pyc0000644000175000001440000000247413173442023026765 0ustar thatchusers00000000000000ó Ž³oYœc@s_ddlZddljjZddlZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestSecretcBseZdZd„ZRS(s Test secret functions c Csd}tjjƒ}tjjƒ}tj|||ƒ}tj|||ƒ}|j||ƒ|jtƒtj|d|ƒWdQX|jtƒtj||dƒWdQX|jtƒtj|d|ƒWdQX|jtƒtj||dƒWdQXdS(Ns$Are you suggesting coconuts migrate?t too_short( tlibnacltutilst rand_noncet salsa_keytcrypto_secretboxtcrypto_secretbox_opent assertEqualt assertRaisest ValueError(tselftmsgtnoncetkeytctm((s;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyttest_secretbox s(t__name__t __module__t__doc__R(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyR s( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRt libnacl.utilstunittesttTestCaseR(((s;/home/thatch/projects/libnacl/tests/unit/test_raw_secret.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_sign.cpython-27-PYTEST.pyc0000644000175000001440000000231513173442023025561 0ustar thatchusers00000000000000ó Ž³oY±c@sSddlZddljjZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestSigningcBseZdZd„ZRS(s cCs¡d}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j||ƒ|j||ƒdS(NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.( tlibnacltsigntSignert signaturetassertNotEqualtVerifierthex_vktverifyt assertEqual(tselftmsgtsignertsignedRtveritverifiedt verified2((s5/home/thatch/projects/libnacl/tests/unit/test_sign.pyt test_sign s(t__name__t __module__t__doc__R(((s5/home/thatch/projects/libnacl/tests/unit/test_sign.pyRs( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_art libnacl.signRtunittesttTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_sign.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_verify.cpython-27-PYTEST.pyc0000644000175000001440000000666413173442023026140 0ustar thatchusers00000000000000ó Ž³oYi c@srdZddlZddljjZddlZddlZdej fd„ƒYZ dej fd„ƒYZ dS(s" Basic tests for verify functions iÿÿÿÿNt TestVerifycBs#eZd„Zd„Zd„ZRS(cCsÃtjdƒ}|}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@cd7s    )libnacl-1.6.1/tests/unit/__pycache__/test_seal.cpython-36.pyc0000644000175000001440000000236313134221747024527 0ustar thatchusers000000000000003 ޳oYã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@s eZdZdZdd„Zdd„ZdS)Ú TestSealedz cCsJd}tjjƒ}tjj|ƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) ÚlibnaclÚpublicÚ SecretKeyÚsealedÚ SealedBoxÚencryptÚassertNotEqualÚdecryptÚ assertEqual)ÚselfÚmsgÚkeyÚboxÚctxtÚbclear©rú5/home/thatch/projects/libnacl/tests/unit/test_seal.pyÚtest_secretkey s     zTestSealed.test_secretkeycCsdd}tjjƒ}tjj|jƒ}tjj|ƒ}|j|ƒ}|j||ƒtjj|ƒ}|j |ƒ}|j ||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) rrrÚ PublicKeyÚpkrrrr r r )r r rZ key_publicrrZdecrypting_boxrrrrÚtest_publickey_onlys      zTestSealed.test_publickey_onlyN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrs r)Zlibnacl.sealedrÚlibnacl.publicÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_aead.cpython-27-PYTEST.pyc0000644000175000001440000000401413173442023025511 0ustar thatchusers00000000000000ó =ÖYóc@sSddlZddljjZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNtTestAEADcBsJeZdZejejdƒd„ƒZejejdƒd„ƒZ RS(s sAES256-GCM AEAD not availablec Csìd}d}tjjƒjƒ}|j||ƒ}|j||ƒtjj|jƒjƒ}|j|t|ƒƒ}|j ||ƒ|j|t|ƒƒ}|j ||ƒ|j||ƒ}|j|t|ƒƒ} |j | |ƒdS(NsFYou've got two empty halves of coconuts and your bangin' 'em together.s"3( tlibnacltaeadtAEADt useAESGCMtencrypttassertNotEqualtsktdecrypttlent assertEqual( tselftmsgtaadtboxtctxttbox2tclear1tclear2tctxt2tclear3((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyt test_gcm_aead ss3IETF variant of ChaCha20Poly1305 AEAD not availablec Csàd}d}tjjƒ}|j||ƒ}|j||ƒtjj|jƒ}|j|t|ƒƒ}|j||ƒ|j|t|ƒƒ}|j||ƒ|j||ƒ}|j|t|ƒƒ} |j| |ƒdS(Ns&Our King? Well i didn't vote for you!!s"3( RRRRRRRR R ( R R R RRRRRRR((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyttest_ietf_aeads( t__name__t __module__t__doc__tunittestt skipUnlessRtHAS_AEAD_AES256GCMRtHAS_AEAD_CHACHA20POLY1305_IETFR(((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyRs( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_art libnacl.aeadRRtTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_aead.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_raw_sign.cpython-36.pyc0000644000175000001440000000235513134221747025415 0ustar thatchusers000000000000003 ޳oYcã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@s eZdZdZdd„Zdd„ZdS)ÚTestSignz Test sign functions cCsètjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS)N)ÚlibnaclÚcrypto_sign_keypairÚ assertEqualÚlenÚcrypto_sign_PUBLICKEYBYTESÚcrypto_sign_SECRETKEYBYTESÚassertNotEqual)ÚselfÚvk1Úsk1Zvk2Úsk2Zvk3Úsk3©rú9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyÚtest_gen s          zTestSign.test_gencCsNd}tjƒ\}}tj||ƒ}|j||tjd…ƒtj||ƒ}|j||ƒdS)Ns$Are you suggesting coconuts migrate?)rrÚ crypto_signrÚcrypto_sign_BYTESÚcrypto_sign_open)r Úmsgr r ÚsigZsig_msgrrrÚtest_boxs    zTestSign.test_boxN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrr sr)rÚ libnacl.utilsÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_seal.cpython-36-PYTEST.pyc0000644000175000001440000000253613173435433025561 0ustar thatchusers000000000000003 ޳oYã@sBddlZddljjZddlZddlZddl Z Gdd„de j ƒZ dS)éNc@s eZdZdZdd„Zdd„ZdS)Ú TestSealedz cCsJd}tjjƒ}tjj|ƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) ÚlibnaclÚpublicÚ SecretKeyÚsealedÚ SealedBoxÚencryptÚassertNotEqualÚdecryptÚ assertEqual)ÚselfÚmsgÚkeyÚboxÚctxtÚbclear©rú5/home/thatch/projects/libnacl/tests/unit/test_seal.pyÚtest_secretkey s     zTestSealed.test_secretkeycCsdd}tjjƒ}tjj|jƒ}tjj|ƒ}|j|ƒ}|j||ƒtjj|ƒ}|j |ƒ}|j ||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) rrrÚ PublicKeyÚpkrrrr r r )r r rZ key_publicrrZdecrypting_boxrrrrÚtest_publickey_onlys      zTestSealed.test_publickey_onlyN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrs r) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arZlibnacl.sealedrÚlibnacl.publicÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_raw_generichash.cpython-36-PYTEST.pyc0000644000175000001440000000266413173435433027770 0ustar thatchusers000000000000003 ޳oY¼ã@s:ddlZddljjZddlZddlZGdd„dejƒZ dS)éNc@s eZdZdZdd„Zdd„ZdS)ÚTestGenericHashz Test sign functions cCsDd}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.)ÚlibnaclÚcrypto_generichashÚassertNotEqual)ÚselfÚmsg1Úmsg2Úchash1Úchash2©r ú@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyÚtest_keyless_generichash s    z(TestGenericHash.test_keyless_generichashc CsÈd}d}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.)rÚutilsÚ rand_noncerrÚ assertEqual) rrrÚkey1Úkey2Úkhash1_1Ú khash1_1_2Úkhash1_2Úkhash2_1Úkhash2_2r r r Útest_key_generichashs$               z$TestGenericHash.test_key_generichashN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rr r r r rs r) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚunittestÚTestCaserr r r r Ús libnacl-1.6.1/tests/unit/__pycache__/test_version.cpython-36.pyc0000644000175000001440000000203413134221747025263 0ustar thatchusers000000000000003 ޳oYÞã@s*dZddlZddlZGdd„dejƒZdS)z# Basic tests for version functions éNc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestSodiumVersioncCs|jtjƒƒdS)N)ÚassertIsNotNoneÚlibnaclÚsodium_version_string)Úself©rú8/home/thatch/projects/libnacl/tests/unit/test_version.pyÚtest_version_string sz%TestSodiumVersion.test_version_stringcCs|jtjƒdkƒdS)Nr)Ú assertTruerÚsodium_library_version_major)rrrrÚtest_library_version_majorsz,TestSodiumVersion.test_library_version_majorcCs|jtjƒdkƒdS)Nr)r rÚsodium_library_version_minor)rrrrÚtest_library_version_minorsz,TestSodiumVersion.test_library_version_minorN)Ú__name__Ú __module__Ú __qualname__r r rrrrrr sr)Ú__doc__rÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_secret.cpython-36-PYTEST.pyc0000644000175000001440000000165713173435433026125 0ustar thatchusers000000000000003 ޳oYã@s:ddlZddljjZddlZddlZGdd„dej ƒZ dS)éNc@seZdZdZdd„ZdS)Ú TestSecretz c Cs‚d}tjjƒ}|j|ƒ}|j||ƒtjj|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒ|j|ƒ}|j|ƒ}|j||ƒdS)Ns6But then of course African swallows are not migratory.)ÚlibnaclÚsecretÚ SecretBoxÚencryptÚassertNotEqualÚskÚdecryptÚ assertEqual) ÚselfÚmsgÚboxÚctxtÚbox2Úclear1Úclear2Úctxt2Úclear3©rú7/home/thatch/projects/libnacl/tests/unit/test_secret.pyÚ test_secret s         zTestSecret.test_secretN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrsr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arÚlibnacl.secretrÚunittestÚTestCaserrrrrÚs libnacl-1.6.1/tests/unit/__pycache__/test_public.cpython-36.pyc0000644000175000001440000000256013134221747025060 0ustar thatchusers000000000000003 ޳oYšã@s&ddlZddlZGdd„dejƒZdS)éNc@s eZdZdZdd„Zdd„ZdS)Ú TestPublicz c Cs¤d}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j|ƒ} |j || ƒ|j||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) ÚlibnaclÚpublicÚ SecretKeyÚBoxÚskÚpkÚencryptÚassertNotEqualÚdecryptÚ assertEqual) ÚselfÚmsgÚbobÚaliceÚbob_boxÚ alice_boxÚbob_ctxtÚbclearÚ alice_ctxtÚaclear©rú7/home/thatch/projects/libnacl/tests/unit/test_public.pyÚtest_secretkey s          zTestPublic.test_secretkeyc Csxd}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) rrrÚ PublicKeyrrrr r r r ) r rrrÚalice_pkrrrrrrrÚtest_publickeys     zTestPublic.test_publickeyN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrsr)Úlibnacl.publicrÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_raw_sign.cpython-36-PYTEST.pyc0000644000175000001440000000253013173435433026440 0ustar thatchusers000000000000003 ޳oYcã@sBddlZddljjZddlZddlZddlZGdd„dej ƒZ dS)éNc@s eZdZdZdd„Zdd„ZdS)ÚTestSignz Test sign functions cCsètjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS)N)ÚlibnaclÚcrypto_sign_keypairÚ assertEqualÚlenÚcrypto_sign_PUBLICKEYBYTESÚcrypto_sign_SECRETKEYBYTESÚassertNotEqual)ÚselfÚvk1Úsk1Zvk2Úsk2Zvk3Úsk3©rú9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyÚtest_gen s          zTestSign.test_gencCsNd}tjƒ\}}tj||ƒ}|j||tjd…ƒtj||ƒ}|j||ƒdS)Ns$Are you suggesting coconuts migrate?)rrÚ crypto_signrÚcrypto_sign_BYTESÚcrypto_sign_open)r Úmsgr r ÚsigZsig_msgrrrÚtest_boxs    zTestSign.test_boxN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrr sr) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚ libnacl.utilsÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_dual.cpython-36.pyc0000644000175000001440000000355013134221747024527 0ustar thatchusers000000000000003 ޳oYÕã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@s(eZdZdZdd„Zdd„Zdd„ZdS) ÚTestDualz c Cs¤d}tjjƒ}tjjƒ}tjj|j|jƒ}tjj|j|jƒ}|j|ƒ}|j||ƒ|j |ƒ}|j ||ƒ|j|ƒ}|j||ƒ|j |ƒ} |j || ƒ|j||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) ÚlibnaclÚdualÚ DualSecretÚpublicÚBoxÚskÚpkÚencryptÚassertNotEqualÚdecryptÚ assertEqual) ÚselfÚmsgÚbobÚaliceÚbob_boxÚ alice_boxÚbob_ctxtÚbclearZ alice_ctxtZaclear©rú5/home/thatch/projects/libnacl/tests/unit/test_dual.pyÚtest_secretkey s          zTestDual.test_secretkeyc Csxd}tjjƒ}tjjƒ}tjj|jƒ}tjj|j|ƒ}tjj|j|jƒ}|j|ƒ}|j ||ƒ|j |ƒ}|j ||ƒdS)z sGYou've got two empty halves of coconut and you're bangin' 'em together.N) rrrrÚ PublicKeyr rrr r r r ) rrrrZalice_pkrrrrrrrÚtest_publickeys     zTestDual.test_publickeycCsrd}tjjƒ}|j|ƒ}|j|ƒ}|j||ƒtjj|jƒƒ}|j|ƒ}|j||ƒ}|j ||ƒ|j ||ƒdS)NslWell, that's no ordinary rabbit. That's the most foul, cruel, and bad-tempered rodent you ever set eyes on.) rrrÚsignÚ signaturer ÚVerifierÚhex_vkÚverifyr )rrÚsignerZsignedrZveriZverifiedZ verified2rrrÚ test_sign+s      zTestDual.test_signN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr!rrrrrsr)Úlibnacl.publicrÚ libnacl.dualÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/tests/unit/__pycache__/test_raw_sign.cpython-27-PYTEST.pyc0000644000175000001440000000333513173442023026435 0ustar thatchusers00000000000000ó Ž³oYcc@s_ddlZddljjZddlZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNtTestSigncBs eZdZd„Zd„ZRS(s Test sign functions cCs@tjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS(N(tlibnacltcrypto_sign_keypairt assertEqualtlentcrypto_sign_PUBLICKEYBYTEStcrypto_sign_SECRETKEYBYTEStassertNotEqual(tselftvk1tsk1tvk2tsk2tvk3tsk3((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyttest_gen s cCsgd}tjƒ\}}tj||ƒ}|j||tjƒtj||ƒ}|j||ƒdS(Ns$Are you suggesting coconuts migrate?(RRt crypto_signRtcrypto_sign_BYTEStcrypto_sign_open(RtmsgR R tsigtsig_msg((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyttest_boxs (t__name__t __module__t__doc__RR(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyR s ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRt libnacl.utilstunittesttTestCaseR(((s9/home/thatch/projects/libnacl/tests/unit/test_raw_sign.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_version.cpython-27-PYTEST.pyc0000644000175000001440000000254113173442023026307 0ustar thatchusers00000000000000ó Ž³oYÞc@sYdZddlZddljjZddlZddlZdej fd„ƒYZ dS(s# Basic tests for version functions iÿÿÿÿNtTestSodiumVersioncBs#eZd„Zd„Zd„ZRS(cCs|jtjƒƒdS(N(tassertIsNotNonetlibnacltsodium_version_string(tself((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyttest_version_string scCs|jtjƒdkƒdS(Ni(t assertTrueRtsodium_library_version_major(R((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyttest_library_version_majorscCs|jtjƒdkƒdS(Ni(RRtsodium_library_version_minor(R((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyttest_library_version_minors(t__name__t __module__RRR (((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyR s  ( t__doc__t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRtunittesttTestCaseR(((s8/home/thatch/projects/libnacl/tests/unit/test_version.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_auth_verify.cpython-36-PYTEST.pyc0000644000175000001440000000367413173435433027166 0ustar thatchusers000000000000003 ޳oY% ã@sBddlZddljjZddlZddlZddlZGdd„dej ƒZ dS)éNc@s eZdZdZdd„Zdd„ZdS)ÚTestAuthVerifyz$ Test onetimeauth functions cCsÈd}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}|jtj|||ƒƒ|jtj|||ƒƒ|jtƒ}tj|||ƒWdQRX|jd|jj kƒ|jtƒ}tj|||ƒWdQRX|jd|jj kƒdS)NsQAnybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.zFailed to auth msg) ÚlibnaclÚutilsÚ salsa_keyÚ crypto_authÚ assertTrueÚcrypto_auth_verifyÚ assertRaisesÚ ValueErrorÚ exceptionÚargs)ÚselfÚmsgÚkey1Úkey2Úsig1Úsig2Úcontext©rús  libnacl-1.6.1/tests/unit/__pycache__/test_auth_verify.cpython-27-PYTEST.pyc0000644000175000001440000000454613173442023027156 0ustar thatchusers00000000000000ó Ž³oY% c@s_ddlZddljjZddlZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNtTestAuthVerifycBs eZdZd„Zd„ZRS(s$ Test onetimeauth functions c Cs d}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}|jtj|||ƒƒ|jtj|||ƒƒ|jtƒ}tj|||ƒWdQX|jd|jj kƒ|jtƒ}tj|||ƒWdQX|jd|jj kƒdS(NsQAnybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.sFailed to auth msg( tlibnacltutilst salsa_keyt crypto_autht assertTruetcrypto_auth_verifyt assertRaisest ValueErrort exceptiontargs(tselftmsgtkey1tkey2tsig1tsig2tcontext((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyttest_auth_verify sc Cs |jdtjƒƒd}tjtjƒ}tjtjƒ}tj||ƒ}tj||ƒ}|jtƒtj|dƒWdQX|jtƒtj||dƒWdQX|jtƒtjd||ƒWdQX|j tj|||ƒƒ|j tj|||ƒƒ|jtƒ}tj|||ƒWdQX|j d|j j kƒ|jtƒ}tj|||ƒWdQX|j d|j j kƒdS(Ntpoly1305sQAnybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.t too_shortsFailed to auth message( t assertEqualRtcrypto_onetimeauth_primitivet randombytestcrypto_onetimeauth_KEYBYTEStcrypto_onetimeauthRRtcrypto_onetimeauth_verifyRR R (R R R RRRR((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyttest_onetimeauth_verifys((t__name__t __module__t__doc__RR(((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyR s ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRt libnacl.utilstunittesttTestCaseR(((s</home/thatch/projects/libnacl/tests/unit/test_auth_verify.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_raw_random.cpython-36.pyc0000644000175000001440000000307713134221747025737 0ustar thatchusers000000000000003 ޳oYñã@s*dZddlZddlZGdd„dejƒZdS)z) Basic tests for randombytes_* functions éNc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestRandomBytescCs|jtjƒtƒdS)N)ÚassertIsInstanceÚlibnaclÚrandombytes_randomÚint)Úself©rú;/home/thatch/projects/libnacl/tests/unit/test_raw_random.pyÚtest_randombytes_random sz'TestRandomBytes.test_randombytes_randomcCsJ|jtjdƒtƒdd„tdƒDƒ}|jdt|ƒƒ|jt|j ƒƒƒdS)NéÈcSsi|]}dtjdƒ“qS)éé)rÚrandombytes_uniform)Ú.0Ú_rrr ú sz.ir ) rrrrÚrangeÚ assertEqualÚlenÚ assertTrueÚallÚvalues)rÚfreqrrr Útest_randombytes_uniform sz(TestRandomBytes.test_randombytes_uniformcCs>tjdƒ}dd„|Dƒ}|jdt|ƒƒ|jt|jƒƒƒdS)z+copied from libsodium default/randombytes.cicSsi|] }d|“qS)r r)rÚxrrr rsz4TestRandomBytes.test_randombytes..r N)rÚ randombytesrrrrr)rÚdatarrrr Útest_randombytess z TestRandomBytes.test_randombytesN)Ú__name__Ú __module__Ú __qualname__r rrrrrr r sr)Ú__doc__rÚunittestÚTestCaserrrrr Úslibnacl-1.6.1/tests/unit/__pycache__/test_seal.cpython-27-PYTEST.pyc0000644000175000001440000000324213173442023025545 0ustar thatchusers00000000000000ó Ž³oYc@s_ddlZddljjZddlZddlZddl Z de j fd„ƒYZ dS(iÿÿÿÿNt TestSealedcBs eZdZd„Zd„ZRS(s cCsid}tjjƒ}tjj|ƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( tlibnacltpublict SecretKeytsealedt SealedBoxtencrypttassertNotEqualtdecryptt assertEqual(tselftmsgtkeytboxtctxttbclear((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyttest_secretkey scCsd}tjjƒ}tjj|jƒ}tjj|ƒ}|j|ƒ}|j||ƒtjj|ƒ}|j |ƒ}|j ||ƒdS(s sGYou've got two empty halves of coconut and you're bangin' 'em together.N( RRRt PublicKeytpkRRRRRR (R R R t key_publicR Rtdecrypting_boxR((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyttest_publickey_onlys(t__name__t __module__t__doc__RR(((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyRs ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_artlibnacl.sealedRtlibnacl.publictunittesttTestCaseR(((s5/home/thatch/projects/libnacl/tests/unit/test_seal.pyts    libnacl-1.6.1/tests/unit/__pycache__/test_blake.cpython-27-PYTEST.pyc0000644000175000001440000000347513173442023025707 0ustar thatchusers00000000000000ó Ž³oYÄc@sSddlZddljjZddlZddlZdej fd„ƒYZ dS(iÿÿÿÿNt TestBlakecBs eZdZd„Zd„ZRS(s Test sign functions cCs^d}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.(tlibnacltcrypto_generichashtassertNotEqual(tselftmsg1tmsg2tchash1tchash2((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyttest_keyless_blake sc CsEd}d}tjjƒ}tjjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.( Rtutilst rand_noncetblaketBlake2btdigesttblake2bRt assertEqual( RRRtkey1tkey2tkhash1_1t khash1_1_2tkhash1_2tkhash2_1tkhash2_2((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyttest_key_blakes$(t__name__t __module__t__doc__R R(((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyRs ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_art libnacl.blakeRtunittesttTestCaseR(((s6/home/thatch/projects/libnacl/tests/unit/test_blake.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_raw_public.cpython-36-PYTEST.pyc0000644000175000001440000000461513173435433026764 0ustar thatchusers000000000000003 ޳oYŠ ã@sBddlZddljjZddlZddlZddlZGdd„dej ƒZ dS)éNc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú TestPublicz Test public functions cCsètjƒ\}}tjƒ\}}tjƒ\}}|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|jt|ƒtjƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒ|j||ƒdS)N)ÚlibnaclÚcrypto_box_keypairÚ assertEqualÚlenÚcrypto_box_PUBLICKEYBYTESÚassertNotEqual)ÚselfÚpk1Úsk1Úpk2Úsk2Úpk3Úsk3©rú;/home/thatch/projects/libnacl/tests/unit/test_raw_public.pyÚtest_gen s          zTestPublic.test_gencCsÔd}tjjƒ}tjƒ\}}tjƒ\}}tj||||ƒ}|j||ƒtj||||ƒ}|j||ƒtjjƒ} tjƒ\} } tjƒ\} } tj|| | | ƒ}|j||ƒtj|| | | ƒ}|j||ƒ|j|| ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?)rÚutilsÚ rand_noncerÚ crypto_boxrÚcrypto_box_openr)r ÚmsgÚnonce1r r r r Úenc_msgÚ clear_msgZnonce2rrZpk4Zsk4Úenc_msg2Ú clear_msg2rrrÚtest_boxs"           zTestPublic.test_boxc Csvd}tjjƒ}tjƒ\}}tjƒ\}}tj||ƒ}tj||ƒ}tj|||ƒ} |j|| ƒtj| ||ƒ} |j| |ƒdS)Ns$Are you suggesting coconuts migrate?) rrrrÚcrypto_box_beforenmÚcrypto_box_afternmrÚcrypto_box_open_afternmr) r rrr r r r Úk1Úk2rrrrrÚ test_boxnm5s      zTestPublic.test_boxnmc Csd}tjƒ\}}tj||ƒ}|j||ƒtj|||ƒ}|j||ƒtjƒ\}}tj||ƒ}|j||ƒtj|||ƒ} |j| |ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?)rrÚcrypto_box_sealrÚcrypto_box_seal_openr) r rÚpkÚskrrr r rrrrrÚ test_box_sealBs        zTestPublic.test_box_sealN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr#r(rrrrr s  r) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arrÚ libnacl.utilsÚunittestÚTestCaserrrrrÚs  libnacl-1.6.1/tests/unit/__pycache__/test_auth_verify.cpython-36.pyc0000644000175000001440000000352113134221747026125 0ustar thatchusers000000000000003 ޳oY% ã@s.ddlZddlZddlZGdd„dejƒZdS)éNc@s eZdZdZdd„Zdd„ZdS)ÚTestAuthVerifyz$ Test onetimeauth functions cCsÈd}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}|jtj|||ƒƒ|jtj|||ƒƒ|jtƒ}tj|||ƒWdQRX|jd|jj kƒ|jtƒ}tj|||ƒWdQRX|jd|jj kƒdS)NsQAnybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.zFailed to auth msg) ÚlibnaclÚutilsÚ salsa_keyÚ crypto_authÚ assertTrueÚcrypto_auth_verifyÚ assertRaisesÚ ValueErrorÚ exceptionÚargs)ÚselfÚmsgÚkey1Úkey2Úsig1Úsig2Úcontext©rúslibnacl-1.6.1/tests/unit/__pycache__/test_blake.cpython-36-PYTEST.pyc0000644000175000001440000000271113173435433025706 0ustar thatchusers000000000000003 ޳oYÄã@s:ddlZddljjZddlZddlZGdd„dej ƒZ dS)éNc@s eZdZdZdd„Zdd„ZdS)Ú TestBlakez Test sign functions cCsDd}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.)ÚlibnaclÚcrypto_generichashÚassertNotEqual)ÚselfÚmsg1Úmsg2Zchash1Zchash2©r ú6/home/thatch/projects/libnacl/tests/unit/test_blake.pyÚtest_keyless_blake s    zTestBlake.test_keyless_blakec Csæd}d}tjjƒ}tjjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ}tjj||ƒjƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS)Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.) rÚutilsÚ rand_nonceZblakeZBlake2bÚdigestÚblake2brÚ assertEqual) rrrÚkey1Úkey2Zkhash1_1Z khash1_1_2Zkhash1_2Zkhash2_1Zkhash2_2r r r Útest_key_blakes$          zTestBlake.test_key_blakeN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rr r r r rs r) ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arZ libnacl.blakerÚunittestÚTestCaserr r r r Ús libnacl-1.6.1/tests/unit/__pycache__/test_raw_generichash.cpython-27-PYTEST.pyc0000644000175000001440000000342013173442023027750 0ustar thatchusers00000000000000ó Ž³oY¼c@sSddlZddljjZddlZddlZdejfd„ƒYZ dS(iÿÿÿÿNtTestGenericHashcBs eZdZd„Zd„ZRS(s Test sign functions cCs^d}d}tj|ƒ}tj|ƒ}|j||ƒ|j||ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.(tlibnacltcrypto_generichashtassertNotEqual(tselftmsg1tmsg2tchash1tchash2((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyttest_keyless_generichash sc Csd}d}tjjƒ}tjjƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ}tj||ƒ} |j||ƒ|j||ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒ|j|| ƒ|j||ƒdS(Ns$Are you suggesting coconuts migrate?s"Not at all, they could be carried.(Rtutilst rand_nonceRRt assertEqual( RRRtkey1tkey2tkhash1_1t khash1_1_2tkhash1_2tkhash2_1tkhash2_2((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyttest_key_generichashs$(t__name__t __module__t__doc__R R(((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyRs ( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRtunittesttTestCaseR(((s@/home/thatch/projects/libnacl/tests/unit/test_raw_generichash.pyts   libnacl-1.6.1/tests/unit/__pycache__/test_verify.cpython-36.pyc0000644000175000001440000000530413134221747025105 0ustar thatchusers000000000000003 ޳oYi ã@s<dZddlZddlZGdd„dejƒZGdd„dejƒZdS)z" Basic tests for verify functions éNc@s$eZdZdd„Zdd„Zdd„ZdS)Ú TestVerifycCs˜tjdƒ}|dd…}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@d7<t|ƒ}|jtj||ƒƒ|jtj||ƒƒ|j tj dƒdS)Nééé) ÚlibnaclÚrandombytes_bufÚ assertTrueÚcrypto_verify_16Úbytes_eqÚ bytearrayÚrandombytes_randomÚbytesÚ assertFalseÚ assertEqualÚcrypto_verify_16_BYTES)ÚselfZv16Zv16x©rú7/home/thatch/projects/libnacl/tests/unit/test_verify.pyÚ test_verify16 s  zTestVerify.test_verify16cCs˜tjdƒ}|dd…}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@d7<t|ƒ}|jtj||ƒƒ|jtj||ƒƒ|j tj dƒdS)Né ér) rrrÚcrypto_verify_32r r r r rrÚcrypto_verify_32_BYTES)rZv32Zv32xrrrÚ test_verify32s  zTestVerify.test_verify32cCs˜tjdƒ}|dd…}|jtj||ƒƒ|jtj||ƒƒt|ƒ}|tjƒd@d7<t|ƒ}|jtj||ƒƒ|jtj||ƒƒ|j tj dƒdS)Né@é?r) rrrÚcrypto_verify_64r r r r rrÚcrypto_verify_64_BYTES)rZv64Zv64xrrrÚ test_verify64%s  zTestVerify.test_verify64N)Ú__name__Ú __module__Ú __qualname__rrrrrrrr s  rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚTestVerifyBytesEqcCs,tjdƒ}|dd…}|jtj||ƒƒdS)Néz)rrrr )rÚaÚbrrrÚ test_equal4s  zTestVerifyBytesEq.test_equalcCs@tjdƒ}t|ƒ}|dd7<t|ƒ}|jtj||ƒƒdS)Nr#éWr)rrr r rr )rr$r%rrrÚtest_different9s  z TestVerifyBytesEq.test_differentc Cs8tjdƒ}t|ƒ}|jtƒtj||ƒWdQRXdS)Nr#)rrr Ú assertRaisesÚ TypeErrorr )rr$r%rrrÚtest_invalid_type@s  z#TestVerifyBytesEq.test_invalid_typecCs,tjdƒ}|dd…}|jtj||ƒƒdS)Nr#réÿÿÿÿ)rrrr )rr$r%rrrÚtest_different_lengthFs  z'TestVerifyBytesEq.test_different_lengthN)rr r!r&r(r+r-rrrrr"3sr")Ú__doc__rÚunittestÚTestCaserr"rrrrÚs)libnacl-1.6.1/tests/unit/__pycache__/test_save.cpython-36-PYTEST.pyc0000644000175000001440000000546313173435433025575 0ustar thatchusers000000000000003 ޳oY ã@srddlZddljjZddlZddlZddl Zddl Zddl Z ddl Z ddl Z ddlZddlZGdd„de jƒZdS)éNc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ÚTestSavez cCsÄd}tjjƒ}tjjƒ}tjƒ\}}tj|ƒtjƒ\}}tj|ƒ|j|ƒ|j|ƒtjj ||j ƒ}tjj ||j ƒ}|j |ƒ} |j |ƒ} tj j |ƒ} tj j |ƒ} tjj | | j ƒ} tjj | | j ƒ}|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j|j| jƒ|j|j | j ƒ|j|j| jƒ|j|j| jƒ|j| ƒ}| j| ƒ}|j||ƒ|j||ƒtj j |ƒ}|j|j|jƒ|j|j |j ƒ|j|j|jƒtj|ƒtj|ƒdS)Ns:then leap out of the rabbit, taking the French by surprise)ÚlibnaclÚdualÚ DualSecretÚtempfileÚmkstempÚosÚcloseÚsaveÚpublicÚBoxÚpkÚencryptÚutilsÚload_keyÚ assertEqualÚskÚvkÚseedÚdecryptÚremove)ÚselfÚmsgÚbobÚaliceÚfh_Úbob_pathZ alice_pathÚbob_boxÚ alice_boxZbob_encZ alice_encZbob_loadZ alice_loadZ bob_load_boxZalice_load_boxZbob_decZ alice_decZbob2©rú5/home/thatch/projects/libnacl/tests/unit/test_save.pyÚtest_save_loadsF                  zTestSave.test_save_loadcCs^d}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j |ƒ}|j |ƒ}|j ||ƒdS)Ns:then leap out of the rabbit, taking the French by surprise) rÚsecretÚ SecretBoxrrrr r rrrrr)rrÚboxrZbox_pathZlboxÚctxtZout_msgrrr Útest_save_load_secret9s       zTestSave.test_save_load_secretcCshd}tjjƒ}tjƒ\}}tj|ƒ|j|ƒtjj |ƒ}|j|ƒ}|j|ƒ}|j ||ƒtj |ƒdS)Ns:then leap out of the rabbit, taking the French by surprise) rÚsignÚSignerrrrr r rrrr)rrÚsignerrZ sign_pathZ signer_loadZsigned1Zsigned2rrr Útest_save_load_signDs        zTestSave.test_save_load_signcCsftjjƒ}tjƒ\}}tj|ƒ|j|ƒtj|ƒ}t j dkrBdnd}|j |tj |ƒtj |ƒdS)NÚwin32i€i¶)rrrrrrr r ÚstatÚsysÚplatformrÚST_MODEr)rrrrÚstatsZexpected_permsrrr Útest_save_permsPs     zTestSave.test_save_permsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r!r&r*r1rrrr rs '  r)ÚbuiltinsÚ @py_builtinsÚ_pytest.assertion.rewriteÚ assertionÚrewriteÚ @pytest_arÚ libnacl.dualrÚlibnacl.secretÚ libnacl.signÚ libnacl.utilsrr,Úunittestrr-ÚTestCaserrrrr Ús libnacl-1.6.1/tests/unit/__pycache__/test_secret.cpython-36.pyc0000644000175000001440000000150413134221747025064 0ustar thatchusers000000000000003 ޳oYã@s&ddlZddlZGdd„dejƒZdS)éNc@seZdZdZdd„ZdS)Ú TestSecretz c Cs‚d}tjjƒ}|j|ƒ}|j||ƒtjj|jƒ}|j|ƒ}|j||ƒ|j|ƒ}|j||ƒ|j|ƒ}|j|ƒ}|j||ƒdS)Ns6But then of course African swallows are not migratory.)ÚlibnaclÚsecretÚ SecretBoxÚencryptÚassertNotEqualÚskÚdecryptÚ assertEqual) ÚselfÚmsgÚboxÚctxtÚbox2Úclear1Úclear2Úctxt2Úclear3©rú7/home/thatch/projects/libnacl/tests/unit/test_secret.pyÚ test_secret s         zTestSecret.test_secretN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrsr)Úlibnacl.secretrÚunittestÚTestCaserrrrrÚslibnacl-1.6.1/libnacl.egg-info/0000755000175000001440000000000013200105202016634 5ustar thatchusers00000000000000libnacl-1.6.1/libnacl.egg-info/top_level.txt0000644000175000001440000000001013200105202021355 0ustar thatchusers00000000000000libnacl libnacl-1.6.1/libnacl.egg-info/SOURCES.txt0000644000175000001440000001265613200105202020532 0ustar thatchusers00000000000000AUTHORS LICENSE MANIFEST.in README.rst setup.cfg setup.py doc/Makefile doc/conf.py doc/index.rst doc/topics/dual.rst doc/topics/public.rst doc/topics/raw_generichash.rst doc/topics/raw_hash.rst doc/topics/raw_public.rst doc/topics/raw_sealed.rst doc/topics/raw_secret.rst doc/topics/raw_sign.rst doc/topics/sealed.rst doc/topics/secret.rst doc/topics/sign.rst doc/topics/utils.rst doc/topics/releases/1.0.0.rst doc/topics/releases/1.1.0.rst doc/topics/releases/1.2.0.rst doc/topics/releases/1.3.0.rst doc/topics/releases/1.3.1.rst doc/topics/releases/1.3.2.rst doc/topics/releases/1.3.3.rst doc/topics/releases/1.3.4.rst doc/topics/releases/1.4.0.rst doc/topics/releases/1.4.1.rst doc/topics/releases/1.4.2.rst doc/topics/releases/1.4.3.rst doc/topics/releases/1.4.4.rst doc/topics/releases/1.4.5.rst doc/topics/releases/1.5.0.rst doc/topics/releases/1.5.1.rst doc/topics/releases/1.5.2.rst doc/topics/releases/1.6.0.rst doc/topics/releases/1.6.1.rst doc/topics/releases/index.rst libnacl/__init__.py libnacl/aead.py libnacl/base.py libnacl/blake.py libnacl/dual.py libnacl/encode.py libnacl/public.py libnacl/sealed.py libnacl/secret.py libnacl/sign.py libnacl/utils.py libnacl/version.py libnacl.egg-info/PKG-INFO libnacl.egg-info/SOURCES.txt libnacl.egg-info/dependency_links.txt libnacl.egg-info/top_level.txt pkg/rpm/python-libnacl.spec pkg/suse/python-libnacl.changes pkg/suse/python-libnacl.spec tests/runtests.py tests/unit/__init__.py tests/unit/__init__.pyc tests/unit/test_aead.py tests/unit/test_aead.pyc tests/unit/test_auth_verify.py tests/unit/test_auth_verify.pyc tests/unit/test_blake.py tests/unit/test_blake.pyc tests/unit/test_dual.py tests/unit/test_dual.pyc tests/unit/test_public.py tests/unit/test_public.pyc tests/unit/test_raw_auth_sym.py tests/unit/test_raw_auth_sym.pyc tests/unit/test_raw_generichash.py tests/unit/test_raw_generichash.pyc tests/unit/test_raw_hash.py tests/unit/test_raw_hash.pyc tests/unit/test_raw_public.py tests/unit/test_raw_public.pyc tests/unit/test_raw_random.py tests/unit/test_raw_random.pyc tests/unit/test_raw_secret.py tests/unit/test_raw_secret.pyc tests/unit/test_raw_sign.py tests/unit/test_raw_sign.pyc tests/unit/test_save.py tests/unit/test_save.pyc tests/unit/test_seal.py tests/unit/test_seal.pyc tests/unit/test_secret.py tests/unit/test_secret.pyc tests/unit/test_sign.py tests/unit/test_sign.pyc tests/unit/test_verify.py tests/unit/test_verify.pyc tests/unit/test_version.py tests/unit/test_version.pyc tests/unit/__pycache__/__init__.cpython-36.pyc tests/unit/__pycache__/test_aead.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_aead.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_aead.cpython-36.pyc tests/unit/__pycache__/test_auth_verify.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_auth_verify.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_auth_verify.cpython-36.pyc tests/unit/__pycache__/test_blake.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_blake.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_blake.cpython-36.pyc tests/unit/__pycache__/test_dual.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_dual.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_dual.cpython-36.pyc tests/unit/__pycache__/test_public.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_public.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_public.cpython-36.pyc tests/unit/__pycache__/test_raw_auth_sym.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_auth_sym.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_auth_sym.cpython-36.pyc tests/unit/__pycache__/test_raw_generichash.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_generichash.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_generichash.cpython-36.pyc tests/unit/__pycache__/test_raw_hash.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_hash.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_hash.cpython-36.pyc tests/unit/__pycache__/test_raw_public.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_public.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_public.cpython-36.pyc tests/unit/__pycache__/test_raw_random.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_random.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_random.cpython-36.pyc tests/unit/__pycache__/test_raw_secret.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_secret.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_secret.cpython-36.pyc tests/unit/__pycache__/test_raw_sign.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_raw_sign.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_raw_sign.cpython-36.pyc tests/unit/__pycache__/test_save.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_save.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_save.cpython-36.pyc tests/unit/__pycache__/test_seal.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_seal.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_seal.cpython-36.pyc tests/unit/__pycache__/test_secret.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_secret.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_secret.cpython-36.pyc tests/unit/__pycache__/test_sign.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_sign.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_sign.cpython-36.pyc tests/unit/__pycache__/test_verify.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_verify.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_verify.cpython-36.pyc tests/unit/__pycache__/test_version.cpython-27-PYTEST.pyc tests/unit/__pycache__/test_version.cpython-36-PYTEST.pyc tests/unit/__pycache__/test_version.cpython-36.pyclibnacl-1.6.1/libnacl.egg-info/dependency_links.txt0000644000175000001440000000000113200105202022702 0ustar thatchusers00000000000000 libnacl-1.6.1/libnacl.egg-info/PKG-INFO0000644000175000001440000000135313200105202017733 0ustar thatchusers00000000000000Metadata-Version: 1.1 Name: libnacl Version: 1.6.1 Summary: Python bindings for libsodium based on ctypes Home-page: https://libnacl.readthedocs.org/ Author: Thomas S Hatch Author-email: thatch@saltstack.com License: UNKNOWN Description-Content-Type: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.4 Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Topic :: Security :: Cryptography libnacl-1.6.1/libnacl/0000755000175000001440000000000013200105202015142 5ustar thatchusers00000000000000libnacl-1.6.1/libnacl/public.py0000644000175000001440000000524213133731616017020 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' High level classes and routines around public key encryption and decryption ''' # import libnacl libs import libnacl import libnacl.utils import libnacl.encode import libnacl.dual import libnacl.base class PublicKey(libnacl.base.BaseKey): ''' This class is used to manage public keys ''' def __init__(self, pk): if len(pk) == libnacl.crypto_box_PUBLICKEYBYTES: self.pk = pk else: raise ValueError('Passed in invalid public key') class SecretKey(libnacl.base.BaseKey): ''' This class is used to manage keypairs ''' def __init__(self, sk=None): ''' If a secret key is not passed in then it will be generated ''' if sk is None: self.pk, self.sk = libnacl.crypto_box_keypair() elif len(sk) == libnacl.crypto_box_SECRETKEYBYTES: self.sk = sk self.pk = libnacl.crypto_scalarmult_base(sk) else: raise ValueError('Passed in invalid secret key') class Box(object): ''' TheBox class is used to create cryptographic boxes and unpack cryptographic boxes ''' def __init__(self, sk, pk): if isinstance(sk, (SecretKey, libnacl.dual.DualSecret)): sk = sk.sk if isinstance(pk, (SecretKey, libnacl.dual.DualSecret)): raise ValueError('Passed in secret key as public key') if isinstance(pk, PublicKey): pk = pk.pk if pk and sk: self._k = libnacl.crypto_box_beforenm(pk, sk) def encrypt(self, msg, nonce=None, pack_nonce=True): ''' Encrypt the given message with the given nonce, if the nonce is not provided it will be generated from the libnacl.utils.rand_nonce function ''' if nonce is None: nonce = libnacl.utils.rand_nonce() elif len(nonce) != libnacl.crypto_box_NONCEBYTES: raise ValueError('Invalid nonce size') ctxt = libnacl.crypto_box_afternm(msg, nonce, self._k) if pack_nonce: return nonce + ctxt else: return nonce, ctxt def decrypt(self, ctxt, nonce=None): ''' Decrypt the given message, if a nonce is passed in attempt to decrypt it with the given nonce, otherwise assum that the nonce is attached to the message ''' if nonce is None: nonce = ctxt[:libnacl.crypto_box_NONCEBYTES] ctxt = ctxt[libnacl.crypto_box_NONCEBYTES:] elif len(nonce) != libnacl.crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') msg = libnacl.crypto_box_open_afternm(ctxt, nonce, self._k) return msg libnacl-1.6.1/libnacl/sealed.py0000644000175000001440000000162413133731616016777 0ustar thatchusers00000000000000import libnacl import libnacl.public import libnacl.dual class SealedBox(object): ''' Sealed box is a variant of Box that does not authenticate sender. ''' def __init__(self, pk, sk=None): self.pk = pk self.sk = sk if isinstance(pk, (libnacl.public.SecretKey, libnacl.dual.DualSecret)): self.pk = pk.pk self.sk = pk.sk if isinstance(pk, libnacl.public.PublicKey): self.pk = pk.pk def encrypt(self, msg): ''' Encrypt the given message using the receiver's public key ''' return libnacl.crypto_box_seal(msg, self.pk) def decrypt(self, msg): ''' Decrypt the given message using the receiver's public and private key ''' if not self.sk: raise ValueError('Secret key is not set') return libnacl.crypto_box_seal_open(msg, self.pk, self.sk) libnacl-1.6.1/libnacl/dual.py0000644000175000001440000000153613133731616016471 0ustar thatchusers00000000000000''' The dual key system allows for the creation of keypairs that contain both cryptographic and signing keys ''' # import libnacl libs import libnacl import libnacl.base import libnacl.public import libnacl.sign class DualSecret(libnacl.base.BaseKey): ''' Manage crypt and sign keys in one object ''' def __init__(self, crypt=None, sign=None): self.crypt = libnacl.public.SecretKey(crypt) self.signer = libnacl.sign.Signer(sign) self.sk = self.crypt.sk self.seed = self.signer.seed self.pk = self.crypt.pk self.vk = self.signer.vk def sign(self, msg): ''' Sign the given message ''' return self.signer.sign(msg) def signature(self, msg): ''' Return just the signature for the message ''' return self.signer.signature(msg) libnacl-1.6.1/libnacl/aead.py0000644000175000001440000000477513133731616016446 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' Utilities to make secret box encryption simple ''' # Import libnacl import libnacl import libnacl.utils import libnacl.base class AEAD(libnacl.base.BaseKey): ''' Manage AEAD encryption using the IETF ChaCha20-Poly1305(default) or AES-GCM algorithm ''' def __init__(self, key=None): if key is None: key = libnacl.utils.aead_key() if len(key) != libnacl.crypto_aead_chacha20poly1305_ietf_KEYBYTES: # same size for both raise ValueError('Invalid key') self.sk = key self.usingAES = False def useAESGCM(self): self.usingAES = True return self def encrypt(self, msg, aad, nonce=None, pack_nonce_aad=True): ''' Encrypt the given message. If a nonce is not given it will be generated via the rand_nonce function ''' if nonce is None: nonce = libnacl.utils.rand_aead_nonce() if len(nonce) != libnacl.crypto_aead_aes256gcm_NPUBBYTES: raise ValueError('Invalid nonce') if self.usingAES: ctxt = libnacl.crypto_aead_aes256gcm_encrypt(msg, aad, nonce, self.sk) else: ctxt = libnacl.crypto_aead_chacha20poly1305_ietf_encrypt(msg, aad, nonce, self.sk) if pack_nonce_aad: return aad + nonce + ctxt else: return aad, nonce, ctxt def decrypt(self, ctxt, aadLen): ''' Decrypt the given message, if no nonce or aad are given they will be extracted from the message ''' aad = ctxt[:aadLen] nonce = ctxt[aadLen:aadLen+libnacl.crypto_aead_aes256gcm_NPUBBYTES] ctxt = ctxt[aadLen+libnacl.crypto_aead_aes256gcm_NPUBBYTES:] if len(nonce) != libnacl.crypto_aead_aes256gcm_NPUBBYTES: raise ValueError('Invalid nonce') if self.usingAES: return libnacl.crypto_aead_aes256gcm_decrypt(ctxt, aad, nonce, self.sk) return libnacl.crypto_aead_chacha20poly1305_ietf_decrypt(ctxt, aad, nonce, self.sk) def decrypt_unpacked(self, aad, nonce, ctxt): ''' Decrypt the given message, if no nonce or aad are given they will be extracted from the message ''' if len(nonce) != libnacl.crypto_aead_aes256gcm_NPUBBYTES: raise ValueError('Invalid nonce') if self.usingAES: return libnacl.crypto_aead_aes256gcm_decrypt(ctxt, aad, nonce, self.sk) return libnacl.crypto_aead_chacha20poly1305_ietf_decrypt(ctxt, aad, nonce, self.sk) libnacl-1.6.1/libnacl/secret.py0000644000175000001440000000300413133731616017021 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' Utilities to make secret box encryption simple ''' # Import libnacl import libnacl import libnacl.utils import libnacl.base class SecretBox(libnacl.base.BaseKey): ''' Manage symetric encryption using the salsa20 algorithm ''' def __init__(self, key=None): if key is None: key = libnacl.utils.salsa_key() if len(key) != libnacl.crypto_secretbox_KEYBYTES: raise ValueError('Invalid key') self.sk = key def encrypt(self, msg, nonce=None, pack_nonce=True): ''' Encrypt the given message. If a nonce is not given it will be generated via the rand_nonce function ''' if nonce is None: nonce = libnacl.utils.rand_nonce() if len(nonce) != libnacl.crypto_secretbox_NONCEBYTES: raise ValueError('Invalid nonce size') ctxt = libnacl.crypto_secretbox(msg, nonce, self.sk) if pack_nonce: return nonce + ctxt else: return nonce, ctxt def decrypt(self, ctxt, nonce=None): ''' Decrypt the given message, if no nonce is given the nonce will be extracted from the message ''' if nonce is None: nonce = ctxt[:libnacl.crypto_secretbox_NONCEBYTES] ctxt = ctxt[libnacl.crypto_secretbox_NONCEBYTES:] if len(nonce) != libnacl.crypto_secretbox_NONCEBYTES: raise ValueError('Invalid nonce') return libnacl.crypto_secretbox_open(ctxt, nonce, self.sk) libnacl-1.6.1/libnacl/__init__.py0000644000175000001440000010575013173434757017320 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' Wrap libsodium routines ''' # pylint: disable=C0103 # Import libnacl libs from libnacl.version import __version__ # Import python libs import ctypes import sys import os __SONAMES = (23, 18, 17, 13, 10, 5, 4) def _get_nacl(): ''' Locate the nacl c libs to use ''' # Import libsodium if sys.platform.startswith('win'): try: return ctypes.cdll.LoadLibrary('libsodium') except OSError: pass for soname_ver in __SONAMES: try: return ctypes.cdll.LoadLibrary( 'libsodium-{0}'.format(soname_ver) ) except OSError: pass msg = 'Could not locate nacl lib, searched for libsodium' raise OSError(msg) elif sys.platform.startswith('darwin'): try: return ctypes.cdll.LoadLibrary('libsodium.dylib') except OSError: pass try: libidx = __file__.find('lib') if libidx > 0: libpath = __file__[0:libidx+3] + '/libsodium.dylib' return ctypes.cdll.LoadLibrary(libpath) except OSError: msg = 'Could not locate nacl lib, searched for libsodium' raise OSError(msg) else: try: return ctypes.cdll.LoadLibrary('libsodium.so') except OSError: pass try: return ctypes.cdll.LoadLibrary('/usr/local/lib/libsodium.so') except OSError: pass try: libidx = __file__.find('lib') if libidx > 0: libpath = __file__[0:libidx+3] + '/libsodium.so' return ctypes.cdll.LoadLibrary(libpath) except OSError: pass for soname_ver in __SONAMES: try: return ctypes.cdll.LoadLibrary( 'libsodium.so.{0}'.format(soname_ver) ) except OSError: pass try: # fall back to shipped libsodium, trust os version first libpath = os.path.join(os.path.dirname(__file__), 'libsodium.so') return ctypes.cdll.LoadLibrary(libpath) except OSError: pass msg = 'Could not locate nacl lib, searched for libsodium.so, ' for soname_ver in __SONAMES: msg += 'libsodium.so.{0}, '.format(soname_ver) raise OSError(msg) nacl = _get_nacl() # Define exceptions class CryptError(Exception): """ Base Exception for cryptographic errors """ sodium_init = nacl.sodium_init sodium_init.res_type = ctypes.c_int if sodium_init() < 0: raise RuntimeError('sodium_init() call failed!') # Define constants try: crypto_box_SEALBYTES = nacl.crypto_box_sealbytes() HAS_SEAL = True except AttributeError: HAS_SEAL = False try: crypto_aead_aes256gcm_KEYBYTES = nacl.crypto_aead_aes256gcm_keybytes() crypto_aead_aes256gcm_NPUBBYTES = nacl.crypto_aead_aes256gcm_npubbytes() crypto_aead_aes256gcm_ABYTES = nacl.crypto_aead_aes256gcm_abytes() HAS_AEAD_AES256GCM = bool(nacl.crypto_aead_aes256gcm_is_available()) crypto_aead_chacha20poly1305_ietf_KEYBYTES = nacl.crypto_aead_chacha20poly1305_ietf_keybytes() crypto_aead_chacha20poly1305_ietf_NPUBBYTES = nacl.crypto_aead_chacha20poly1305_ietf_npubbytes() crypto_aead_chacha20poly1305_ietf_ABYTES = nacl.crypto_aead_chacha20poly1305_ietf_abytes() HAS_AEAD_CHACHA20POLY1305_IETF = True HAS_AEAD = True except AttributeError: HAS_AEAD_AES256GCM = False HAS_AEAD_CHACHA20POLY1305_IETF = False HAS_AEAD = False crypto_box_SECRETKEYBYTES = nacl.crypto_box_secretkeybytes() crypto_box_SEEDBYTES = nacl.crypto_box_seedbytes() crypto_box_PUBLICKEYBYTES = nacl.crypto_box_publickeybytes() crypto_box_NONCEBYTES = nacl.crypto_box_noncebytes() crypto_box_ZEROBYTES = nacl.crypto_box_zerobytes() crypto_box_BOXZEROBYTES = nacl.crypto_box_boxzerobytes() crypto_box_BEFORENMBYTES = nacl.crypto_box_beforenmbytes() crypto_scalarmult_BYTES = nacl.crypto_scalarmult_bytes() crypto_scalarmult_SCALARBYTES = nacl.crypto_scalarmult_scalarbytes() crypto_sign_BYTES = nacl.crypto_sign_bytes() crypto_sign_SEEDBYTES = nacl.crypto_sign_secretkeybytes() // 2 crypto_sign_PUBLICKEYBYTES = nacl.crypto_sign_publickeybytes() crypto_sign_SECRETKEYBYTES = nacl.crypto_sign_secretkeybytes() crypto_sign_ed25519_PUBLICKEYBYTES = nacl.crypto_sign_ed25519_publickeybytes() crypto_sign_ed25519_SECRETKEYBYTES = nacl.crypto_sign_ed25519_secretkeybytes() crypto_box_MACBYTES = crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES crypto_secretbox_KEYBYTES = nacl.crypto_secretbox_keybytes() crypto_secretbox_NONCEBYTES = nacl.crypto_secretbox_noncebytes() crypto_secretbox_ZEROBYTES = nacl.crypto_secretbox_zerobytes() crypto_secretbox_BOXZEROBYTES = nacl.crypto_secretbox_boxzerobytes() crypto_secretbox_MACBYTES = crypto_secretbox_ZEROBYTES - crypto_secretbox_BOXZEROBYTES crypto_stream_KEYBYTES = nacl.crypto_stream_keybytes() crypto_stream_NONCEBYTES = nacl.crypto_stream_noncebytes() crypto_auth_BYTES = nacl.crypto_auth_bytes() crypto_auth_KEYBYTES = nacl.crypto_auth_keybytes() crypto_onetimeauth_BYTES = nacl.crypto_onetimeauth_bytes() crypto_onetimeauth_KEYBYTES = nacl.crypto_onetimeauth_keybytes() crypto_generichash_BYTES = nacl.crypto_generichash_bytes() crypto_generichash_BYTES_MIN = nacl.crypto_generichash_bytes_min() crypto_generichash_BYTES_MAX = nacl.crypto_generichash_bytes_max() crypto_generichash_KEYBYTES = nacl.crypto_generichash_keybytes() crypto_generichash_KEYBYTES_MIN = nacl.crypto_generichash_keybytes_min() crypto_generichash_KEYBYTES_MAX = nacl.crypto_generichash_keybytes_max() crypto_scalarmult_curve25519_BYTES = nacl.crypto_scalarmult_curve25519_bytes() crypto_hash_BYTES = nacl.crypto_hash_sha512_bytes() crypto_hash_sha256_BYTES = nacl.crypto_hash_sha256_bytes() crypto_hash_sha512_BYTES = nacl.crypto_hash_sha512_bytes() crypto_verify_16_BYTES = nacl.crypto_verify_16_bytes() crypto_verify_32_BYTES = nacl.crypto_verify_32_bytes() crypto_verify_64_BYTES = nacl.crypto_verify_64_bytes() # pylint: enable=C0103 # Pubkey defs def crypto_box_keypair(): ''' Generate and return a new keypair pk, sk = nacl.crypto_box_keypair() ''' pk = ctypes.create_string_buffer(crypto_box_PUBLICKEYBYTES) sk = ctypes.create_string_buffer(crypto_box_SECRETKEYBYTES) nacl.crypto_box_keypair(pk, sk) return pk.raw, sk.raw def crypto_box_seed_keypair(seed): ''' Generate and return a keypair from a key seed ''' if len(seed) != crypto_box_SEEDBYTES: raise ValueError('Invalid key seed') pk = ctypes.create_string_buffer(crypto_box_PUBLICKEYBYTES) sk = ctypes.create_string_buffer(crypto_box_SECRETKEYBYTES) nacl.crypto_box_seed_keypair(pk, sk, seed) return pk.raw, sk.raw def crypto_scalarmult_base(sk): ''' Generate a public key from a secret key ''' if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') pk = ctypes.create_string_buffer(crypto_box_PUBLICKEYBYTES) nacl.crypto_scalarmult_base(pk, sk) return pk.raw def crypto_box(msg, nonce, pk, sk): ''' Using a public key and a secret key encrypt the given message. A nonce must also be passed in, never reuse the nonce enc_msg = nacl.crypto_box('secret message', , , ) ''' if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') pad = b'\x00' * crypto_box_ZEROBYTES + msg c = ctypes.create_string_buffer(len(pad)) ret = nacl.crypto_box(c, pad, ctypes.c_ulonglong(len(pad)), nonce, pk, sk) if ret: raise CryptError('Unable to encrypt message') return c.raw[crypto_box_BOXZEROBYTES:] def crypto_box_open(ctxt, nonce, pk, sk): ''' Decrypts a message given the receiver's private key, and sender's public key ''' if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') pad = b'\x00' * crypto_box_BOXZEROBYTES + ctxt msg = ctypes.create_string_buffer(len(pad)) ret = nacl.crypto_box_open( msg, pad, ctypes.c_ulonglong(len(pad)), nonce, pk, sk) if ret: raise CryptError('Unable to decrypt ciphertext') return msg.raw[crypto_box_ZEROBYTES:] def crypto_box_easy(msg, nonce, pk, sk): ''' Using a public key and a secret key encrypt the given message. A nonce must also be passed in, never reuse the nonce enc_msg = nacl.crypto_box_easy('secret message', , , ) ''' if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') c = ctypes.create_string_buffer(len(msg) + crypto_box_MACBYTES) ret = nacl.crypto_box(c, msg, ctypes.c_ulonglong(len(msg)), nonce, pk, sk) if ret: raise CryptError('Unable to encrypt message') return c.raw def crypto_box_open_easy(ctxt, nonce, pk, sk): ''' Decrypts a message given the receiver's private key, and sender's public key ''' if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') msg = ctypes.create_string_buffer(len(ctxt) - crypto_box_MACBYTES) ret = nacl.crypto_box_open( msg, ctxt, ctypes.c_ulonglong(len(ctxt)), nonce, pk, sk) if ret: raise CryptError('Unable to decrypt ciphertext') return msg.raw[crypto_box_ZEROBYTES:] def crypto_box_beforenm(pk, sk): ''' Partially performs the computation required for both encryption and decryption of data ''' if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') k = ctypes.create_string_buffer(crypto_box_BEFORENMBYTES) ret = nacl.crypto_box_beforenm(k, pk, sk) if ret: raise CryptError('Unable to compute shared key') return k.raw def crypto_box_afternm(msg, nonce, k): ''' Encrypts a given a message, using partial computed data ''' if len(k) != crypto_box_BEFORENMBYTES: raise ValueError('Invalid shared key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') pad = b'\x00' * crypto_box_ZEROBYTES + msg ctxt = ctypes.create_string_buffer(len(pad)) ret = nacl.crypto_box_afternm(ctxt, pad, ctypes.c_ulonglong(len(pad)), nonce, k) if ret: raise CryptError('Unable to encrypt messsage') return ctxt.raw[crypto_box_BOXZEROBYTES:] def crypto_box_open_afternm(ctxt, nonce, k): ''' Decrypts a ciphertext ctxt given k ''' if len(k) != crypto_box_BEFORENMBYTES: raise ValueError('Invalid shared key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') pad = b'\x00' * crypto_box_BOXZEROBYTES + ctxt msg = ctypes.create_string_buffer(len(pad)) ret = nacl.crypto_box_open_afternm( msg, pad, ctypes.c_ulonglong(len(pad)), nonce, k) if ret: raise CryptError('unable to decrypt message') return msg.raw[crypto_box_ZEROBYTES:] def crypto_box_easy_afternm(msg, nonce, k): ''' Using a precalculated shared key, encrypt the given message. A nonce must also be passed in, never reuse the nonce enc_msg = nacl.crypto_box_easy_afternm('secret message', , ) ''' if len(k) != crypto_box_BEFORENMBYTES: raise ValueError('Invalid shared key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') ctxt = ctypes.create_string_buffer(len(msg) + crypto_box_MACBYTES) ret = nacl.crypto_box_easy_afternm(ctxt, msg, ctypes.c_ulonglong(len(msg)), nonce, k) if ret: raise CryptError('Unable to encrypt messsage') return ctxt.raw def crypto_box_open_easy_afternm(ctxt, nonce, k): ''' Decrypts a ciphertext ctxt given k ''' if len(k) != crypto_box_BEFORENMBYTES: raise ValueError('Invalid shared key') if len(nonce) != crypto_box_NONCEBYTES: raise ValueError('Invalid nonce') msg = ctypes.create_string_buffer(len(ctxt) - crypto_box_MACBYTES) ret = nacl.crypto_box_open_easy_afternm( msg, ctxt, ctypes.c_ulonglong(len(ctxt)), nonce, k) if ret: raise CryptError('unable to decrypt message') return msg.raw def crypto_box_seal(msg, pk): ''' Using a public key to encrypt the given message. The identity of the sender cannot be verified. enc_msg = nacl.crypto_box_seal('secret message', ) ''' if not HAS_SEAL: raise ValueError('Underlying Sodium library does not support sealed boxes') if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if not isinstance(msg, bytes): raise TypeError('Message must be bytes') c = ctypes.create_string_buffer(len(msg) + crypto_box_SEALBYTES) ret = nacl.crypto_box_seal(c, msg, ctypes.c_ulonglong(len(msg)), pk) if ret: raise CryptError('Unable to encrypt message') return c.raw def crypto_box_seal_open(ctxt, pk, sk): ''' Decrypts a message given the receiver's public and private key. ''' if not HAS_SEAL: raise ValueError('Underlying Sodium library does not support sealed boxes') if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError('Invalid public key') if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError('Invalid secret key') if not isinstance(ctxt, bytes): raise TypeError('Message must be bytes') c = ctypes.create_string_buffer(len(ctxt) - crypto_box_SEALBYTES) ret = nacl.crypto_box_seal_open(c, ctxt, ctypes.c_ulonglong(len(ctxt)), pk, sk) if ret: raise CryptError('Unable to decrypt message') return c.raw # Signing functions def crypto_sign_keypair(): ''' Generates a signing/verification key pair ''' vk = ctypes.create_string_buffer(crypto_sign_PUBLICKEYBYTES) sk = ctypes.create_string_buffer(crypto_sign_SECRETKEYBYTES) ret = nacl.crypto_sign_keypair(vk, sk) if ret: raise ValueError('Failed to generate keypair') return vk.raw, sk.raw def crypto_sign_ed25519_keypair(): ''' Generates a signing/verification Ed25519 key pair ''' vk = ctypes.create_string_buffer(crypto_sign_ed25519_PUBLICKEYBYTES) sk = ctypes.create_string_buffer(crypto_sign_ed25519_SECRETKEYBYTES) ret = nacl.crypto_sign_ed25519_keypair(vk, sk) if ret: raise ValueError('Failed to generate keypair') return vk.raw, sk.raw def crypto_sign_ed25519_sk_to_pk(sk): ''' Extract the public key from the secret key ''' pk = ctypes.create_string_buffer(crypto_sign_PUBLICKEYBYTES) ret = nacl.crypto_sign_ed25519_sk_to_pk(pk, sk) if ret: raise ValueError('Failed to generate public key') return pk.raw def crypto_sign_ed25519_sk_to_seed(sk): ''' Extract the seed from the secret key ''' seed = ctypes.create_string_buffer(crypto_sign_SEEDBYTES) ret = nacl.crypto_sign_ed25519_sk_to_seed(seed, sk) if ret: raise ValueError('Failed to generate seed') return seed.raw def crypto_sign(msg, sk): ''' Sign the given message with the given signing key ''' sig = ctypes.create_string_buffer(len(msg) + crypto_sign_BYTES) slen = ctypes.pointer(ctypes.c_ulonglong()) ret = nacl.crypto_sign( sig, slen, msg, ctypes.c_ulonglong(len(msg)), sk) if ret: raise ValueError('Failed to sign message') return sig.raw def crypto_sign_detached(msg, sk): ''' Return signature for the given message with the given signing key ''' sig = ctypes.create_string_buffer(crypto_sign_BYTES) slen = ctypes.pointer(ctypes.c_ulonglong()) ret = nacl.crypto_sign_detached( sig, slen, msg, ctypes.c_ulonglong(len(msg)), sk) if ret: raise ValueError('Failed to sign message') return sig.raw[:slen.contents.value] def crypto_sign_seed_keypair(seed): ''' Computes and returns the secret and verify keys from the given seed ''' if len(seed) != crypto_sign_SEEDBYTES: raise ValueError('Invalid Seed') sk = ctypes.create_string_buffer(crypto_sign_SECRETKEYBYTES) vk = ctypes.create_string_buffer(crypto_sign_PUBLICKEYBYTES) ret = nacl.crypto_sign_seed_keypair(vk, sk, seed) if ret: raise CryptError('Failed to generate keypair from seed') return (vk.raw, sk.raw) def crypto_sign_open(sig, vk): ''' Verifies the signed message sig using the signer's verification key ''' msg = ctypes.create_string_buffer(len(sig)) msglen = ctypes.c_ulonglong() msglenp = ctypes.pointer(msglen) ret = nacl.crypto_sign_open( msg, msglenp, sig, ctypes.c_ulonglong(len(sig)), vk) if ret: raise ValueError('Failed to validate message') return msg.raw[:msglen.value] # pylint: disable=invalid-slice-index def crypto_sign_verify_detached(sig, msg, vk): ''' Verifies that sig is a valid signature for the message msg using the signer's verification key ''' ret = nacl.crypto_sign_verify_detached( sig, msg, ctypes.c_ulonglong(len(msg)), vk) if ret: raise ValueError('Failed to validate message') return msg # Authenticated Symmetric Encryption def crypto_secretbox(message, nonce, key): """Encrypts and authenticates a message using the given secret key, and nonce Args: message (bytes): a message to encrypt nonce (bytes): nonce, does not have to be confidential must be `crypto_secretbox_NONCEBYTES` in length key (bytes): secret key, must be `crypto_secretbox_KEYBYTES` in length Returns: bytes: the ciphertext Raises: ValueError: if arguments' length is wrong or the operation has failed. """ if len(key) != crypto_secretbox_KEYBYTES: raise ValueError('Invalid key') if len(nonce) != crypto_secretbox_NONCEBYTES: raise ValueError('Invalid nonce') pad = b'\x00' * crypto_secretbox_ZEROBYTES + message ctxt = ctypes.create_string_buffer(len(pad)) ret = nacl.crypto_secretbox( ctxt, pad, ctypes.c_ulonglong(len(pad)), nonce, key) if ret: raise ValueError('Failed to encrypt message') return ctxt.raw[crypto_secretbox_BOXZEROBYTES:] def crypto_secretbox_open(ctxt, nonce, key): """ Decrypts a ciphertext ctxt given the receivers private key, and senders public key """ if len(key) != crypto_secretbox_KEYBYTES: raise ValueError('Invalid key') if len(nonce) != crypto_secretbox_NONCEBYTES: raise ValueError('Invalid nonce') pad = b'\x00' * crypto_secretbox_BOXZEROBYTES + ctxt msg = ctypes.create_string_buffer(len(pad)) ret = nacl.crypto_secretbox_open( msg, pad, ctypes.c_ulonglong(len(pad)), nonce, key) if ret: raise ValueError('Failed to decrypt message') return msg.raw[crypto_secretbox_ZEROBYTES:] # Authenticated Symmetric Encryption with Additional Data def crypto_aead_aes256gcm_encrypt(message, aad, nonce, key): """Encrypts and authenticates a message with public additional data using the given secret key, and nonce Args: message (bytes): a message to encrypt aad (bytes): additional public data to authenticate nonce (bytes): nonce, does not have to be confidential must be `crypto_aead_aes256gcm_NPUBBYTES` in length key (bytes): secret key, must be `crypto_aead_aes256gcm_KEYBYTES` in length Returns: bytes: the ciphertext Raises: ValueError: if arguments' length is wrong or the operation has failed. """ if not HAS_AEAD_AES256GCM: raise ValueError('Underlying Sodium library does not support AES256-GCM AEAD') if len(key) != crypto_aead_aes256gcm_KEYBYTES: raise ValueError('Invalid key') if len(nonce) != crypto_aead_aes256gcm_NPUBBYTES: raise ValueError('Invalid nonce') length = len(message) + crypto_aead_aes256gcm_ABYTES clen = ctypes.c_ulonglong() c = ctypes.create_string_buffer(length) ret = nacl.crypto_aead_aes256gcm_encrypt( c, ctypes.pointer(clen), message, ctypes.c_ulonglong(len(message)), aad, ctypes.c_ulonglong(len(aad)), None, nonce, key) if ret: raise ValueError('Failed to encrypt message') return c.raw def crypto_aead_chacha20poly1305_ietf_encrypt(message, aad, nonce, key): """Encrypts and authenticates a message with public additional data using the given secret key, and nonce Args: message (bytes): a message to encrypt aad (bytes): additional public data to authenticate nonce (bytes): nonce, does not have to be confidential must be `crypto_aead_chacha20poly1305_ietf_NPUBBYTES` in length key (bytes): secret key, must be `crypto_aead_chacha20poly1305_ietf_KEYBYTES` in length Returns: bytes: the ciphertext Raises: ValueError: if arguments' length is wrong or the operation has failed. """ if not HAS_AEAD_CHACHA20POLY1305_IETF: raise ValueError('Underlying Sodium library does not support IETF variant of ChaCha20Poly1305 AEAD') if len(key) != crypto_aead_chacha20poly1305_ietf_KEYBYTES: raise ValueError('Invalid key') if len(nonce) != crypto_aead_chacha20poly1305_ietf_NPUBBYTES: raise ValueError('Invalid nonce') length = len(message) + crypto_aead_chacha20poly1305_ietf_ABYTES clen = ctypes.c_ulonglong() c = ctypes.create_string_buffer(length) ret = nacl.crypto_aead_chacha20poly1305_ietf_encrypt( c, ctypes.pointer(clen), message, ctypes.c_ulonglong(len(message)), aad, ctypes.c_ulonglong(len(aad)), None, nonce, key) if ret: raise ValueError('Failed to encrypt message') return c.raw def crypto_aead_aes256gcm_decrypt(ctxt, aad, nonce, key): """ Decrypts a ciphertext ctxt given the key, nonce, and aad. If the aad or ciphertext were altered then the decryption will fail. """ if not HAS_AEAD_AES256GCM: raise ValueError('Underlying Sodium library does not support AES256-GCM AEAD') if len(key) != crypto_aead_aes256gcm_KEYBYTES: raise ValueError('Invalid key') if len(nonce) != crypto_aead_aes256gcm_NPUBBYTES: raise ValueError('Invalid nonce') length = len(ctxt)-crypto_aead_aes256gcm_ABYTES mlen = ctypes.c_ulonglong() m = ctypes.create_string_buffer(length) ret = nacl.crypto_aead_aes256gcm_decrypt( m, ctypes.byref(mlen), None, ctxt, ctypes.c_ulonglong(len(ctxt)), aad, ctypes.c_ulonglong(len(aad)), nonce, key) if ret: raise ValueError('Failed to decrypt message') return m.raw def crypto_aead_chacha20poly1305_ietf_decrypt(ctxt, aad, nonce, key): """ Decrypts a ciphertext ctxt given the key, nonce, and aad. If the aad or ciphertext were altered then the decryption will fail. """ if not HAS_AEAD_CHACHA20POLY1305_IETF: raise ValueError('Underlying Sodium library does not support IETF variant of ChaCha20Poly1305 AEAD') if len(key) != crypto_aead_chacha20poly1305_ietf_KEYBYTES: raise ValueError('Invalid key') if len(nonce) != crypto_aead_chacha20poly1305_ietf_NPUBBYTES: raise ValueError('Invalid nonce') length = len(ctxt)-crypto_aead_chacha20poly1305_ietf_ABYTES mlen = ctypes.c_ulonglong() m = ctypes.create_string_buffer(length) ret = nacl.crypto_aead_chacha20poly1305_ietf_decrypt( m, ctypes.byref(mlen), None, ctxt, ctypes.c_ulonglong(len(ctxt)), aad, ctypes.c_ulonglong(len(aad)), nonce, key) if ret: raise ValueError('Failed to decrypt message') return m.raw # Symmetric Encryption def crypto_stream(slen, nonce, key): ''' Generates a stream using the given secret key and nonce ''' stream = ctypes.create_string_buffer(slen) ret = nacl.crypto_stream(stream, ctypes.c_ulonglong(slen), nonce, key) if ret: raise ValueError('Failed to init stream') return stream.raw def crypto_stream_xor(msg, nonce, key): ''' Encrypts the given message using the given secret key and nonce The crypto_stream_xor function guarantees that the ciphertext is the plaintext (xor) the output of crypto_stream. Consequently crypto_stream_xor can also be used to decrypt ''' stream = ctypes.create_string_buffer(len(msg)) ret = nacl.crypto_stream_xor( stream, msg, ctypes.c_ulonglong(len(msg)), nonce, key) if ret: raise ValueError('Failed to init stream') return stream.raw # Authentication def crypto_auth(msg, key): ''' Constructs a one time authentication token for the given message msg using a given secret key ''' tok = ctypes.create_string_buffer(crypto_auth_BYTES) ret = nacl.crypto_auth(tok, msg, ctypes.c_ulonglong(len(msg)), key) if ret: raise ValueError('Failed to auth msg') return tok.raw[:crypto_auth_BYTES] def crypto_auth_verify(tok, msg, key): ''' Verifies that the given authentication token is correct for the given message and key ''' ret = nacl.crypto_auth_verify(tok, msg, ctypes.c_ulonglong(len(msg)), key) if ret: raise ValueError('Failed to auth msg') return msg # One time authentication def crypto_onetimeauth_primitive(): """ Return the onetimeauth underlying primitive Returns: str: always ``poly1305`` """ func = nacl.crypto_onetimeauth_primitive func.restype = ctypes.c_char_p return func().decode() def crypto_onetimeauth(message, key): """ Constructs a one time authentication token for the given message using a given secret key Args: message (bytes): message to authenticate. key (bytes): secret key - must be of crypto_onetimeauth_KEYBYTES length. Returns: bytes: an authenticator, of crypto_onetimeauth_BYTES length. Raises: ValueError: if arguments' length is wrong. """ if len(key) != crypto_onetimeauth_KEYBYTES: raise ValueError('Invalid secret key') tok = ctypes.create_string_buffer(crypto_onetimeauth_BYTES) # cannot fail _ = nacl.crypto_onetimeauth( tok, message, ctypes.c_ulonglong(len(message)), key) return tok.raw[:crypto_onetimeauth_BYTES] def crypto_onetimeauth_verify(token, message, key): """ Verifies, in constant time, that ``token`` is a correct authenticator for the message using the secret key. Args: token (bytes): an authenticator of crypto_onetimeauth_BYTES length. message (bytes): The message to authenticate. key: key (bytes): secret key - must be of crypto_onetimeauth_KEYBYTES length. Returns: bytes: secret key - must be of crypto_onetimeauth_KEYBYTES length. Raises: ValueError: if arguments' length is wrong or verification has failed. """ if len(key) != crypto_onetimeauth_KEYBYTES: raise ValueError('Invalid secret key') if len(token) != crypto_onetimeauth_BYTES: raise ValueError('Invalid authenticator') ret = nacl.crypto_onetimeauth_verify( token, message, ctypes.c_ulonglong(len(message)), key) if ret: raise ValueError('Failed to auth message') return message # Hashing def crypto_hash(msg): ''' Compute a hash of the given message ''' hbuf = ctypes.create_string_buffer(crypto_hash_BYTES) nacl.crypto_hash(hbuf, msg, ctypes.c_ulonglong(len(msg))) return hbuf.raw def crypto_hash_sha256(msg): ''' Compute the sha256 hash of the given message ''' hbuf = ctypes.create_string_buffer(crypto_hash_sha256_BYTES) nacl.crypto_hash_sha256(hbuf, msg, ctypes.c_ulonglong(len(msg))) return hbuf.raw def crypto_hash_sha512(msg): ''' Compute the sha512 hash of the given message ''' hbuf = ctypes.create_string_buffer(crypto_hash_sha512_BYTES) nacl.crypto_hash_sha512(hbuf, msg, ctypes.c_ulonglong(len(msg))) return hbuf.raw # Generic Hash def crypto_generichash(msg, key=None): ''' Compute the blake2 hash of the given message with a given key ''' hbuf = ctypes.create_string_buffer(crypto_generichash_BYTES) if key: key_len = len(key) else: key_len = 0 nacl.crypto_generichash( hbuf, ctypes.c_size_t(len(hbuf)), msg, ctypes.c_ulonglong(len(msg)), key, ctypes.c_size_t(key_len)) return hbuf.raw # scalarmult def crypto_scalarmult_base(n): ''' Computes and returns the scalar product of a standard group element and an integer "n". ''' buf = ctypes.create_string_buffer(crypto_scalarmult_BYTES) ret = nacl.crypto_scalarmult_base(buf, n) if ret: raise CryptError('Failed to compute scalar product') return buf.raw # String cmp def crypto_verify_16(string1, string2): ''' Compares the first crypto_verify_16_BYTES of the given strings The time taken by the function is independent of the contents of string1 and string2. In contrast, the standard C comparison function memcmp(string1,string2,16) takes time that is dependent on the longest matching prefix of string1 and string2. This often allows for easy timing attacks. ''' return not nacl.crypto_verify_16(string1, string2) def crypto_verify_32(string1, string2): ''' Compares the first crypto_verify_32_BYTES of the given strings The time taken by the function is independent of the contents of string1 and string2. In contrast, the standard C comparison function memcmp(string1,string2,32) takes time that is dependent on the longest matching prefix of string1 and string2. This often allows for easy timing attacks. ''' return not nacl.crypto_verify_32(string1, string2) def crypto_verify_64(string1, string2): ''' Compares the first crypto_verify_64_BYTES of the given strings The time taken by the function is independent of the contents of string1 and string2. In contrast, the standard C comparison function memcmp(string1,string2,64) takes time that is dependent on the longest matching prefix of string1 and string2. This often allows for easy timing attacks. ''' return not nacl.crypto_verify_64(string1, string2) def bytes_eq(a, b): ''' Compares two byte instances with one another. If `a` and `b` have different lengths, return `False` immediately. Otherwise `a` and `b` will be compared in constant time. Return `True` in case `a` and `b` are equal. Otherwise `False`. Raises :exc:`TypeError` in case `a` and `b` are not both of the type :class:`bytes`. ''' if not isinstance(a, bytes) or not isinstance(b, bytes): raise TypeError('Both arguments must be bytes.') len_a = len(a) len_b = len(b) if len_a != len_b: return False return nacl.sodium_memcmp(a, b, len_a) == 0 # Random byte generation def randombytes(size): ''' Return a string of random bytes of the given size ''' buf = ctypes.create_string_buffer(size) nacl.randombytes(buf, ctypes.c_ulonglong(size)) return buf.raw def randombytes_buf(size): ''' Return a string of random bytes of the given size ''' size = int(size) buf = ctypes.create_string_buffer(size) nacl.randombytes_buf(buf, size) return buf.raw def randombytes_close(): ''' Close the file descriptor or the handle for the cryptographic service provider ''' nacl.randombytes_close() def randombytes_random(): ''' Return a random 32-bit unsigned value ''' return nacl.randombytes_random() def randombytes_stir(): ''' Generate a new key for the pseudorandom number generator The file descriptor for the entropy source is kept open, so that the generator can be reseeded even in a chroot() jail. ''' nacl.randombytes_stir() def randombytes_uniform(upper_bound): ''' Return a value between 0 and upper_bound using a uniform distribution ''' return nacl.randombytes_uniform(upper_bound) # Utility functions def sodium_library_version_major(): ''' Return the major version number ''' return nacl.sodium_library_version_major() def sodium_library_version_minor(): ''' Return the minor version number ''' return nacl.sodium_library_version_minor() def sodium_version_string(): ''' Return the version string ''' func = nacl.sodium_version_string func.restype = ctypes.c_char_p return func() def crypto_box_seed_keypair(seed): ''' Computes and returns the public and secret keys from the given seed ''' if len(seed) != crypto_box_SEEDBYTES: raise ValueError('Invalid Seed') pk = ctypes.create_string_buffer(crypto_box_PUBLICKEYBYTES) sk = ctypes.create_string_buffer(crypto_box_SECRETKEYBYTES) ret = nacl.crypto_box_seed_keypair(pk, sk, seed) if ret: raise CryptError('Failed to generate keypair from seed') return (pk.raw, sk.raw) def crypto_sign_ed25519_pk_to_curve25519(ed25519_pk): ''' Convert an Ed25519 public key to a Curve25519 public key ''' if len(ed25519_pk) != crypto_sign_ed25519_PUBLICKEYBYTES: raise ValueError('Invalid Ed25519 Key') curve25519_pk = ctypes.create_string_buffer(crypto_scalarmult_curve25519_BYTES) ret = nacl.crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) if ret: raise CryptError('Failed to generate Curve25519 public key') return curve25519_pk.raw def crypto_sign_ed25519_sk_to_curve25519(ed25519_sk): ''' Convert an Ed25519 secret key to a Curve25519 secret key ''' if len(ed25519_sk) != crypto_sign_ed25519_SECRETKEYBYTES: raise ValueError('Invalid Ed25519 Key') curve25519_sk = ctypes.create_string_buffer(crypto_scalarmult_curve25519_BYTES) ret = nacl.crypto_sign_ed25519_sk_to_curve25519(curve25519_sk, ed25519_sk) if ret: raise CryptError('Failed to generate Curve25519 secret key') return curve25519_sk.raw libnacl-1.6.1/libnacl/encode.py0000644000175000001440000000164513133731616017002 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' Build in routines and classes to simplify encoding routines ''' # Import python libs import base64 import binascii def hex_encode(data): ''' Hex encode data ''' return binascii.hexlify(data) def hex_decode(data): ''' Hex decode data ''' return binascii.unhexlify(data) def base16_encode(data): ''' Base32 encode data ''' return base64.b16encode(data) def base16_decode(data): ''' Base16 decode data ''' return base64.b16decode(data) def base32_encode(data): ''' Base16 encode data ''' return base64.b32encode(data) def base32_decode(data): ''' Base32 decode data ''' return base64.b32decode(data) def base64_encode(data): ''' Base16 encode data ''' return base64.b64encode(data) def base64_decode(data): ''' Base32 decode data ''' return base64.b64decode(data) libnacl-1.6.1/libnacl/version.py0000644000175000001440000000002613173675315017231 0ustar thatchusers00000000000000__version__ = '1.6.1' libnacl-1.6.1/libnacl/sign.py0000644000175000001440000000275513133731616016510 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' High level routines to maintain signing keys and to sign and verify messages ''' # Import libancl libs import libnacl import libnacl.base import libnacl.encode class Signer(libnacl.base.BaseKey): ''' The tools needed to sign messages ''' def __init__(self, seed=None): ''' Create a signing key, if not seed it supplied a keypair is generated ''' if seed: if len(seed) != libnacl.crypto_sign_SEEDBYTES: raise ValueError('Invalid seed bytes') self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed) else: seed = libnacl.randombytes(libnacl.crypto_sign_SEEDBYTES) self.vk, self.sk = libnacl.crypto_sign_seed_keypair(seed) self.seed = seed def sign(self, msg): ''' Sign the given message with this key ''' return libnacl.crypto_sign(msg, self.sk) def signature(self, msg): ''' Return just the signature for the message ''' return libnacl.crypto_sign(msg, self.sk)[:libnacl.crypto_sign_BYTES] class Verifier(libnacl.base.BaseKey): ''' Verify signed messages ''' def __init__(self, vk_hex): ''' Create a verification key from a hex encoded vkey ''' self.vk = libnacl.encode.hex_decode(vk_hex) def verify(self, msg): ''' Verify the message with tis key ''' return libnacl.crypto_sign_open(msg, self.vk) libnacl-1.6.1/libnacl/base.py0000644000175000001440000000354013133731616016453 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- ''' Implement the base key object for other keys to inherit convenience functions ''' # Import libnacl libs import libnacl.encode # Import python libs import os import stat class BaseKey(object): ''' Include methods for key management convenience ''' def hex_sk(self): if hasattr(self, 'sk'): return libnacl.encode.hex_encode(self.sk) else: return '' def hex_pk(self): if hasattr(self, 'pk'): return libnacl.encode.hex_encode(self.pk) def hex_vk(self): if hasattr(self, 'vk'): return libnacl.encode.hex_encode(self.vk) def hex_seed(self): if hasattr(self, 'seed'): return libnacl.encode.hex_encode(self.seed) def for_json(self): ''' Return a dictionary of the secret values we need to store. ''' pre = {} sk = self.hex_sk() pk = self.hex_pk() vk = self.hex_vk() seed = self.hex_seed() if sk: pre['priv'] = sk.decode('utf-8') if pk: pre['pub'] = pk.decode('utf-8') if vk: pre['verify'] = vk.decode('utf-8') if seed: pre['sign'] = seed.decode('utf-8') return pre def save(self, path, serial='json'): ''' Safely save keys with perms of 0400 ''' pre = self.for_json() if serial == 'msgpack': import msgpack packaged = msgpack.dumps(pre) elif serial == 'json': import json packaged = json.dumps(pre) perm_other = stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH perm_group = stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP cumask = os.umask(perm_other | perm_group) with open(path, 'w+') as fp_: fp_.write(packaged) os.umask(cumask) libnacl-1.6.1/libnacl/utils.py0000644000175000001440000000552513133731616016706 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- import struct import time # Import nacl libs import libnacl import libnacl.encode import libnacl.secret import libnacl.public import libnacl.sign import libnacl.dual def load_key(path_or_file, serial='json'): ''' Read in a key from a file and return the applicable key object based on the contents of the file ''' if hasattr(path_or_file, 'read'): stream = path_or_file else: if serial == 'json': stream = open(path_or_file, 'r') else: stream = open(path_or_file, 'rb') try: if serial == 'msgpack': import msgpack key_data = msgpack.load(stream) elif serial == 'json': import json key_data = json.loads(stream.read(), encoding='UTF-8') finally: if stream != path_or_file: stream.close() if 'priv' in key_data and 'sign' in key_data and 'pub' in key_data: return libnacl.dual.DualSecret( libnacl.encode.hex_decode(key_data['priv']), libnacl.encode.hex_decode(key_data['sign'])) elif 'priv' in key_data and 'pub' in key_data: return libnacl.public.SecretKey( libnacl.encode.hex_decode(key_data['priv'])) elif 'sign' in key_data: return libnacl.sign.Signer( libnacl.encode.hex_decode(key_data['sign'])) elif 'pub' in key_data: return libnacl.public.PublicKey( libnacl.encode.hex_decode(key_data['pub'])) elif 'verify' in key_data: return libnacl.sign.Verifier(key_data['verify']) elif 'priv' in key_data: return libnacl.secret.SecretBox( libnacl.encode.hex_decode(key_data['priv'])) raise ValueError('Found no key data') def salsa_key(): ''' Generates a salsa2020 key ''' return libnacl.randombytes(libnacl.crypto_secretbox_KEYBYTES) def aead_key(): ''' Generates an AEAD key (both implementations use the same size) ''' return libnacl.randombytes(libnacl.crypto_aead_aes256gcm_KEYBYTES) def rand_aead_nonce(): ''' Generates and returns a random bytestring of the size defined in libsodium as crypto_aead_aes256gcm_NPUBBYTES and crypto_aead_chacha20poly1305_ietf_NPUBBYTES ''' return libnacl.randombytes(libnacl.crypto_aead_aes256gcm_NPUBBYTES) def rand_nonce(): ''' Generates and returns a random bytestring of the size defined in libsodium as crypto_box_NONCEBYTES ''' return libnacl.randombytes(libnacl.crypto_box_NONCEBYTES) def time_nonce(): ''' Generates and returns a nonce as in rand_nonce() but using a timestamp for the first 8 bytes. This function now exists mostly for backwards compatibility, as rand_nonce() is usually preferred. ''' nonce = rand_nonce() return (struct.pack('=d', time.time()) + nonce)[:len(nonce)] libnacl-1.6.1/libnacl/blake.py0000644000175000001440000000166613133731616016626 0ustar thatchusers00000000000000''' Mimic very closely the python hashlib classes for blake2b NOTE: This class does not yet implement streaming the msg into the hash function via the update method ''' # Import python libs import binascii # Import libnacl libs import libnacl class Blake2b(object): ''' Manage a Blake2b hash ''' def __init__(self, msg, key=None): self.msg = msg self.key = key self.raw_digest = libnacl.crypto_generichash(msg, key) self.digest_size = len(self.raw_digest) def digest(self): ''' Return the digest of the string ''' return self.raw_digest def hexdigest(self): ''' Return the hex digest of the string ''' return binascii.hexlify(self.raw_digest) def blake2b(msg, key=None): ''' Create and return a Blake2b object to mimic the behavior of the python hashlib functions ''' return Blake2b(msg, key) libnacl-1.6.1/setup.cfg0000644000175000001440000000010313200105202015351 0ustar thatchusers00000000000000[bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 libnacl-1.6.1/MANIFEST.in0000644000175000001440000000017513133731616015322 0ustar thatchusers00000000000000include LICENSE include AUTHORS include README.rst recursive-include tests * recursive-include doc * recursive-include pkg * libnacl-1.6.1/setup.py0000644000175000001440000000176713200105142015266 0ustar thatchusers00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- from setuptools import setup NAME = 'libnacl' DESC = 'Python bindings for libsodium based on ctypes' # Version info -- read without importing _locals = {} with open('libnacl/version.py') as fp: exec(fp.read(), None, _locals) VERSION = _locals['__version__'] setup(name=NAME, version=VERSION, description=DESC, author='Thomas S Hatch', author_email='thatch@saltstack.com', url='https://libnacl.readthedocs.org/', classifiers=[ 'Operating System :: OS Independent', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Topic :: Security :: Cryptography', ], packages=['libnacl']) libnacl-1.6.1/PKG-INFO0000644000175000001440000000135313200105202014635 0ustar thatchusers00000000000000Metadata-Version: 1.1 Name: libnacl Version: 1.6.1 Summary: Python bindings for libsodium based on ctypes Home-page: https://libnacl.readthedocs.org/ Author: Thomas S Hatch Author-email: thatch@saltstack.com License: UNKNOWN Description-Content-Type: UNKNOWN Description: UNKNOWN Platform: UNKNOWN Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.4 Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Topic :: Security :: Cryptography libnacl-1.6.1/doc/0000755000175000001440000000000013200105202014303 5ustar thatchusers00000000000000libnacl-1.6.1/doc/topics/0000755000175000001440000000000013200105202015604 5ustar thatchusers00000000000000libnacl-1.6.1/doc/topics/raw_public.rst0000644000175000001440000000470713133731616020520 0ustar thatchusers00000000000000========================= Raw Public Key Encryption ========================= .. note:: While these routines are perfectly safe, higher level convenience wrappers are under development to make these routines easier. Public key encryption inside the nacl library has been constructed to ensure that all cryptographic routines are executed correctly and safely. The public key encryption is executed via the functions which begin with `crypto_box` and can be easily executed. First generate a public key and secret key keypair for the two communicating parties, who for tradition's sake, will be referred to as Alice and Bob: .. code-block:: python import libnacl alice_pk, alice_sk = libnacl.crypto_keypair() bob_pk, bob_sk = libnacl.crypto_keypair() Once the keys have been generated a cryptographic box needs to be created. The cryptographic box takes the party's secret key and the receiving party's public key. These are used to create a message which is both signed and encrypted. Before creating the box a nonce is required. The nonce is a 24 character string which should only be used for this message, the nonce should never be reused. This means that the nonce needs to be generated in such a way that the probability of reusing the nonce string with the same keypair is very low. The libnacl wrapper ships with a convenience function which generates a nonce from random bytes: .. code-block:: python import libnacl.utils nonce = libnacl.utils.rand_nonce() Now, with a nonce a cryptographic box can be created, Alice will send a message: .. code-block:: python msg = 'Quiet, quiet. Quiet! There are ways of telling whether she is a witch.' box = libnacl.crypto_box(msg, nonce, bob_pk, alice_sk) Now with a box in hand it can be decrypted by Bob: .. code-block:: python clear_msg = libnacl.crypto_box_open(box, nonce, alice_pk, bob_sk) The trick here is that the box AND the nonce need to be sent to Bob, so he can decrypt the message. The nonce can be safely sent to Bob in the clear. To bring it all together: .. code-block:: python import libnacl import libnacl.utils alice_pk, alice_sk = libnacl.crypto_keypair() bob_pk, bob_sk = libnacl.crypto_keypair() nonce = libnacl.utils.rand_nonce() msg = 'Quiet, quiet. Quiet! There are ways of telling whether she is a witch.' box = libnacl.crypto_box(msg, nonce, bob_pk, alice_sk) clear_msg = libnacl.crypto_box_open(box, nonce, alice_pk, bob_sk) libnacl-1.6.1/doc/topics/releases/0000755000175000001440000000000013200105202017407 5ustar thatchusers00000000000000libnacl-1.6.1/doc/topics/releases/1.6.0.rst0000644000175000001440000000202313165440567020632 0ustar thatchusers00000000000000=========================== libnacl 1.6.0 Release Notes =========================== Add Bindings for More Libsodium Function ======================================== Add bindings for crypto_box_seed_keypair() and crypto_scalarmult_base() Add bindings for crypto_box_easy() and crypto_box_open_easy() Add bindings for crypto_box_easy_afternm() and crypto_box_open_easy_afternm() Add bindings for crypto_sign_ed25519_keypair(), crypto_sign_ed25519_sk_to_pk() and crypto_sign_ed25519_sk_to_seed() Add bindings for crypto_sign_detached() and crypto_sign_verify_detached() Add bindings for crypto_sign_ed25519_pk_to_curve25519() and crypto_sign_ed25519_sk_to_curve25519() Please Note The Exception Change From the 1.5.1 Release ======================================================= If encryption or decryption fails, `CryptError` is raised instead of `ValueError`. This might be a breaking change for your application. See `#91 `__ and `#74 `__. libnacl-1.6.1/doc/topics/releases/1.3.2.rst0000644000175000001440000000022713133731616020626 0ustar thatchusers00000000000000=========================== libnacl 1.3.2 Release Notes =========================== Add detection of the libsodium.so.10 lib created by libsodium 0.6 libnacl-1.6.1/doc/topics/releases/1.5.0.rst0000644000175000001440000000102613133731616020624 0ustar thatchusers00000000000000=========================== libnacl 1.5.0 Release Notes =========================== Add Built In libsodium.so Support ================================= Added the ability to place a `libsodium.so` file in the libnacl python directory as a last resort fallback. To use this feature just copy your `libsodium.so` file to the same directory as the libnacl `__init__.py` file. This was added to make total portability of the library easier. Add `bytes_eq` ============== Added the `bytes_eq` function to allow better byte comparison libnacl-1.6.1/doc/topics/releases/1.4.0.rst0000644000175000001440000000051313133731616020623 0ustar thatchusers00000000000000=========================== libnacl 1.4.0 Release Notes =========================== Blake Hash Support ================== Initial support has been added for the blake2b hash algorithm Misc Fixes ========== * Fix issue with keyfile saves on windows * Fix libsodium detection for Ubuntu manual installs and Windows dll detection libnacl-1.6.1/doc/topics/releases/1.0.0.rst0000644000175000001440000000064513133731616020625 0ustar thatchusers00000000000000=========================== libnacl 1.0.0 Release Notes =========================== This is the first stable release of libnacl, the python bindings for Daniel J. Bernstein's nacl library via libsodium. NaCl Base Functions =================== This release features direct access to the underlying functions from nacl exposed via importing libnacl. These functions are fully documented and can be safely used directly. libnacl-1.6.1/doc/topics/releases/1.5.2.rst0000644000175000001440000000065013134223050020615 0ustar thatchusers00000000000000=========================== libnacl 1.5.2 Release Notes =========================== Add Support for AEAD AES and chacha20poly1305 ============================================= Big thanks to Nicholas O'Brien for adding support for libsodium's AEAD encryption systems. The raw functions are all available to access libsodium directly along with the high level AEAD class that cleanly follows libnacl's key management model. libnacl-1.6.1/doc/topics/releases/1.6.1.rst0000644000175000001440000000034113173673627020640 0ustar thatchusers00000000000000=========================== libnacl 1.6.0 Release Notes =========================== Add support for libsodium 1.0.15 ================================ Make sure that libnacl runs correctly on the 1.0.15 release of libsodium libnacl-1.6.1/doc/topics/releases/1.4.5.rst0000644000175000001440000000050713133731616020633 0ustar thatchusers00000000000000=========================== libnacl 1.4.5 Release Notes =========================== Set low end libsodium version to 0.5 ==================================== * libnacl will only function with libsodium 0.5 and above Add soversion 18 detection ========================== * Added explicit soversion support for libsodium 18 libnacl-1.6.1/doc/topics/releases/1.4.3.rst0000644000175000001440000000077313133731616020636 0ustar thatchusers00000000000000=========================== libnacl 1.4.3 Release Notes =========================== crypto_onetimeauth_verify fixes =============================== * Fix a call to the crypto_onetimeauth_verify routine into the right libsodium system * Add tests for crypto_onetimeauth_verify Improved support for MacOSX =========================== * Improved the lookup procedure for finding libsodium on MacOSX Add support for reading file streams for key loading ==================================================== libnacl-1.6.1/doc/topics/releases/1.3.1.rst0000644000175000001440000000017413133731616020626 0ustar thatchusers00000000000000=========================== libnacl 1.3.1 Release Notes =========================== Bring back a safe time_nonce function. libnacl-1.6.1/doc/topics/releases/1.5.1.rst0000644000175000001440000000110013165436407020623 0ustar thatchusers00000000000000=========================== libnacl 1.5.1 Release Notes =========================== Add Sealed Box Support ====================== A big thanks to Manatsawin Hanmongkolchai for adding in support for libsodium `Sealed Boxes`! Change Exception on Encrypt/Decrypt Failure =========================================== If encryption or decryption fails, `CryptError` is raised instead of `ValueError`. This might be a breaking change for your application. See `#91 `__ and `#74 `__. libnacl-1.6.1/doc/topics/releases/1.4.1.rst0000644000175000001440000000030013133731616020616 0ustar thatchusers00000000000000=========================== libnacl 1.4.1 Release Notes =========================== Misc Fixes ========== * Fix for crypto_auth_verify and crypto_auth_onetimeverify * Lint fixes and updates libnacl-1.6.1/doc/topics/releases/1.4.2.rst0000644000175000001440000000027413133731616020631 0ustar thatchusers00000000000000=========================== libnacl 1.4.2 Release Notes =========================== SecretBox key save and load =========================== * Add support to save and load SecretBox keys libnacl-1.6.1/doc/topics/releases/1.2.0.rst0000644000175000001440000000150613133731616020624 0ustar thatchusers00000000000000=========================== libnacl 1.2.0 Release Notes =========================== This release introduces the DualKey class, secure key saving and loading, as well as enhancements to the time_nonce function. Dual Key Class ============== Dual Keys are classes which can encrypt and sign data. These classes generate and maintain both Curve25519 and Ed25519 keys, as well as all methods for both encryption and signing. Time Nonce Improvements ======================= The original time nonce routine used the first 20 chars of the 24 char nonce for the microsecond timestamp (based on salt's jid), leaving 4 chars for random data. This new nonce uses far fewer chars for the timestamp by hex encoding the float of microseconds into just 13 chars, leaving 11 chars of random data. This makes the default nonce safer and more secure. libnacl-1.6.1/doc/topics/releases/1.4.4.rst0000644000175000001440000000147013133731616020632 0ustar thatchusers00000000000000=========================== libnacl 1.4.4 Release Notes =========================== Add pack_nonce options to secretbox =================================== * libnacl secretbox has been packing the nonce in each message, the new pack_nonce option allows for the nonce to be omitted which allows for more flexible options Add soversion 17 detection ========================== * Added explicit soversion support for libsodium 17 Fix crypto_onetimeauth tests ============================ * The crypto onetimeauth test issues have been resolved Remove tweetnacl Support ======================== * The tweetnacl support was never really tested, and since the tweetnacl api is not complete we have removed support for it Add sodium_init calls ===================== * Added calls to sodium_init when the lib is loaded libnacl-1.6.1/doc/topics/releases/1.1.0.rst0000644000175000001440000000114713133731616020624 0ustar thatchusers00000000000000=========================== libnacl 1.1.0 Release Notes =========================== This release introduces the addition of high level classes that make using NaCl even easier. High level NaCl =============== The addition of the high level classes give a more pythonic abstraction to using the underlying NaCl cryptography. These classes can be found in libnacl.public, libnacl.sign and libnacl.secret. Easy Nonce Generation ===================== The new classes will automatically generate a nonce value per encrypted message. The default nonce which is generated can be found in `libnacl.utils.time_nonce`. libnacl-1.6.1/doc/topics/releases/1.3.4.rst0000644000175000001440000000040313133731616020624 0ustar thatchusers00000000000000=========================== libnacl 1.3.4 Release Notes =========================== * Change the default ctype values to be more accurate and efficient * Update soname detection on Linux for libsodium 0.7.0 * Make soname detection a little more future proof libnacl-1.6.1/doc/topics/releases/1.3.3.rst0000644000175000001440000000027713133731616020634 0ustar thatchusers00000000000000=========================== libnacl 1.3.3 Release Notes =========================== Fix issue and add tests for bug where saving and loading a signing key caused a stack trace, se issue #18 libnacl-1.6.1/doc/topics/releases/index.rst0000644000175000001440000000014013133731616021266 0ustar thatchusers00000000000000============= Release notes ============= .. toctree:: :maxdepth: 1 :glob: [0-9]* libnacl-1.6.1/doc/topics/releases/1.3.0.rst0000644000175000001440000000026013133731616020621 0ustar thatchusers00000000000000=========================== libnacl 1.3.0 Release Notes =========================== This release removes the time_nonce function and replaces it with the rand_nonce function. libnacl-1.6.1/doc/topics/utils.rst0000644000175000001440000000303213133731616017517 0ustar thatchusers00000000000000================= Utility Functions ================= The libnacl system comes with a number of utility functions, these functions are made available to make some of the aspects of encryption and key management easier. These range from nonce generation to loading saved keys. Loading Saved Keys ================== After keys are saved using the key save method reloading the keys is easy. The `libnacl.utils.load_key` function will detect what type of key object saved said key and then create the object from the key and return it. .. code-block:: python import libnacl.utils key_obj = libnacl.utils.load_key('/etc/keys/bob.key') The load_key and save routines also support inline key serialization. The default is json but msgpack is also supported. Salsa Key ========= A simple function that will return a random byte string suitable for use in SecretKey encryption. .. code-block:: python import libnacl.utils key = libnacl.utils.salsa_key() This routine is only required with the raw encryption functions, as the `libnacl.secret.SecretBox` will generate the key automatically. Nonce Routines ============== A few functions are available to help with creating nonce values, these routines are available because there is some debate about what the best approach is. We recommend a pure random string for the nonce which is returned from `rand_nonce`, but some have expressed a desire to create nonces which are designed to avoid re-use by more than simply random data and therefore the `time_nonce` function is also available. libnacl-1.6.1/doc/topics/raw_hash.rst0000644000175000001440000000115513133731616020157 0ustar thatchusers00000000000000================== Raw Hash Functions ================== The nacl library comes with sha256 and sha512 hashing libraries. They do not seem to offer any benefit over python's hashlib, but for completeness they are included. Creating a hash of a message is very simple: .. code-block:: python import libnacl msg = 'Is there someone else up there we could talk to?' h_msg = libnacl.crypto_hash(msg) crypto_hash defaults to sha256, sha512 is also available: .. code-block:: python import libnacl msg = 'Is there someone else up there we could talk to?' h_msg = libnacl.crypto_hash_sha512(msg) libnacl-1.6.1/doc/topics/dual.rst0000644000175000001440000000540613165436407017320 0ustar thatchusers00000000000000=================== Dual Key Management =================== The libnacl library abstracts a "Dual Key" model. The Dual Key creates a single key management object that can be used for both signing and encrypting, it generates and maintains a Curve25519 encryption key pair and an ED25519 signing keypair. All methods for encryption and signing work with and from Dual Keys. To encrypt messages using Dual Keys: .. code-block:: python import libnacl.dual # Define a message to send msg = b"You've got two empty halves of coconut and you're bangin' 'em together." # Generate the key pairs for Alice and bob, if secret keys already exist # they can be passed in, otherwise new keys will be automatically generated bob = libnacl.dual.DualSecret() alice = libnacl.dual.DualSecret() # Create the boxes, this is an object which represents the combination of the # sender's secret key and the receiver's public key bob_box = libnacl.public.Box(bob.sk, alice.pk) alice_box = libnacl.public.Box(alice.sk, bob.pk) # Bob's box encrypts messages for Alice bob_ctxt = bob_box.encrypt(msg) # Alice's box decrypts messages from Bob bclear = alice_box.decrypt(bob_ctxt) # Alice can send encrypted messages which only Bob can decrypt alice_ctxt = alice_box.encrypt(msg) aclear = alice_box.decrypt(alice_ctxt) .. note:: Every encryption routine requires a nonce. The nonce is a 24 char string that must never be used twice with the same keypair. If no nonce is passed in then a nonce is generated based on random data. If it is desired to generate a nonce manually this can be done by passing it into the encrypt method. DualKey Object ============== The DualKey object is used to manage both public and secret keys, this object contains a number of methods for both convenience and utility. The key data is also available. Keys ---- The raw public key is available as DualKey.pk, to generate a hex encoded version of the key the pk_hex method is available: .. code-block:: python import libnacl.dual fred = libnacl.dual.DualSecret() raw_sk = fred.sk hex_sk = fred.hex_sk() raw_pk = fred.pk hex_pk = fred.hex_pk() By saving only the binary keys in memory libnacl ensures that the minimal memory footprint is needed. Saving Keys to Disk =================== All libnacl key objects can be safely saved to disk via the save method. This method changes the umask before saving the key file to ensure that the saved file can only be read by the user creating it and cannot be written to. When using dual keys the encrypting and signing keys will be saved togather in a single file. .. code-block:: python import libnacl.dual fred = libnacl.dual.DualSecret() fred.save('/etc/nacl/fred.key') libnacl-1.6.1/doc/topics/raw_generichash.rst0000644000175000001440000000144613133731616021517 0ustar thatchusers00000000000000==================================== Raw Generic Hash (Blake2b) Functions ==================================== The nacl library comes with blake hashing libraries. More information on Blake can be found here: https://blake2.net The blake2b hashing algorithm is a keyed hashing algorithm, which allows for a key to be associated with a hash. Blake can be executed with or without a key. With a key (they key can should be between 16 and 64 bytes): .. code-block:: python import libnacl msg = 'Is there someone else up there we could talk to?' key = libnacl.randombytes(32) h_msg = libnacl.crypto_generichash(msg, key) Without a key: .. code-block:: python import libnacl msg = 'Is there someone else up there we could talk to?' h_msg = libnacl.crypto_generichash(msg) libnacl-1.6.1/doc/topics/public.rst0000644000175000001440000000576313133731616017652 0ustar thatchusers00000000000000===================== Public Key Encryption ===================== Unlike traditional means for public key asymmetric encryption, the nacl encryption systems are very high speed. The CurveCP network protocol for instance only uses public key encryption for all transport. Public key encryption is very simple, as is evidenced with this communication between Alice and Bob: .. code-block:: python import libnacl.public # Define a message to send msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' # Generate the key pairs for Alice and bob, if secret keys already exist # they can be passed in, otherwise new keys will be automatically generated bob = libnacl.public.SecretKey() alice = libnacl.public.SecretKey() # Create the boxes, this is an object which represents the combination of the # sender's secret key and the receiver's public key bob_box = libnacl.public.Box(bob.sk, alice.pk) alice_box = libnacl.public.Box(alice.sk, bob.pk) # Bob's box encrypts messages for Alice bob_ctxt = bob_box.encrypt(msg) # Alice's box decrypts messages from Bob bclear = alice_box.decrypt(bob_ctxt) # Alice can send encrypted messages which only Bob can decrypt alice_ctxt = alice_box.encrypt(msg) aclear = bob_box.decrypt(alice_ctxt) .. note:: Every encryption routine requires a nonce. The nonce is a 24 char string that must never be used twice with the same keypair. If no nonce is passed in then a nonce is generated based on random data. If it is desired to generate a nonce manually this can be done by passing it into the encrypt method. .. _secretkey-object: SecretKey Object ================ The SecretKey object is used to manage both public and secret keys, this object contains a number of methods for both convenience and utility. The key data is also available. Keys ---- The raw public key is available as SecretKey.sk, to generate a hex encoded version of the key the sk_hex method is available. The same items are available for the public keys: .. code-block:: python import libnacl.public fred = libnacl.public.SecretKey() raw_sk = fred.sk hex_sk = fred.hex_sk() raw_pk = fred.pk hex_pk = fred.hex_pk() By saving only the binary keys in memory libnacl ensures that the minimal memory footprint is needed. .. _publickey-object: PublicKey Object ================ To manage only the public key end, a public key object exists: .. code-block:: python import libnacl.public tom = libnacl.public.PublicKey(tom_public_key_hex) raw_pk = tom.pk hex_pk = tom.hex_pk() Saving Keys to Disk =================== All libnacl key objects can be safely saved to disk via the save method. This method changes the umask before saving the key file to ensure that the saved file can only be read by the user creating it and cannot be written to. .. code-block:: python import libnacl.public fred = libnacl.public.SecretKey() fred.save('/etc/nacl/fred.key') libnacl-1.6.1/doc/topics/raw_secret.rst0000644000175000001440000000350413133731616020521 0ustar thatchusers00000000000000========================= Raw Secret Key Encryption ========================= .. note:: While these routines are perfectly safe, higher level convenience wrappers are under development to make these routines easier. Secret key encryption is high speed encryption based on a shared secret key. .. note:: The nacl library uses the salsa20 stream encryption cipher for secret key encryption, more information about the salsa20 cipher can be found here: http://cr.yp.to/salsa20.html The means of encryption assumes that the two sides of the conversation both have access to the same shared secret key. First generate a secret key, libnacl provides a convenience function for the generation of this key called libnacl.utils.salsa_key, then generate a nonce, a new nonce should be used every time a new message is encrypted. A convenience function to create a unique nonce based on random bytes: .. code-block:: python import libnacl import libnacl.utils key = libnacl.utils.salsa_key() nonce = libnacl.utils.rand_nonce() With the key and nonce in hand, the cryptographic secret box can now be generated: .. code-block:: python msg = 'Who are you who are so wise in the ways of science?' box = libnacl.crypto_secretbox(msg, nonce, key) Now the message can be decrypted on the other end. The nonce and the key are both required to decrypt: .. code-block:: python clear_msg = libnacl.crypto_secretbox_open(box, nonce, key) When placed all together the sequence looks like this: .. code-block:: python import libnacl import libnacl.utils key = libnacl.utils.salsa_key() nonce = libnacl.utils.rand_nonce() msg = 'Who are you who are so wise in the ways of science?' box = libnacl.crypto_secretbox(msg, nonce, key) clear_msg = libnacl.crypto_secretbox_open(box, nonce, key) libnacl-1.6.1/doc/topics/sign.rst0000644000175000001440000000277213133731616017331 0ustar thatchusers00000000000000============================== Signing and Verifying Messages ============================== The nacl libs have the capability to sign and verify messages. Please be advised that public key encrypted messages do not need to be signed, the nacl box construct verifies the validity of the sender. To sign and verify messages use the Signer and Verifier classes: .. code-block:: python import libnacl.sign msg = (b'Well, that\'s no ordinary rabbit. That\'s the most foul, ' b'cruel, and bad-tempered rodent you ever set eyes on.') # Create a Signer Object, if the key seed value is not passed in the # signing keys will be automatically generated signer = libnacl.sign.Signer() # Sign the message, the signed string is the message itself plus the # signature signed = signer.sign(msg) # If only the signature is desired without the message: signature = signer.signature(msg) # To create a verifier pass in the verify key: veri = libnacl.sign.Verifier(signer.hex_vk()) # Verify the message! verified = veri.verify(signed) verified2 = veri.verify(signature + msg) Saving Keys to Disk =================== All libnacl key objects can be safely saved to disk via the save method. This method changes the umask before saving the key file to ensure that the saved file can only be read by the user creating it and cannot be written to. .. code-block:: python import libnacl.sign signer = libnacl.sign.Signer() signer.save('/etc/nacl/signer.key') libnacl-1.6.1/doc/topics/sealed.rst0000644000175000001440000000207013133731616017615 0ustar thatchusers00000000000000===================== Sealed Box ===================== Sealed box is a variant of :doc:`public key encryption scheme ` which only the receiver's public key is required. As such, the sender of the message cannot be cryptographically authenticated. .. code-block:: python import libnacl.sealed import libnacl.public # Define a message to send msg = b'You\'ve got two empty halves of coconut and you\'re bangin\' \'em together.' # Generate the key pair keypair = libnacl.public.SecretKey() # Create the box box = libnacl.sealed.SealedBox(keypair) # Encrypt messages ctxt = box.encrypt(msg) # Decrypt messages bclear = box.decrypt(ctxt) Creating Box ====================== SealedBox instances can be created by supplying a public and private key. The private key is only required when decrypting. The public key can be supplied as: * Instance of :ref:`SecretKey `, which supply both the public and private key. * Instance of :ref:`PublicKey ` * Raw binary representation libnacl-1.6.1/doc/topics/raw_sealed.rst0000644000175000001440000000216013133731616020466 0ustar thatchusers00000000000000========================= Raw Sealed Box Encryption ========================= Sealed box is a variant of :doc:`public key encryption scheme ` where the sender is not authenticated. This is done by generating an ephemeral key pair, which the public key is prefixed to the cipher text. First, generate a keypair for the receiver. The sender doesn't need a keypair. .. code-block:: python import libnacl pk, sk = libnacl.crypto_keypair() Then a sealed box is created by the sender, using the receiver's public key .. code-block:: python msg = 'Quiet, quiet. Quiet! There are ways of telling whether she is a witch.' box = libnacl.crypto_box_seal(msg, pk) The receiver then can decrypt the box using their keypair. .. code-block:: python clear_msg = libnacl.crypto_box_seal_open(box, pk, sk) To bring it all together: .. code-block:: python import libnacl pk, sk = libnacl.crypto_keypair() msg = 'Quiet, quiet. Quiet! There are ways of telling whether she is a witch.' box = libnacl.crypto_box_seal(msg, pk) clear_msg = libnacl.crypto_box_seal_open(box, pk, sk) libnacl-1.6.1/doc/topics/secret.rst0000644000175000001440000000243413133731616017651 0ustar thatchusers00000000000000===================== Secret Key Encryption ===================== Secret key encryption is the method of using a single key for both encryption and decryption of messages. One of the classic examples from history of secret key, or symmetric, encryption is the Enigma machine. The SecretBox class in libnacl.secret makes this type of encryption very easy to execute: .. code-block:: python msg = b'But then of course African swallows are not migratory.' # Create a SecretBox object, if not passed in the secret key is # Generated purely from random data box = libnacl.secret.SecretBox() # Messages can now be safely encrypted ctxt = box.encrypt(msg) # An additional box can be created from the original box secret key box2 = libnacl.secret.SecretBox(box.sk) # Messages can now be easily encrypted and decrypted clear1 = box.decrypt(ctxt) clear2 = box2.decrypt(ctxt) ctxt2 = box2.encrypt(msg) clear3 = box.decrypt(ctxt2) .. note:: Every encryption routine requires a nonce. The nonce is a 24 char string that must never be used twice with the same keypair. If no nonce is passed in then a nonce is generated based on random data. If it is desired to generate a nonce manually this can be done by passing it into the encrypt method. libnacl-1.6.1/doc/topics/raw_sign.rst0000644000175000001440000000344113133731616020174 0ustar thatchusers00000000000000====================== Raw Message Signatures ====================== .. note:: While these routines are perfectly safe, higher level convenience wrappers are under development to make these routines easier. Signing messages ensures that the message itself has not been tampered with. The application of a signature to a message is something that is is automatically applied when using the public key encryption and is not a required step when sending encrypted messages. This document however is intended to illustrate how to sign plain text messages. The nacl libs use a separate keypair for signing then is used for public key encryption, it is a high performance key signing algorithm called ed25519, more information on ed25519 can be found here: http://ed25519.cr.yp.to/ The sign messages first generate a signing keypair, this constitutes the signing key which needs to be kept secret, and the verify key which is made available to message recipients. .. code-block:: python import libnacl vk, sk = libnacl.crypto_sign_keypair() With the signing keypair in hand a message can be signed: .. code-block:: python msg = 'And that, my liege, is how we know the Earth to be banana-shaped.' signed = libnacl.crypto_sign(msg, sk) The signed message is really just the plain text of the message prepended with the signature. The crypto_sign_open function will read the signed message and return me original message without the signature: .. code-block:: python orig = libnacl.crypto_sign_open(signed, vk) Put all together: .. code-block:: python import libnacl vk, sk = libnacl.crypto_sign_keypair() msg = 'And that, my liege, is how we know the Earth to be banana-shaped.' signed = libnacl.crypto_sign(msg, sk) orig = libnacl.crypto_sign_open(signed, vk) libnacl-1.6.1/doc/Makefile0000644000175000001440000001517613133731616016000 0ustar thatchusers00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Python-NaCl.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Python-NaCl.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/Python-NaCl" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Python-NaCl" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." libnacl-1.6.1/doc/index.rst0000644000175000001440000000070213133731616016166 0ustar thatchusers00000000000000libnacl: Python bindings to NaCl ================================ Contents: .. toctree:: :maxdepth: 2 topics/public topics/sealed topics/secret topics/sign topics/dual topics/utils topics/raw_public topics/raw_sealed topics/raw_secret topics/raw_sign topics/raw_hash topics/raw_generichash topics/releases/index Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` libnacl-1.6.1/doc/conf.py0000644000175000001440000002406313133731616015632 0ustar thatchusers00000000000000# -*- coding: utf-8 -*- # # libnacl documentation build configuration file, created by # sphinx-quickstart on Thu May 29 10:29:25 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os sys.path.insert(0, os.path.abspath('..')) from libnacl import __version__ as version # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'libnacl' copyright = u'2017, Thomas S Hatch' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. # The full version, including alpha/beta/rc tags. release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. #html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". #html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. #htmlhelp_basename = 'libnacl' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'libnacl.tex', u'libnacl Documentation', u'Thomas S Hatch', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'libnacl', u'libnacl Documentation', [u'Thomas S Hatch'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'libnacl', u'libnacl Documentation', u'Thomas S Hatch', 'libnacl', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. epub_title = u'libnacl' epub_author = u'Thomas S Hatch' epub_publisher = u'Thomas S Hatch' epub_copyright = u'2017, Thomas S Hatch' # The basename for the epub file. It defaults to the project name. #epub_basename = u'libnacl' # The HTML theme for the epub output. Since the default themes are not optimized # for small screen space, using the same theme for HTML and epub output is # usually not wise. This defaults to 'epub', a theme designed to save visual # space. #epub_theme = 'epub' # The language of the text. It defaults to the language option # or en if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. #epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. #epub_identifier = '' # A unique identification for the text. #epub_uid = '' # A tuple containing the cover image and cover page html template filenames. #epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. #epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_post_files = [] # A list of files that should not be packed into the epub file. #epub_exclude_files = [] # The depth of the table of contents in toc.ncx. #epub_tocdepth = 3 # Allow duplicate toc entries. #epub_tocdup = True # Choose between 'default' and 'includehidden'. #epub_tocscope = 'default' # Fix unsupported image types using the PIL. #epub_fix_images = False # Scale large images. #epub_max_image_width = 0 # How to display URL addresses: 'footnote', 'no', or 'inline'. #epub_show_urls = 'inline' # If false, no index is generated. #epub_use_index = True libnacl-1.6.1/LICENSE0000644000175000001440000002606113133731616014573 0ustar thatchusers00000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {2014} Thomas S Hatch Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.