This repo holds a cleaned-up, de-obfuscated fork of tweetnacl-20140427. The new library is cleanly formatted, and passes some very strict code-quality checks.
It's also verified to be compatible with libsodium's implementation of the NaCl API.
Libsaline is forked from tweetnacl-20140427. There are a number of changes and improvements. The changes of interest are:
-
Cleaned up tweetnacl's macro-soup. Header and functions are clearly defined now.
-
Replace #defined constants with enums.
-
Used clang-format and astyle to reformat original source files for clearer reading.
-
Fix all compiler warnings/undefined-behavior. There were a fair amount of these.
-
Size all internal types where appropriate. Keep external function signatures compatible with libsodium.
-
Added a configurable implementation of randombytes(), which is needed by saline.
-
Added a thorough testbench that verifies libsodium compatibility.
-
Autotoolized the library for easy integration with common build-systems.
-
Relicense the library with an ISC license.
Libsodium is a great library, written and maintained by sharp people. If your project can use libsodium, that'll almost certainly be the right choice for you.
Libsodium isn't the right fit for all software projects though. It's hard to embed in a custom codebase, and it's not well very suited for bare-metal applications.
Libsaline is minimalistic and very portable, and is suitable for use in places where libsodium doesn't fit well for whatever reason. Libsaline's performance is performance is much lower than libsodium, but it's also a much smaller codebase with a focus on portability.
Libsaline doesn't provide all of the functions available with libsodium, but it does fully implement the original NaCl API. A comprehensive test suite verifies that libsaline's provided functions are all libsodium-compatible. So if your project can compile against libsaline, then it can also compile against libsodium without changing anything other than the include files.
This library is presented as a standard GNU Autotools project. All of the usual suspects will work fine.
-
(If running from a Git clone) Run
./autogen.sh
to build the configure script and its inputs. Not necessary if running from amake dist
-generated source tarball, which will already include aconfigure
script. -
Run
./configure
to configure the build, or run it from a custom build directory. Add--enable-sodium=no
to disable libsodium compatibility testing. Set--with-rand=stdlib
for bare-metal use. -
Build using
make
and install usingmake install
. Set aDESTDIR
duringmake install
if needed.
Alternatively, you can just grab the files you need and pull them into your design.
At the current time, this work is believed complete. All warnings have been fixed, and the code has been de-obfusticated where possible. A full test-suite is included which compares against libsodium for a reference. The design is fully autotoolized and looks like it works well.
Libsaline's original release was under a public-domain license, released by Daniel Bernstein. This release is relicensed with an ISC license for easy collaboration, and to reflect the work done improving public-domain tweetnacl's code quality into something reasonable.