OpenCores
URL https://opencores.org/ocsvn/csa/csa/trunk

Subversion Repositories csa

[/] [csa/] [trunk/] [sw_sim/] [get_key_perm_table.c] - Blame information for rev 32

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 simon111
/*
2
 * this alone program generate the partical code for key_perm.v
3
 */
4
#include <stdio.h>
5
#include <string.h>
6
#include <memory.h>
7
#include <assert.h>
8
unsigned char key_perm[0x40] = {
9
    0x12,0x24,0x09,0x07,0x2A,0x31,0x1D,0x15,0x1C,0x36,0x3E,0x32,0x13,0x21,0x3B,0x40,
10
    0x18,0x14,0x25,0x27,0x02,0x35,0x1B,0x01,0x22,0x04,0x0D,0x0E,0x39,0x28,0x1A,0x29,
11
    0x33,0x23,0x34,0x0C,0x16,0x30,0x1E,0x3A,0x2D,0x1F,0x08,0x19,0x17,0x2F,0x3D,0x11,
12
    0x3C,0x05,0x38,0x2B,0x0B,0x06,0x0A,0x2C,0x20,0x3F,0x2E,0x0F,0x03,0x26,0x10,0x37,
13
};
14
 
15
unsigned char unkey_perm[0x40];
16
 
17
#define RI(i) ((i)/8*8+(7-((i)%8)))
18
 
19
int main()
20
{
21
        int i;
22
        int n;
23
        int sp;
24
        int tp;
25
        memset(unkey_perm,0,sizeof unkey_perm);
26
        for(i=0;i<64;i++)
27
        {
28
                for(n=0;n<64;n++)
29
                {
30
                        if(key_perm[n]==RI(i)+1)
31
                                break;
32
                }
33
                assert(n<64);
34
                n=RI(n);
35
                unkey_perm[i]=n;
36
        }
37
 
38
        for (i=63;i>=0;i--)
39
        {
40
                printf("i_key[6\'h%02x]", unkey_perm[i]);
41
                printf(",");
42
                if((i%4)==0)
43
                        printf("\n");
44
        }
45
        return 0;
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.