Arduino Library for AES Encryption (source based on avr-crypto-lib)
Switch branches/tags
Nothing to show
Clone or download
DavyLandman Merge pull request #18 from asajim/multiple_basic_enc_dec
Add multiple data option on basic enc dec
Latest commit cc4f8ae Dec 29, 2017
Permalink
Failed to load latest commit information.
.gitignore First commit with a partial import of aes from crypto-lib Feb 2, 2012
AESLib.c fix documentation Dec 29, 2017
AESLib.h Add multiple data option to encryption and decryption using 128bits a… Dec 21, 2017
LICENSE Added license and README Feb 2, 2012
README.md Update README.md Aug 9, 2015
aes.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes128_dec.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes128_enc.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes192_dec.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes192_enc.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes256_dec.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes256_enc.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_dec-asm_faster.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_dec.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_enc-asm.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_enc.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_invsbox-asm.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_invsbox.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_keyschedule-asm.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_keyschedule.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_sbox-asm.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_sbox.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
aes_types.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
avr-asm-macros.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-basic.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-basic.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-cbc.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-cbc.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-cmac.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-cmac.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-ofb.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal-ofb.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal_aes128.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal_aes128.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal_aes192.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal_aes192.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal_aes256.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
bcal_aes256.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
blockcipher_descriptor.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
gf256mul.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
gf256mul.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
keysize_descriptor.c First commit with a partial import of aes from crypto-lib Feb 2, 2012
keysize_descriptor.h First commit with a partial import of aes from crypto-lib Feb 2, 2012
library.json @PlatformIO Library Registry manifest file Apr 14, 2016
memxor.S First commit with a partial import of aes from crypto-lib Feb 2, 2012
memxor.h First commit with a partial import of aes from crypto-lib Feb 2, 2012

README.md

Arduino AESLib

This project is just an Arduino ready extract from the AVR-Crypto-Lib.

It only packages the ASM implementations of AES into a library ready to use in Arduino IDE.

See the LICENSE file for details of the GPLv3 license in which the AVR-Crypo-Lib is licensed.

Installation

  • Download the files in this repository (using either clone or the download button)
  • Copy the AESLib folder into libraries folder (same level as your sketch folder)
  • add #include <AESLib.h> in your sketch.

Usage

At the moment only 128bit keys are supported, the blocksize is also fixed at 128bit. This means that the key array and possible iv array should contain exactly 16 bytes (uint8_t or byte). Moreover the amount of bytes to encrypt should be mod 16. (this means you have to take care of padding yourself).

The library supports 3 kinds of operations.

  1. single block encryption/decryption
  • multiple block encryption/decryption using CBC (single call)
  • multiple block encryption/decryption using CBC (multiple calls)

The single block enc/decryption are the following methods:

void aes128_enc_single(const uint8_t* key, void* data);
void aes128_dec_single(const uint8_t* key, void* data);

Usage example:

Serial.begin(57600);
uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data[] = "0123456789012345"; //16 chars == 16 bytes
aes128_enc_single(key, data);
Serial.print("encrypted:");
Serial.println(data);
aes128_dec_single(key, data);
Serial.print("decrypted:");
Serial.println(data);

Usage example for AES256:

Serial.begin(57600);
uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
char data[] = "0123456789012345";
aes256_enc_single(key, data);
Serial.print("encrypted:");
Serial.println(data);
aes256_dec_single(key, data);
Serial.print("decrypted:");
Serial.println(data);