Skip to content

Lua C module implementing the ChaCha stream cipher

License

Notifications You must be signed in to change notification settings

kushalaa/lua-chacha

 
 

Repository files navigation

lua-chacha

Build Status

Presentation

This repository contains two implementations of the ChaCha stream cipher for Lua: a C module and a pure Lua module which implements the same interface.

WARNING: ChaCha is just a stream cipher, not a complete solution for encryption. Do not use this unless you really understand what you are doing.

Dependencies

The C module, "chacha", supports Lua from 5.1 to 5.3 and LuaJIT 2. The pure module only supports Lua 5.3.

Tests depend on cwtest. Tests on anything else than Lua 5.3 depend on compat53.

Usage

The module exposes two functions: ref_crypt and ietf_crypt. They both have the same interface:

f(rounds, key, IV, plaintext, [counter])

ietf_crypt corresponds to the ChaCha20 variant described in RFC7539 section 2.4. rounds must be 20; key must be 32 bytes (256 bits); IV must be 12 bytes (96 bits) and the optional argument counter must be 4 bytes (32 bits) if present.

ref_crypt corresponds to the original ChaCha algorithm by D.J. Bernstein. rounds must be a multiple of 2; key can be 16 or 32 bytes (128 or 256 bits); IV must be 8 bytes (64 bits) and the optional argument counter must be 8 bytes (64 bits) if present.

See chacha.test.lua for more.

Copyright

  • Copyright (c) 2015 - 2016 Pierre Chapuis

The original ChaCha implementation was released under the Public Domain by D.J. Bernstein.

About

Lua C module implementing the ChaCha stream cipher

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 52.9%
  • C++ 19.5%
  • Lua 18.4%
  • Shell 8.5%
  • Makefile 0.7%