Code Monkey home page Code Monkey logo

aes-min's Introduction

aes-min

Minimal AES-128 (Wikipedia) encryption.

This aims to be suitable for small embedded systems with limited RAM and ROM.

It includes optional on-the-fly key schedule calculation, for minimal RAM usage if required in a very RAM-constrained application. For systems with sufficient RAM, there is also encryption and decryption with a pre-calculated key schedule.

Normally the S-box implementation is by a simple 256-byte table look-up. An optional smaller S-box implementation is included for a very ROM-constrained application, where a 256-byte look-up table might be too big. This would only be expected to be necessary for especially tiny target applications, e.g. an automotive keyless entry remote.

Encryption modes

Encryption modes (CBC, OFB, etc) are not implemented. This only provides the core AES encryption operation, and leaves it to the developer to implement the encryption mode. This is because for small embedded systems, there are so many possible ways to handle the data in a memory-constrained system, it's not possible to provide an API that suits the needs of every system.

In most cases, implementation of the encryption mode is reasonably straight-forward, requiring only a few block XOR operations. The function aes_block_xor() can be used for the block XOR operation.

AES-GCM encryption mode

GCM encryption mode (Galois/Counter Mode) is an authenticated encryption mode, which uses a Galois 128-bit multiply operation. Code is provided to do the 128-bit Galois multiply operation needed for GCM mode. Several implementations are provided, depending on the required trade-off between speed and RAM consumption:

  • a bit-by-bit implementation (slow but requiring minimal RAM)
  • a table implementation using an 8-bit table look-up (fast, but requiring 4,080 bytes of calculated table data per key)
  • a 4-bit table look-up implementation (moderately fast, requiring 480 bytes of calculated table data per key)

Testing

Test programs are included, which test the S-box implementation and encrypt and decrypt operations.

Encryption and decryption are tested against some files in the official test vectors. Specifically, the ECB mode test files were used, for AES-128. These files:

  • ECBGFSbox128.rsp
  • ECBKeySbox128.rsp
  • ECBVarKey128.rsp
  • ECBVarTxt128.rsp

The test vectors were parsed and converted to C data structures using a Python program.

For AES-GCM mode, the Galois 128-bit multiply is tested against these AES-GCM test vectors from NIST.

When using autotools, run the tests via:

make check

License

This code is released under the MIT license. See LICENSE.txt for details.

aes-min's People

Contributors

cmcqueen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aes-min's Issues

Support Request, How to use the library

  1. How to use this library?
  2. What is schedule, block, start_key and key work and their relation to key, IV and data?
  3. What is gcm (gcm.h, gcm.c), do I need to include them too?
  4. I'm trying to fit this library plus some other code in a ATTiny85 (6KB), do I need all the files in library or just aes-min.c and aes-min.h?
  5. Is it possible to directly work on data block (array) instead of copying it to another array?
  6. And finally, I don't think I can fit your copyright inside ATTiny with the code, where do you like me to put it?

gcm_test uses gcm_mul even if TEST_GCM_MUL_TABLE4 is selected

Hello,

I've noticed that at line 390 of gcm_test.c, gcm_mul is called regardless of the value of gcm_mul_implementation_t.
I seems to me that this area could use the same switch / case statement used to select the gcm_mul implementation at the other places in this function.

Is this a simple oversight, or on purpose ?

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.