The Hardware Side of Cryptography

2 November 2009

A Compact Implementation of Grain Cipher using PIC16F84

This post demostrates an example of compact grain cipher implementation using PIC16F84, a stream cipher invented by Martin Hell, Thomas Johansson and Willi Meier. This stream cipher is based on Linear Feedback Shift Register (LFSR) and non-linear feedback shift register (NFSR).

The core of this cipher are two shift registers, two tapping function for determining the next state of the cipher. The last filtering function is used to determine the bit stream output based on the current cipher state.

All shift registers are emulated as 8 consecutive registers which is treated as a unity. The linear boolean function are implemented on the fly while non-linear boolean function are stored as a lookup table to save memory usage and to simplify the implementation.

I have tested the source source code against several known test vector. Here is the example.


Test Vector
Cipher Key : 44 44 44 44 44 44 44 44 44 44
IV : 55 55 55 55 55 55 55 55
Bit Stream : aa 65 8e e6 45 ef d3 4f 34 28

test vector result:

The code is released for free under the term of GNU Public License v3.0 without any warranty implied. You may use this code for educational purpose only.

Related Stuff

Download
Source Code | v1.0 | v1.1
Grain Stream Cipher Specification
MPLAB 8.40

Reference
Grain Cipher

About these ads

2 Comments »

  1. can any one submit d code for slidefair cipher to be implemented in any scripting language

    Comment by sowmya — 11 January 2010 @ 9:18 am

  2. If you have been sent for therapy or given drugs,
    yours is not a surgical situation, meaning that your spasms are not a protective reaction against injury, but a
    reflex-conditioning problem. Article Source: get more tips on beating back pain and
    in particular sciatic pain, visit our website at where we talk about sciatic nerve pain relief.
    Pain due to compression of a spinal nerve root may
    be due to such disorders as a herniated disk, osteoarthritis, osteoporosis, spinal stenosis, or Paget’s disease.

    Comment by 3629;& — 20 June 2014 @ 2:27 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:

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

The Silver is the New Black Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: