The Hardware Side of Cryptography

2 January 2009

Fast RC4 Stream Cipher Implementation on AVR

As quoted on wikipedia, RC4 is a stream cipher designed by Professor Ronald Rivest from MIT. This block cipher employs simple bytewise permutation over 256 bytes state array. This characteristic makes RC4 easy to implement in programmable device such microcontroller.

AVR is a powerful microcontroller that cope all requirements needed for RC4 implementation, from indirect memory addressing for array operation, addition and so on. The lookup process of RC4 is depicted below.

RC4 Stream Cipher Lookup Process

The previous platform of RC4 implementation that I made was PIC18F4550, which gave good performance, but AVR is better. AVR has more specific single cycled instruction that made it faster and superior than PIC18F4550 on this case.

In order to validate cipher result, I tested my code to encrypt plain text “Plaintext” with cipherkey “Key” and it generated the same hex value which was “BBF316E8D940AF0AD3″. The test vector example was taken from RC4 page on wikipedia. Take a look those three pictures below.

Plain Text

RC4 Stream Cipher Implementation on AVR (Plain Text)

Cipher Key

RC4 Stream Cipher Implementation on AVR (Cipher Key)

Cipher Text

RC4 Stream Cipher Implementation on AVR (Cipher Text)

RELATED STUFF

Download :
Source Code | v1.0

Reference:
RC4
Ronald Rivest

About these ads

10 Comments »

  1. Damn man!! you’re such talented cryptography artist!!!!

    Keep on Crazy dude!!!

    -a guy who always support you-

    Comment by Takhta Pandu Padmanegara — 14 January 2009 @ 7:57 pm

  2. i need guidance related to stream cipher specific in a5/1.

    Comment by akalili — 17 July 2009 @ 3:55 pm

    • @Akalili.
      Hi. the A5/1 implementation is basically emulates the A5/1 workingflow in register transfer level way. try to understand the A5/1 in TTL implementation, then you can easily move to Microcontroller implementation.

      Comment by edipermadi — 18 August 2009 @ 1:01 pm

  3. hi,
    i need your help in software implementation of hash function and stream cipher cryptography.

    Comment by siddharth kumar — 16 September 2009 @ 11:40 pm

  4. Good Article. Thanks you in advance

    8bit MCU implemetation ?

    But, Your source code link is broken. check it please.

    Comment by hbkim — 30 November 2009 @ 1:10 pm

  5. Thank you for this excellent piece of work. I really like the idea of putting cryptographic primitives into hardware.
    If you implemented RC4, what do you think about implementing also stronger RC4 incarnation, VMPC?
    See pastebin.com/J62Z3iHB

    Comment by IZCP — 22 July 2010 @ 10:59 pm

    • Thank you for visiting my blog and also thank you for your valuable suggestion. I’m starting to read the VMPC spec :)

      Comment by edipermadi — 23 July 2010 @ 3:50 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

The Silver is the New Black Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: