A Simple Bitslice Implementation of PRESENT

I had a hunch the other day which required $2^{36}$ plaintext—ciphertext pairs to be tested. While the hunch turned out to be wrong, at least I got a simple
bitslice implementation of PRESENT (in pure C99) out of it. The implementation is far from optimal:

  • it is pure C but critical paths should be pushed down to assembly,
  • it doesn’t use SSE2’s 128-bit instructions but it should, and
  • the S-Box is hardly optimised (it is simply ANF).

Still, it is better than what I found on the web via a quick Google search. On my 2.33 Ghz Core2Duo Macbook Pro it seems to run at 28 cycles per byte for long messages (not counting the key schedule). For comparison, I think the current speed of AES in bit slice mode is like 10 cycles per byte on the Core2. If I need some performance in the future, I might sit down and improve the implementation (such that it doesn’t totally suck) but for now I have to attend to other projects.

Advertisements

5 thoughts on “A Simple Bitslice Implementation of PRESENT”

  1. Hi Martin,I came across your bitslice version of present-80 ,please can you tell me which functions to call to encrypt the message to cipher and decrypt the cipher to obtain the message back

    1. Hi Martin ,

      I did a few very minor edits to your code like initially your plaintext and key all are 0000000….64 times(plain text ) and 0000000000000………..80 times(key)

      I did a minor change

      for(i=0;i<Ks;i++)
      key[i] = rand() % 2 ;

      and similarly for key with different seeds every time to generate a random sequence of 0's and 1's

      Now I want to print the cipher-text, plain-text and initial key but because they are of type uint64_t ,I am coming across a few minor glitches .
      Can you please pitch in a snippet of code to print the plain-text ,key and cipher .

      Thank you

  2. Respected Sir ,
    Sorry for the vague comments before
    I am facing a few minor glitches while running bit-slice code of present-cipher (80 bits ) )
    I am running a 64 bit 14.2 Ubuntu Machine with a gcc compiler.I will be highly obliged if you could pitch in some code , to run your code for 16 unique inputs on bit-slice version of present block cipher.

  3. I was thinking to cut corners and hence ended up bugging you with stupid questions.I have edited your code over the past month and a half and tried to enable sse 4.2 and parallelized it using MPI (https://bitbucket.org/snippets/ishaan007/epbbg) .
    I have one request please can you give the decrypt function .I could not find the algorithm it in the original paper.I have tried reversing the scheme but the key schedule produces some errors.

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