lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,

I am happy to announce some additions to my Pure Lua Crypto project (PLC) [1]

[1] https://github.com/philanc/plc

PLC is a collection of cryptographic algorithms written in pure,
vanilla  Lua 5.3 (with default 64-bit integers). They have no external
Lua or C dependency. There is no complex tree of modules requiring
other modules. Every file should be usable standalone, with no strings
attached (except where noted).

I tried to pay some attention to the hash or encryption performance
(although this is pure Lua - we are far from C or ASM speed!) - See
some figures below.

Since my initial announcement,  the following algorithms were added:

- Norx, a very fast authenticated encryption algorithm with associated
data (AEAD). NORX is a 3rd-round candidate to CAESAR. This Lua code
implements the default NORX 64-4-1 variant (state is 16 64-bit words,
four rounds, no parallel execution, key and nonce are 256 bits)

- Blake2b - Blake was a final round candidate in the NIST SHA-3
selection process. Blake2b is an improved version of Blake. See
https://blake2.net/. It has been specified in RFC 7693. Much faster
than SHA-3.

-  Rabbit, a fast stream cipher, selected in the eSTREAM portfolio
along with Salsa20, and defined in RFC 4503 (128-bit key, 64-bit IV)

- XTea, a block cipher designed by Roger Needham and David Wheeler as
a more secure evolution of TEA.

PLC also includes:

- Chacha20 stream encryption and Poly1305 MAC as specified in RFC 7539

- Elliptic curve scalar multiplication based on ec25519 (enough to
implement a DH key exchange)

- SHA2-256

- SHA3-256 and -512

- RC4

and some non-cryptographic utilities:

- Hex, Base64, and Base58 encoding/decoding

- CRC-32 and Adler-32 checksum

--- Performance ---

The following are approximate elapsed times (in sec.) to hash or
encrypt a 10 megabytes string (on a laptop with an i5 M430 CPU at 2.27
GHz)

  4s  norx (full AEAD)
  5s  rabbit
  9s  chacha20
  11s chacha20+poly1305 AEAD
  8s  rc4

  9s  blake2b (512-bit hash)
  17s sha2-256
  43s sha3-512

More at https://github.com/philanc/plc.  See also the test_perf.lua file.

For C-level crypto performance, see also my C extension library luazen [2]

[2]  https://github.com/philanc/luazen

All suggestions, bug reports and contributions are welcome.

Regards,

Phil