Implementing Blowfish using PIC16F877
Again for crypto nutters
, i’ve implemented blowfish encryption using PIC16F877. Blowfish was pretty simple to implement, it employs 32 bit addtion, bitwise XOR and substitution only. But wait, it uses 4096 bytes to implement SBOX Table Lookup, so you have to choose microcontroller with memory capacity greater than 4 kbytes.
Blowfish is one of symetric block cipher. It employs feistel structure with 32 bit wide on each side. It is royalty free and require no license. It’s faster than DES and IDEA. Yeah, its good for everyone. Its Free!
This implementation contains both of encryption and decryption routine. You can download and redistribute the code, but take your own risk and don’t forget to mention the source
. So, If you are looking for an example of Blowfish implementation on hardware, you got the right page.
As a benchmark, the program takes 1216 cycles (1.2 ms) to do key setup. To encrypt one block of plain text, it takes 5100 cycles (5.1 ms) also, to decrypt one block of cipher text also takes 5100 cycles (5.1 ms). By this implementation, you can encrypt and decrypt 1.568 kbyte/s. I knew i was fairly slow, i keep trying to modify the code till the most effective one. Hopefully, someday i”ll have a chance to implement this on FPGA or CPLD.
Bruce Scheneier is the author of Blowfish Encryption/Decryption Algorithm. He own the algorithm. Big thanks to him. Check out his website here.
RELATED STUFF
Download:
Source Code v1.0
Source Code v1.1
Source Code v1.2
PIC16F877 Datasheet
Mid Range Reference Manual
References:
Blowfish Cipher
Bruce Schneier
Links:
Encryption
PIC16F877
PIC16F877 Programmer
PIC16F877 Development Board











