somesocks / lua-lockbox

A collection of cryptographic primitives written in pure Lua
MIT License
362 stars 75 forks source link

:information_source: Looking For Maintainers

I'm afraid I've run out of free time to work on the Lockbox, so I'm looking for anyone interested in maintaining/growing the project. If you're interested, open an issue and request to be a collaborator.

The Lua Lockbox

Build Status License: MIT Luacheck

A collection of cryptographic primitives and protocols written in pure Lua. This was written to provide cross-platform, tested reference implementations of many different cryptographic primitives. These are written to be easy to read and easy to use, not for performance!

Implemented Primitives

Digests:

Message Authentication Codes (MACs):

Key Derivation Functions (KDFs):

Block Ciphers:

Block Cipher Modes:

Block Cipher Padding:

Usage

To use these cryptographic primitives in a project, you'll likely have to modify Lockbox.lua to change the module search path. All the primitives import this module to find the packages they require. See RunTests.lua as an example.

The cryptographic primitives are designed to work on streams of bytes. There are three data structures used to help with this: Array(a Lua array of bytes), Stream(an iterator that returns a series of bytes), and Queue(a FIFO pipe of bytes). See Array.lua, Stream.lua, and Queue.lua for more details.

Most cryptographic primitives are designed in a builder-style pattern. They usually have three functions: init, update, and finish. All of these functions will return the primitive, so you can chain functions calls together.

For examples of how to use the different primitives, read the test case files under tests.

Security Concerns

Several weak or broken primitives are implemented in this library, for research or legacy reasons. These should not be used under normal circumstances! To restrict their usage, they have been marked as insecure, with the Lockbox.insecure() method. This will cause a failed assertion when you attempt to import the module, unless you set Lockbox.ALLOW_INSECURE to true before the import. For an example, see RunTests.lua.

Modules names

Planned Updates