A Python wrapper that encapsulates wolfSSL's wolfCrypt API.
 
 
 
Go to file
Hayden Roche 352219fc87 Make several improvements to the CFFI build process.
- Move _build_ffi.py to scripts/build_ffi.py. Do as little in the global
namespace of the script as possible by putting functionality into functions,
including a new main function.
- Improve feature detection by allowing user_settings.h in addition to
options.h. This is particularly useful on Windows.
- Add the windows directory. This contains subdirectories non_fips and
fips_ready, which each have a user_settings.h. The non_fips user_settings.h is
used by the build script to build on Windows with CMake, when not using
USE_LOCAL_WOLFSSL. The fips_ready user_settings.h is an example user_settings.h
that works with our FIPS Ready code and wolfcrypt-py.
- Improve Windows support. This commit modifies the way we build wolfSSL for
wolfcrypt-py on Windows. Instead of using CMake directly, we use it with
user_settings.h. This is typically how Windows users are building wolfSSL, and
it gets around some shortcoming of wolfSSL's CMake support (e.g. not all
required features are supported). Additionally, USE_LOCAL_WOLFSSL now works
properly on Windows. When using USE_LOCAL_WOLFSSL, it should point to a wolfSSL
source code directory. This works for FIPS bundles, too. Finally, for FIPS on
Windows, we only support DLL builds. The CFFI library (.pyd extension) requires
this DLL to work. build_ffi.py detects this scenario and copies the .dll into
the wolfcrypt package directory. I've modified setup.py to distribute the
.dll with the package.
- Add some missing FIPS gates. Testing against FIPS v2 triggered some errors.
Those are fixed in this commit.
2022-11-03 14:56:04 +01:00
.github/workflows Create python-app.yml 2022-07-13 16:10:06 +02:00
docs Completely refactor AES GCM 2022-03-07 23:24:23 -08:00
lib Bump to version 5.4.0 2022-07-13 16:21:32 +02:00
requirements updates copyright and fixes docs 2018-01-08 16:04:27 -03:00
scripts Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
tests Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
windows Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
wolfcrypt Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
.buildinfo updates docs to v0.1.9 2017-01-20 16:49:18 -02:00
.coveragerc adds test coverage support 2018-02-26 22:13:25 +01:00
.gitignore Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
.gitmodules Refactor build for better platform support 2022-01-31 00:51:45 -08:00
ChangeLog.rst Add ChangeLog file 2022-07-25 16:38:34 +01:00
LICENSING.rst fixes license file and adds specific build option to linux 2017-12-12 11:40:24 -03:00
MANIFEST.in Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
Makefile Refactor build for better platform support 2022-01-31 00:51:45 -08:00
README.rst Remove Travis CI 2022-07-13 16:10:06 +02:00
setup.py Make several improvements to the CFFI build process. 2022-11-03 14:56:04 +01:00
tox.ini Fix issues causing tox not to run 2022-02-18 00:01:31 -08:00

README.rst

wolfcrypt: the wolfSSL Crypto Engine
====================================

**wolfCrypt Python**, a.k.a. ``wolfcrypt`` is a Python module that encapsulates
**wolfSSL's wolfCrypt API**.

`wolfCrypt <https://wolfssl.com/wolfSSL/Products-wolfcrypt.html>`_ is a
lightweight, portable, C-language-based crypto library
targeted at IoT, embedded, and RTOS environments primarily because of its size,
speed, and feature set. It works seamlessly in desktop, enterprise, and cloud
environments as well. It is the crypto engine behind `wolfSSL's embedded ssl
library <https://wolfssl.com/wolfSSL/Products-wolfssl.html>`_.

Compiling
---------

Windows
^^^^^^^

Install the following on Windows:

* `CMake <https://cmake.org/download/>`_
* `Git <https://git-scm.com/download/win>`_
* `Python 3.9 <https://www.python.org/downloads/windows/>`_
* `Build Tools for Visual Studio <https://visualstudio.microsoft.com/downloads/>`_. This is in the "Tools for Visual Studio" section at the bottom of the page. The "Desktop development with C++" pack is needed from the installer.

Then from the command line install tox and CFFI using:

.. code-block:: sh

   pip install tox cffi

You can then build the source distribution packages using:

.. code-block:: sh

   python setup.py sdist


Linux
^^^^^

The `setup.py` file covers most things you will need to do to build and install from source. As pre-requisites you will need to install either from your OS repository or pip. You'll also need the Python development package for your Python version:

* `cffi`
* `tox`
* `pytest`

To build a source package run `python setup.py sdist`, to build a wheel package run `python setup.py bdist_wheel`. To test the build run `tox`. The `tox` tests rely on Python 3.9 being installed, if you do not have this version we recommend using `pyenv` to install it.

Installation
------------

We provide Python wheels (prebuilt binaries) for OSX 64 bits and Linux 64 bits:

.. code-block:: bash

    $ pip install wolfcrypt

To build wolfcrypt-py against a local installation of the native C wolfSSL
library, use the USE_LOCAL_WOLFSSL variable.  This variable should be

wolfcrypt-py can be built against a local version of the native wolfSSL
library by using pip with the USE_LOCAL_WOLFSSL variable. USE_LOCAL_WOLFSSL
should be set equal to the installation path for the wolfSSL library:

.. code-block:: bash

    $ USE_LOCAL_WOLFSSL=/path/to/wolfssl/install pip install .

If building wolfcrypt-py against a local wolfSSL library, wolfcrypt-py
will attempt to do native feature detection to enable/disable wolfcrypt-py
features based on how native wolfSSL has been compiled.  It uses the
<wolfssl/options.h> header to do feature detection.

Testing
-------

.. code-block:: python

    >>> from wolfcrypt.hashes import Sha256
    >>> Sha256('wolfcrypt').hexdigest()
    b'96e02e7b1cbcd6f104fe1fdb4652027a5505b68652b70095c6318f9dce0d1844'

Testing ``wolfcrypt``'s source code with ``tox``
------------------------------------------------

To run the unit tests in the source code, you'll need ``tox`` and a few other
requirements.

1. Make sure that the testing requirements are installed:

.. code-block:: console

    $ sudo -H pip install -r requirements/test.txt


2. Run ``tox``:

.. code-block:: console

    $ tox
    ...
    _________________________________ summary _________________________________
    py3: commands succeeded
    congratulations :)