GithubHelp home page GithubHelp logo

kildom / avr-aes Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 88 KB

AES cipher implementation for 8-bit AVR microcontrollers

License: GNU General Public License v3.0

C 66.83% Makefile 0.25% Batchfile 0.19% PHP 1.12% Assembly 27.13% JavaScript 4.47%

avr-aes's People

Contributors

kildom avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

avr-aes's Issues

Improve test framework

Nice to have:

  • switch to some more advanced AVR simulator, e.g. fork of https://github.com/buserror/simavr with changes for tracking SP register.
    • problem with tracking changes to SPL and SPH separately can be solved by logging read from SP, SPL or SPH first time after writing to it.
  • rewrite test scripts in different language
  • add more AES test vectors
  • replace Atmel Studio test project files with makefile.
  • add regression summary - current speed and size comparison with any of the previous commits

Add option to read expanded key from fash or eeprom

In systems where key may be stored in flash or eeprom memory it can be beneficial to use pre-expanded key. It can be read from flash or eeprom directly, so less RAM will be used and key expansion will not be executed each time. This applies to all implementations.

User need to generate the expanded key. It should be possible to do it in following ways:

  • in runtime using a function that generates part of the expanded key on each call.
  • with some tools. It will be best to have this script in multiple languages, e.g. JS, Java, C, C#, Bash, BAT, php, python, HTML. It should have clean separation of frontend and backend to allow user to use backend in his application
  • on-line in a browser (JavaScript). It can be hosted by github pages

Implement 192 and 256 bits key size

Larger key sizes can be added into SMALL implementation without a big effort. It requires more rounds and improved (or completely new) addRoundKey function. Each key size should be independently enabled/disabled.

There are two options how to do a new API:

  • add new parameter with key size
  • provide different functions for a new key sizes

Implement constant time sbox calculation for AES_SHORTSBOX

Setting AES_SHORTSBOX or AES_SHORTINVSBOX is causing variable time of encrypting and decrypting. In some situations it may lead to vulnerability to side channel attacks (timing attack). Faster and smaller implementation (variable time) should be used as a default.

Documentation must contains information about that vulnerability.

Replace "by" by "based on"

Implementations based on external sources contains not so small changes, so using by is not precise enough. Better expression will be based on. This applies to source code comments and documentation.

Move Rcon static variable into register

Place Rcon into local variables and pass it as a first parameter to key handling functions. Assign returned value back to Rcon, e.g.:

byte Rcon;
...

Rcon = aesAddRoundKey(Rcon, state, key);

Improved README

README.TXT should contain more detailed description. Following things should be added or improved:

  • Description of each API containing description of each implementation
  • Description of each implementation
    • General description
    • Reference to API that it implements
    • Performance and size details
    • Reference to configuration options that are used in it
  • Description of each configuration option with list of implementations that are affected
  • Performance and size summary
  • Convert to MD

Fix code style

Code style (mostly indentation) is inconsistent. Reformatting is required. Also some link to code style guaidlines should be added into README.

Create release script

Release script should do following things:

  • Run tests
  • Combine source files into single .c/.h pair
  • Adds license and readme
  • Create release ZIP file
  • Script should show a message with a next release steps (check list), e.g. creating a release tag, uploading ZIP to github.
  • In the future it should be possible to create two ZIPs, second with limited number of files that can be released under BSD license: #14

Add block modes

Add block modes:

  • ECB
  • CBC
  • PCBC
  • CFB
  • OFB
  • CTR

Message padding should also be considered.

Idea for a new implementation

Investigate one more implementation focused on small footprint TINY. Commonly executed operations may be grouped into functions and executed by a very simple VM. Actual implementation will be inside a bytecode.

Draft-VM-approach

Replace aesTempBuffer with stack allocated buffer

This should be optional. By default stack allocated memory is used, but user should have ability to switch to old behavior to reduce footprint.
How to do it:

  • SP can be increased in assembler
  • Loading to Y from aesTempBuffer can be replaced by LDI some_temp_reg, offset; RCALL loadTempBufPtr and loadTempBufPtr: IN Ylo, SPL; IN Yhi, SPH; ADD Ylo, some_temp_reg; LDI some_temp_reg, 0; ADC Yhi, some_temp_reg; RET
  • loadTempBufPtr may also load SPL into some_temp_reg: LDI some_temp_reg, SPL. After call to this function some_temp_reg may be adjusted by ADD instruction and used in loops conditions, e.g. ADD some_temp_reg, offset; ... ; cp Ylo, some_temp_reg

Use Travis CI

  • Move tests to Travis CI
  • Consider moving release execution to Travis CI

Make better file structure

Combining everything in single .c file makes it less readable and maintainable. aes.c should be split into separate files .c/.h files for each implementation of the cipher and one common .h or .inc file. Release files can contains auto-generated combined .c/.h pair.

Doxygen

  • Make all comments Doxygen compatible
  • Create Doxygen config file
  • Make Doxygen pages based on Readme (maybe autogenerated)
  • Release html with github pages

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.