The Hardware Side of Cryptography

24 July 2008

Tweaked Khazad Block Cipher Implementation on PIC18F4550

Filed under: encryption — Tags: , , , , — edipermadi @ 1:23 pm

Khazad is a Non Feistel Block Cipher scheme designed by Paulo S. L. M. Barreto and Vincent Rijmen. This cipher consists of 8 rounds of simple operation such XOR, shift, and substitution. Khazad block cipher has capability of encrypting and decrypting 64-bit block of data with 128-bit keys supplied. The authors said that khazad cipher is free to use and never be patented.

The cipher was easy, straightforward and easy to understand. Here, i provided you an example of Tweaked Khazad Block cipher implementation on PIC18F4550 microcontroller. The implementation here is based on the original C code Khazad implemementation on 64-bit microprocessor platform, therefore this way of implementation employs large lookup table approximately 16kbytes.

Basically, Khazad runs fast on PIC18F4550. It requires 9903 cyles for key setup and 3872 cycles for encryption and  decryption. Since Khazad was an involutional block cipher, you may notice that encrypting and decrypting speed was the same as well as its strength. The only thing that differ is about subkeys.

The source code here was developed and simulated on MPLAB v8.0 and released under the term of GNU Public License 3.0. Feel free to use it by your own risk🙂 . See screenshots below.

Khazad Plain text (Blue = key, Orange = Plain Text)

Khazad Cipher Text (Blue = Cipher Text)

Khazad Generated Subkeys (Blue = Encrypting Subkeys, Orange = Decrypting Subkeys)

I realized that this implementation hoggs memory much and i may not fit on real implementation such smart cards. I will scale down this implementatio so that it fit on smaller microcontroller such PIC16F84 and PIC16F877. Keep visiting this blog for more updates. Cheers😀

RELATED STUFF

Download
Source Code | v1.0 | v1.1 | v1.2
PIC18F4550 Datasheet
Khazad Tweak Specification
MPLAB v8.0

Reference
Khazad Cipher

Official Website
Khazad Block Cipher

Leave a Comment »

No comments yet.

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: