The Hardware Side of Cryptography

11 February 2008

GOST cipher implementation on PIC16F84

Filed under: encryption — Tags: , , , — edipermadi @ 4:46 am

GOST was a Soviet Union (Now Russian) standard of cryptography. GOST stands for “Gosudarstvennyi Standard Soyuza SSR” or Government Standard of the Union of Soviet Socialist Republics, which is equal to FIPS in USA.

GOST cipher is a 64-bit block cipher with 256 key and 32 rounds. It uses feistel structure, SBOX based substitution, Circular left shift by 11, 32 bit addition, 32 bit bitwise XOR and 32-bit register to register swapping with simple key scheduling. If code size matter, GOST can be implemented on microcontroller such PIC16F84 with less than 256 lines of code and less than 64 bytes of RAM. But if speed matter, you can modify the code to go faster but with larger code size. Again, it depends on your purposes.

I got the specification of GOST from here. But it contains missing thing such SBOX. Here i just took DES SBOX to fill the missing chain, of course to make the cipher works. Although this way sounds funny and speculative, the most important thing is that actually GOST cipher works on any SBOX table including DES. Here, i cannot guarantee that my code fully compatible with original GOST cipher. But, since nobody know the real SBOX table for GOST cipher, lets make just our life easier and assume that it is true. Dont confuse yourselfūüôā .

For more confidential things, you can modify SBOX table and create your own customizable GOST cipher and have fun.

If you use microcontroller with larger program memory space , you can cut unnecessary steps by combining 2 4-bit SBOX become a 8-bit SBOX. By doing that, we can speed up the code and neglect code size. Later on, i will port the code to PIC16F877.

Below is the screenshot that i took from MPLAB 5.20.


Source Code v1.0
PIC16F84 Datasheet
Mid-Range Reference Manual
Original GOST cipher translation
GOST Specification
An Analysis of GOST cipher

Wikipedia GOST

Official Website:


  1. cool

    Comment by silver — 5 January 2010 @ 2:32 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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

%d bloggers like this: