The Hardware Side of Cryptography

21 January 2008

Implementing AES using PIC16F84

Filed under: encryption — Tags: , , , , — edipermadi @ 5:18 am

Rijndael (AES) is one of many ciphers that belong to Advanced Encryption Stantard (AES). Generally, AES term refers to rijndael algorithm, although there are many other candidates of AES cipher. Rijndael algorithm was developed by Vincent Rijmen and Joan Daemen that won the FIPS’s AES cryptographic algorithm submission.

Unlike blowfish, Rijndael or AES takes litle memory. This is true since AES only has two 256 byte of SBOX tables. However, blowfish has eight 32 bit of sbox tables. So you can easily implement it on any platform of microcontroller, like what i’ve done here. AES has several version, depends on how long the key was. There are AES-128, AES-192 and AES-256. Here, to make life easier, i just code the first one (AES-128). Later on you can even coded the crazier onešŸ™‚ .

I’ve decided to choose PIC16F84 to run the implementation of AES on microcontroller. If you need an example on how to implement AES using a microcontroller such PIC16F84, you get the right page. You can grab, copy and paste this page but dont forget to mention the sourcešŸ™‚ . Later on, you can translate it this code into other microcontroller platform, hopefully it will increase the speed.

I encrypted “abcdefghijklmnop” string with key “0f1571c9 47d9e859 0cb7add6 af7f6798” i get “110aaff3 f2d56c9e 691a95a5 2e1928eb” as the result which is the same as an “AES Example” that i found from http://people.eku.edu/styere/Encrypt/JS-AES.html . Open that link, it shows you how AES was done, step by step.

As a benchmark first, all of encrypting routine and sbox tables takes 835 lines of program memory. The program tooks 11.62 ms to cipher one block of plain text. I’ll keep modifying the code until it reach the fastest one.

Here is the screenshot, I took it from MPLAB 5.20

Test Result

Finally, i’ve added decryption routine into the code. I also simplified the algorithm to reduce memory usage. You know that speed and memory usage are trading off. Surely the speed was decreased, but i think it’s fair enough comparing to reducing memory usage. You can find the latest implementation (version 1.4), which is more complete and faster than before.

If youĀ need faster AES implementation, please consider AES cipher implementation on PIC16F877 instead of this code. Feel free to use this code under the term of GNU Public License v3.0šŸ˜€ .

Hot News!: AES cipher on PIC 16F877 AES cipher on PIC18F4550

RELATEDĀ STUFFS

Downloads:
Source Code AES 128-bit | v1.0 | v1.1 | v1.2 | v1.3 | v1.4 | v1.5
PIC16F84 Datasheet
Mid-RangeĀ Reference Manual
AESĀ Publication (fips-197)

References:
Wikipedia Advanced Encryption Standard
Wikipedia Vincent Rijmen
Wikipedia Joan Daemen

Official Website:
Microchip
Advanced Encryption Standard

Simulator:
AES (Rijndael) Simulator

Related Project
RS232 Serial Encryptor using PIC16F84

8 Comments »

  1. Congratulations for your implementation of AES (Rijndael) on a PIC16F84 !

    I have abandoned the F84 for a while but if the code runs on a F84, it will easily into a F628 or a F88 ! I will even try it 8n a PIC12F683 !!

    And the code is clean (easy to read) too !!!

    Again thanks !

    Comment by Normand Martel — 24 May 2009 @ 6:00 pm

  2. hai..
    need ur help about AES..
    i need to do simulation of AES algorithm for my final year project..
    but i dont know whats simulator tools to used..
    can u help me?

    Comment by fypstudent — 8 April 2011 @ 5:58 pm

  3. nice job. may we get C codes also?

    Comment by Farrukh — 19 May 2015 @ 10:57 am

  4. hello!,I really like your writing very so much! proportion we be in contact more about your article
    on AOL? I need an expert in this area to unravel my problem.
    May be that is you! Looking forward to peer you.

    Comment by garfield survival of the fattest hack — 29 May 2015 @ 4:45 am

  5. It’s amazing to go to see this web page and reading the views
    of all mates about this paragraph, while I am also zealous of getting familiarity.

    Comment by fuck — 2 June 2016 @ 7:32 pm

  6. It’s nearly impossibe to find well-informed people on this topic, but you seem like
    yoou know what you’re talking about! Thanks

    Comment by Andy — 3 September 2016 @ 4:35 pm

  7. If you are going for most excellent contents like myself,
    just visit his web page daily for the reason that it provides
    quality contents, thanks

    Comment by Adam — 3 September 2016 @ 4:41 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: