Logo SoCRocket

Transaction-Level Modeling Framework for Space Applications

Classes | Macros | Typedefs | Functions | Variables
des.c File Reference
#include <math.h>
#include <stdio.h>
Include dependency graph for des.c:

Classes

struct  test8
 

Macros

#define SHORT_BENCH
 
#define ENCRYPT   1
 
#define DECRYPT   0
 
#define KEY_SZ   8
 
#define ITERATIONS   128
 
#define HALF_ITERATIONS   64
 
#define c2l(c, l)
 
#define c2ln(c, l1, l2, n)
 
#define l2c(l, c)
 
#define l2cn(l1, l2, c, n)
 
#define PERM_OP(a, b, t, n, m)
 
#define HPERM_OP(a, t, n, m)
 
#define D_ENCRYPT(L, R, S)
 
#define NTESTS   20
 

Typedefs

typedef unsigned char uchar
 
typedef unsigned short ushort
 
typedef unsigned int uint
 
typedef unsigned long ulong
 

Functions

void des_set_key (unsigned char *key, void *schedule)
 
int des_encrypt (ulong *, ulong *, ulong *, int)
 
int des_ecb_encrypt (unsigned char *input, unsigned char *output, void *ks, int encrypt)
 
int beq (unsigned char *a, unsigned char *b, int z)
 
int main ()
 

Variables

ulonginput
 
ulongoutput
 
ulongks
 
int encrypt
 
struct test8 test8 []
 
unsigned long keys [32]
 

Macro Definition Documentation

#define c2l (   c,
 
)
Value:
(l =((ulong)(*((c)++))) , \
l|=((ulong)(*((c)++)))<< 8, \
l|=((ulong)(*((c)++)))<<16, \
l|=((ulong)(*((c)++)))<<24)
unsigned long ulong
Definition: des.c:15

Referenced by des_ecb_encrypt(), and des_set_key().

#define c2ln (   c,
  l1,
  l2,
 
)
Value:
{ \
c+=n; \
l1=l2=0; \
switch (n) { \
case 7: l2|=((ulong)(*(--(c))))<<16; \
case 6: l2|=((ulong)(*(--(c))))<< 8; \
case 5: l2|=((ulong)(*(--(c)))); \
case 4: l1|=((ulong)(*(--(c))))<<24; \
case 3: l1|=((ulong)(*(--(c))))<<16; \
case 2: l1|=((ulong)(*(--(c))))<< 8; \
case 1: l1|=((ulong)(*(--(c)))); \
} \
}
unsigned long ulong
Definition: des.c:15
fpreex g0 bne add l5 st l3 l5 or l3 st fsr!enable exceptions jmpl l1
Definition: grfpu_ops.S:440
fmovs f0 retl nop f0 retl nop f2 fdivd f4 std retl nop o1 st f0 fitod f2 std retl o0 o1 st f0 fitos f2 st retl o0 o2 std f0 fdtoi f2 st retl o0 o2 st f0 fstoi f2 st retl o0 o2 st f0 fstod f0 std retl o0 o2 std f0 fdtos f0 st retl o0 o2 st f5 fmovs f6 st retl o0 o2 st f5 fnegs f6 st retl o0 o2 st f5 fabss f6 st retl o0 o4 std std f0 f2 fcmpd f2 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 std std f0 f2 fcmped f2 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 st st f0 f1 fcmps f1 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 st st f0 f1 fcmpes f1 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 std std f0 f2 fsubd f4 std retl o0 o4 st st f0 f1 fadds f2 st retl o0 o4 st st f0 f1 fsubs f2 st retl o0 o4 st st f0 f1 fmuls f2 st retl o0 o4 st st f0 f1 fdivs f2 st retl o0 o4 st f0 fsqrts f1 st retl o0 o1 f2 f0 faddd f10 o1 f0 f1 fadds f4 o3 set o1 set o2 f10 f11 st o4 set o1!change buffer for second run subcc o3 bne grfpc_spdep_tst2_loop nop retl nop o1 set o2 f0 f2 fadds f4!fdivs f5!fmuld f6!fmuls f7 fsqrtd f8 retl std o0 f0 f2 f4 f6 f8 f10 f12 f14 f16 f18 f20 f22 f24 f26 f28 f30 retl nop l4 set l3 st l3 srl l0 and l0 subcc l0 otherwise l7 l7 add l6 std st l5 srl l5 andcc l5 bne nop!std!jmpl l2
Definition: grfpu_ops.S:402
#define D_ENCRYPT (   L,
  R,
  S 
)
Value:
u=(R^s[S ]); \
t=R^s[S+1]; \
t=((t>>4)+(t<<28)); \
L^= des_SPtrans[1][(t )&0x3f]| \
des_SPtrans[3][(t>> 8)&0x3f]| \
des_SPtrans[5][(t>>16)&0x3f]| \
des_SPtrans[7][(t>>24)&0x3f]| \
des_SPtrans[0][(u )&0x3f]| \
des_SPtrans[2][(u>> 8)&0x3f]| \
des_SPtrans[4][(u>>16)&0x3f]| \
des_SPtrans[6][(u>>24)&0x3f];
#define S
Definition: fir2.c:33
volatile unsigned int s
Definition: satcan.c:250

