Welcome Guest [Log In] [Register]
Welcome to Crypto. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
16x16 Sbox
Topic Started: Sep 23 2007, 09:49 PM (241 Views)
loki
Advanced Member
[ *  *  * ]
I was intriged by Terry Ritters Idea of dynamic substitution, after failing at my attempts to make it work. I began to start write a toy cipher which uses 16 8x8 keyed sbox's, feeling very proud of myself I walked away from the project.

After some time it dawned on me, a keyed 16x16 sbox. I have never seen one in code nor ever read about one in a paper.

here is the code I have used to generate the sbox.

Code:
 


#define swap(a,b) t = a; a = b; b = t;

int main(void) {
   int fwd[65536]; /* the forward sbox */
   int i, j, t; /* counters and swap varible */
   int r0, r1, r2, r3, r4, r5, r6, r7; /* random number varibles */
   
   /* initiate the sbox */
   for(i=0;i<65536;i++) {
                         fwd[i] = i; // ensure's each entry is unique
                         }    

   /* shuffle the sbox twice */
for(i=0;i<2;i++) {
       /* for each entry, make 8 swaps */
 for(j=0;j<65536;j++) {
           
           /* get 8 random numbers */                
  r0 = rnd(seed) % 65536;
  r1 = (r0 + rnd(seed)) % 65536;
  r2 = (r1 + rnd(seed)) % 65536;
  r3 = (r2 + rnd(seed)) % 65536;
  r4 = (r3 + rnd(seed)) % 65536;
  r5 = (r4 + rnd(seed)) % 65536;
  r6 = (r5 + rnd(seed)) % 65536;
  r7 = (r6 + rnd(seed)) % 65536;
 
  /* swap */
  swap(fwd[0], fwd[r0]);
  swap(fwd[1], fwd[r1]);
  swap(fwd[2], fwd[r2]);
  swap(fwd[3], fwd[r3]);
  swap(fwd[4], fwd[r4]);
  swap(fwd[5], fwd[r5]);
  swap(fwd[6], fwd[r6]);
  swap(fwd[7], fwd[r7]);
 }
 
}
       /* write the sbox to screen, I like to redirect into a file myself */
    for(i=0;i<65536;i++) {
                         printf("pos 0x%04x: 0x%04x\n", i, fwd[i]);
                         }
}


Your going to have modify this code to suit yourself. The rnd() function I call here is my own written macro that calls a crappy LCG.

all things aside, what are the disadvantages by using this, have you come across this before???
c(x) = 3x3 + x2 + x + 2; Find the inverse
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · General · Next Topic »
Add Reply