Code Monkey home page Code Monkey logo

klein-avr's Introduction

This repository contains our implementation of the KLEIN-64 cipher [1] (optimised for high speed) on the AVR ATTiny45 microcontroller. The ATTiny45 is an 8-bit processor that has 32 registers, 512 bytes SRAM and 4096 bytes Flash memory. As it uses 16-bit addresses, addressing memory requires two 8-bit registers. It is worth mentioning that only register 30 and 31 can be used to load from Flash memory.

The KLEIN cipher

The KLEIN cipher is a lightweight block cipher that shows many similarities with the Rijndael (AES) cipher. KLEIN consists of roughly the same five operations: AddRoundKey, SubNibbles, RotateNibbles, MixNibbles and KeySchedule. The main difference with AES is the fact that KLEIN operates on nibbles rather than bytes.

AddRoundKey This operation consists of xoring the round key into the state.
SubNibbles In this step, the state is passed through the sbox, one nibble at a time.
RotateNibbles This operation rotates the state to the left by four nibbles.
MixNibbles This step consists of a series of permutations that can be represented as two matrix multiplications over a finite field. It operates on pairwise concatenations of nibbles as elements of an input vector, effectively mimicking the Rijndael MixColumn operation on bytes.
KeySchedule This operation computes the next round key by performing several shifts, sbox lookups and xor operations.

Our implementation

To run our implementation of the KLEIN cipher with a different input, change line 6 to 13 and line 28 to 35 according to the key and plaintext values. The initial key and plaintext are loaded into registers using ldi instructions, and the resulting ciphertext ends up in register 16 to 23. During the execution of the program we keep the round key in register 0 to 7, while the state is alternately in register 8 to 15 and register 16 to 23 depending on the parity of the round.

Graphical overview of KLEIN

KLEIN-64

References

[1] Gong, Z., Nikova, S., & Law, Y. W. (2012). KLEIN: a new family of lightweight block ciphers. In RFID. Security and Privacy (pp. 1-18). Springer Berlin Heidelberg.

klein-avr's People

Contributors

joostrijneveld avatar koen92 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.