Pure Lua implementation of NaCl: Networking and Cryptography library.
WARNING! Work in progress. The produced output may be not correct at all!
Mostly, this is a translation of reference implementations from C to Lua. All work is placed into public domain.
To browse files or download ZIP archive, login as anonymous. If you have Fossil installed:
fossil clone https://www.codingrobots.org/p/lua-nacl destination
Requirements
Lua 5.1:
LuaJIT 2.x:
- no external dependencies
Works best with LuaJIT 2.x (currently ~23x faster than Lua 5.1).
Implementation Details
Cryptographic Primitives:
- XSalsa20 / HSalsa20 / Salsa20
- Poly1305
- (TODO: Curve25519)
- (MAYBE: signatures)
API:
Format: C API name (Lua NaCl API name)
- crypto_secret_box (crypto.secretbox.create, crypto.secretbox.open)
- crypto_stream (crypto.stream)
- crypto_stream_xor (crypto.stream_xor)
- crypto_onetimeauth (crypto.onetimeauth)
- crypto_onetimeauth_verify (crypto.onetimeauth_verify)
- crypto_verify (crypto.verify)
Internally, all functions work with tables of numbers (bytes). crypto.bytetable is provided for conversion from/to strings. Note that crypto.secretbox APIs require zero-prefixing, just like in C NaCl API. This will be described later in documentation, and easier API which works directly with strings may be provided later.