Skip to content

jameswmccarty/SPECK-cipher

Repository files navigation

SPECK-cipher

C implementation of NSA's SPECK block cipher.

DISCLAIMER

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED

This project was started to study the SPECK lightweight block cipher outlined in the NSA paper (included in this repo), also hosted: https://eprint.iacr.org/2013/404.pdf.

I make no guarantees as to the correctness of this implementation. This code should not be used for any purpose other than study.

Implementation

This program implements the SPECK cipher with a 128-bit key size and a 128-bit block size. It was designed and compiled on x86_64 Linux.

Files

  • Makefile: Makefile for this project.
  • speck.c: The main c program that implements the cipher.
  • test_vectors.c: Utility code to produce example binary input files.
  • key_128.key: Example key value (from NSA paper test vectors).
  • vect_cipher128.hex: Enciphered 128-bit binary test vector.
  • vect_plain128.hex: Plain text 128-bit binary test vector.
  • NSA SIMON-SPECK 404.pdf: NSA paper outlining the SIMON&SPECK block cipher.

Useage

To compile all, type "make."

SPECK

./speck [-h] -k keyfile [-e|-d] -i infile -o outfile [-x]

flags specify:

  • -h print help screen, then exit.
  • -k keyfile A 128-bit key in the format 0...0 (32 hex chars, no leading 0x). Note this is a text file, not a binary file.
  • -e encrypt the input file.
  • -d decrypt the input file.
  • -i input file path.
  • -o output file path.
  • -x perform key pre-expansion (vice on the fly).

TESTVECT

./testvect

There are no input options for this program, but it will produce vect_cipher128.hex and vect_plain128.hex in the directory where it is run.

Example Useage

./speck -k key_128.key -e -i vect_plain128.hex -o output.enc | Encrypts 'vect_plain128.hex' and stores in output.enc

./speck -k key_128.key -d -i output.enc -o plain_vect.hex | Decrypts 'output.enc' and stores in plain_vect.hex

./speck -k key_128.key -d -i output.enc -o plain_vect.hex -x | Same as above with key pre-expansion.

Known Issues

  • Program only reads/writes a 128-bit block size. This may lead to null bytes at the end of some files.
  • Makes no attempt to correct endedness related issues on file reads/writes. Encrypted files may not be portable across systems.
  • Only implements 128-bit keysize / blocksize.

About

C implementation of NSA's SPECK block cipher.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published