Skinny-C
 All Data Structures Files Functions Variables Groups Pages
Skinny-C Documentation

The SKINNY family of tweakable block ciphers is intended for lightweight implementation in hardware and software, paper.

The algorithm authors' web site provides a refererence implementation in C, but it isn't terribly efficient - it is intended to be correct to make the algorithm easier to analyse. And that's OK.

The Skinny-C repository provides an alternative implementation in ISO C99 that is designed for efficient operation on 32-bit and 64-bit platforms. Alternative backends for CTR mode are also provided that can make use of GCC Vector Extensions or equivalent on systems that support 128-bit SIMD and 256-bit SIMD operations.

Other assembly language and SIMD speed-ups are definitely possible, such as this blindingly fast AVX2 implementation, and may be added later.

This implementation is designed to have constant-time and constant-cache behaviour. In particular, there are no lookup tables for the S-boxes.

Skinny-C is distributed under the terms of the MIT license.

Building Skinny-C

To build the code with gcc and gmake, simply type "make". Then type "make check" to run the test cases and "make perf" to run the performance tests. Some modifications may be needed to the Makefile's and the "options.mak" file to build on non-GNU platforms or with other compilers.

The definitions in the "options.mak" file can be used to tune the compiler options for enabling various features like SSE2, NEON, or AVX2 instructions. The files "src/skinny-internal.h" and "src/skinny-internal.c" also contain definitions that can be tuned to get better performance on your platform.

I mainly use gcc on a Linux x86-64 platform. There is some support in the code for compiling with clang. Patches are welcome to tune the library for other platforms and compilers.

Using Skinny-C

The API for Skinny-C is described on this page.

Examples

There are three example programs, "skinny-ctr", "skinny-tweak", and "skinny-ecb" in the "examples" directory of the repository. See the README.md file in that directory for information on using the examples.

The "skinny-ctr" program is a simple example of encrypting and decrypting files using SKINNY in CTR mode. Incrementing counter values are encrypted for each block and XOR'ed with the plaintext to create the ciphertext.

The "skinny-tweak" program is similar to "skinny-ctr" except that it increments the tweak each block and encrypts the plaintext directly using the key and tweak. This is intended as an example of using SKINNY as a true tweakable block cipher, rather than a recommended method to use SKINNY in a realistic application.

The "skinny-ecb" program is similar to "skinny-ctr" except that it encrypts the data in ECB mode.

API Reference

Arduino Version

The Skinny-C repository contains a cut-down implementation of Skinny-64, Skinny-128, and Mantis-8 for Arduino devices. More information is on this page.

Contact

For more information on this code, to report bugs, or to suggest improvements, please contact the author Rhys Weatherley via email.