micro-aes (MIT License)

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Library: micro-aes

 

Background: My company is keen on open source, and we've released a library that we recently developed. We struggled to find an AES library that was suitable for use on a micro-controller and also permissively licensed for use on closed source software. I/We would appreciate any feedback that you have :)

 

Features

  • Does not use dynamic memory allocation
  • Uses timing-safe algorithms in place of lookup tables (where possible) to reduce code size
  • API designed for use in a low memory environment (cipher text overwrites plain text on encryption)

 

API

// AES-256
void aes_256_init    (aes_256_context_t *context, uint8_t key[32]);
void aes_256_encrypt (aes_256_context_t *context, uint8_t block[16]);
void aes_256_decrypt (aes_256_context_t *context, uint8_t block[16]);

// AES-192
void aes_192_init    (aes_192_context_t *context, uint8_t key[24]);
void aes_192_encrypt (aes_192_context_t *context, uint8_t block[16]);
void aes_192_decrypt (aes_192_context_t *context, uint8_t block[16]);

// AES-128
void aes_128_init    (aes_128_context_t *context, uint8_t key[16]);
void aes_128_encrypt (aes_128_context_t *context, uint8_t block[16]);
void aes_128_decrypt (aes_128_context_t *context, uint8_t block[16]);

 

Last Edited: Sun. Nov 13, 2016 - 11:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you and your co-workers for this.

In 2016-Sep, Atmel distributed an AES-128 for the mega328.

Its license is similar to a typical common 3-part with an added fourth part of use only on an Atmel MCU.

 

Source code :

http://start.atmel.com/#examples

In search "AVR284"

Download

Rename the file type from atzip to zip

AVR284... from root

 


http://www.atmel.com/devices/ATMEGA328PB.aspx?tab=documents (Atmel AVR284: Software Library for AES-128 Encryption and Decryption on megaAVR)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For your next research project,  try searching directly in github.

Github does not seem to get indexed very well by regular search engines.

 

https://github.com/search?utf8=%...

 

I picked a random example out of the 1800 projects with "aes" in them and the licence seems pretty permissive:

/*  
*   Byte-oriented AES-256 implementation.
*   All lookup tables replaced with 'on the fly' calculations. 
*
*   Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
*   Other contributors: Hal Finney
*
*   Permission to use, copy, modify, and distribute this software for any
*   purpose with or without fee is hereby granted, provided that the above
*   copyright notice and this permission notice appear in all copies.
*
...

 

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's a good way of searching for code that I haven't used before, thanks!

You have to be a bit careful with crypto code though, as there's lots of examples of it not being done properly. Having given it a quick glance, the library you mention (this one I believe: https://github.com/qistoph/ArduinoAES256/blob/master/aes256.cpp) has a variety of timing attack vulnerabilities that make it unsuitable for use.

I'm sure there's probably one in the list that would fit the bill though!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AndrewCarterUK wrote:
API designed for use in a low memory environment

 

Can you provide examples of Flash and RAM required?

Also time (clock cycles) required to encrypt/decrypt.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chuck99 wrote:

AndrewCarterUK wrote:
API designed for use in a low memory environment

 

Can you provide examples of Flash and RAM required?

Also time (clock cycles) required to encrypt/decrypt.

 

 

 

I haven't generated the speed stats as it was pretty much immediate for the things we were using it for. I might have a look later this week if I get a chance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to be a bit careful with crypto code though, as there's lots of examples of it not being done properly.

How could we be reassured that your product was coded properly?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jremington wrote:

You have to be a bit careful with crypto code though, as there's lots of examples of it not being done properly.

How could we be reassured that your product was coded properly?

 

It's open source laugh

 

I wasn't saying that I'd never use one of the other ones, I was just saying that you have to be careful. I only really mentioned it because the library that was referenced was vulnerable to side channel attacks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, have  you documented that the code passes standard tests or do we have to do that?

Last Edited: Thu. Nov 17, 2016 - 03:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jremington wrote:

So, have  you documented that the code passes standard tests or do we have to do that?

 

There's a link in the README to the Travis build which runs 2042 of the NIST test vectors against the source code every time the repository is updated. The "build: passing" icon will go red if any of those tests fail.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

look at www.emsign.nl

will also do a 192 and 256

 

 

AES 128 SF   Cycles Code size Ram needed
  Init 25389
  Encrypt 7622 900 bytes 768+16 bytes
  Decrypt 8279 904 bytes 768+16 bytes
  Combined   1302 bytes 768+16 bytes
AES 128 SR   Cycles Code size Ram needed
  Init 5534
  Encrypt 7762 966 bytes 256+16 bytes
  Decrypt 8411 1222 bytes 256+16 bytes
  Combined   1620 bytes 256+16 bytes