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

6 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


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.