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.
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.
Source Code | v1.0