Referenced by des_encrypt().

#define DECRYPT   0
#define ENCRYPT   1

Referenced by main().

#define HALF_ITERATIONS   64
#define HPERM_OP (   a,
  t,
  n,
 
)
Value:
((t)=((((a)<<(16-(n)))^(a))&(m)),\
(a)=(a)^(t)^(t>>(16-(n))))\

Referenced by des_set_key().

#define ITERATIONS   128

Referenced by des_set_key().

#define KEY_SZ   8
#define l2c (   l,
 
)
Value:
(*((c)++)=(uchar)(((l) )&0xff), \
*((c)++)=(uchar)(((l)>> 8)&0xff), \
*((c)++)=(uchar)(((l)>>16)&0xff), \
*((c)++)=(uchar)(((l)>>24)&0xff))
unsigned char uchar
Definition: des.c:12

Referenced by des_ecb_encrypt().

#define l2cn (   l1,
  l2,
  c,
 
)
Value:
{ \
c+=n; \
switch (n) { \
case 7: *(--(c))=(uchar)(((l2)>>16)&0xff); \
case 6: *(--(c))=(uchar)(((l2)>> 8)&0xff); \
case 5: *(--(c))=(uchar)(((l2) )&0xff); \
case 4: *(--(c))=(uchar)(((l1)>>24)&0xff); \
case 3: *(--(c))=(uchar)(((l1)>>16)&0xff); \
case 2: *(--(c))=(uchar)(((l1)>> 8)&0xff); \
case 1: *(--(c))=(uchar)(((l1) )&0xff); \
} \
}
fpreex g0 bne add l5 st l3 l5 or l3 st fsr!enable exceptions jmpl l1
Definition: grfpu_ops.S:440
fmovs f0 retl nop f0 retl nop f2 fdivd f4 std retl nop o1 st f0 fitod f2 std retl o0 o1 st f0 fitos f2 st retl o0 o2 std f0 fdtoi f2 st retl o0 o2 st f0 fstoi f2 st retl o0 o2 st f0 fstod f0 std retl o0 o2 std f0 fdtos f0 st retl o0 o2 st f5 fmovs f6 st retl o0 o2 st f5 fnegs f6 st retl o0 o2 st f5 fabss f6 st retl o0 o4 std std f0 f2 fcmpd f2 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 std std f0 f2 fcmped f2 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 st st f0 f1 fcmps f1 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 st st f0 f1 fcmpes f1 nop a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 a cmpd_end o0 ta!error o4 std std f0 f2 fsubd f4 std retl o0 o4 st st f0 f1 fadds f2 st retl o0 o4 st st f0 f1 fsubs f2 st retl o0 o4 st st f0 f1 fmuls f2 st retl o0 o4 st st f0 f1 fdivs f2 st retl o0 o4 st f0 fsqrts f1 st retl o0 o1 f2 f0 faddd f10 o1 f0 f1 fadds f4 o3 set o1 set o2 f10 f11 st o4 set o1!change buffer for second run subcc o3 bne grfpc_spdep_tst2_loop nop retl nop o1 set o2 f0 f2 fadds f4!fdivs f5!fmuld f6!fmuls f7 fsqrtd f8 retl std o0 f0 f2 f4 f6 f8 f10 f12 f14 f16 f18 f20 f22 f24 f26 f28 f30 retl nop l4 set l3 st l3 srl l0 and l0 subcc l0 otherwise l7 l7 add l6 std st l5 srl l5 andcc l5 bne nop!std!jmpl l2
Definition: grfpu_ops.S:402
unsigned char uchar
Definition: des.c:12
#define NTESTS   20

Referenced by main().

#define PERM_OP (   a,
  b,
  t,
  n,
 
)
Value:
((t)=((((a)>>(n))^(b))&(m)),\
(b)^=(t),\
(a)^=((t)<<(n)))

Referenced by des_encrypt(), and des_set_key().

#define SHORT_BENCH

Typedef Documentation

typedef unsigned char uchar
typedef unsigned int uint
typedef unsigned long ulong
typedef unsigned short ushort

Function Documentation

int beq ( unsigned char a,
unsigned char b,
int  z 
)

Referenced by main().

int des_ecb_encrypt ( unsigned char input,
unsigned char output,
void *  ks,
int  encrypt 
)

References c2l, des_encrypt(), l0, l1, and l2c.

Referenced by main().

Here is the call graph for this function:

int des_encrypt ( ulong input,
ulong output,
ulong ks,
int  encrypt 
)

References D_ENCRYPT, i, PERM_OP, r, and s.

Referenced by des_ecb_encrypt().

void des_set_key ( unsigned char key,
void *  schedule 
)

References c2l, d, HPERM_OP, i, ITERATIONS, PERM_OP, and s.

Referenced by main().

int main ( void  )

References beq(), test8::cipher, des_ecb_encrypt(), des_set_key(), ENCRYPT, i, test8::key, keys, NTESTS, and test8::plain.

Here is the call graph for this function:

Variable Documentation

int encrypt
ulong* input
unsigned long keys[32]

Referenced by main().

ulong* ks
ulong* output
struct test8 test8[]