Changeset c0075af in rtems for cpukit/telnetd


Ignore:
Timestamp:
Jun 17, 2009, 10:29:52 PM (10 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
f9eb21d
Parents:
73c421b
Message:

2009-06-18 Chris Johns <chrisj@…>

  • telnetd/des.c: Split the des_f struct into smaller parts so targets that cannot address large structs can be supported.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/telnetd/des.c

    r73c421b rc0075af  
    7676
    7777/* TS; not really - only the stuff in Des_Context */
    78 static struct fixed {
     78static struct fixed1 {
    7979u_char  inv_key_perm[64];
    8080u_char  inv_comp_perm[56];
    8181u_char  u_sbox[8][64];
    8282u_char  un_pbox[32];
     83} des1_f;
     84static struct fixed2 {
    8385u_int32_t ip_maskl[8][256], ip_maskr[8][256];
     86} des2_f;
     87static struct fixed3 {
    8488u_int32_t fp_maskl[8][256], fp_maskr[8][256];
     89} des3_f;
     90static struct fixed4 {
    8591u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
    8692u_int32_t comp_maskl[8][128], comp_maskr[8][128];
    87 } des_f;
    88 
    89 #define inv_key_perm des_f.inv_key_perm
    90 #define inv_comp_perm des_f.inv_comp_perm
    91 #define u_sbox des_f.u_sbox
    92 #define un_pbox des_f.un_pbox
    93 #define ip_maskl des_f.ip_maskl
    94 #define ip_maskr des_f.ip_maskr
    95 #define fp_maskl des_f.fp_maskl
    96 #define fp_maskr des_f.fp_maskr
    97 #define key_perm_maskl des_f.key_perm_maskl
    98 #define key_perm_maskr des_f.key_perm_maskr
    99 #define comp_maskl des_f.comp_maskl
    100 #define comp_maskr des_f.comp_maskr
     93} des4_f;
     94
     95#define inv_key_perm des1_f.inv_key_perm
     96#define inv_comp_perm des1_f.inv_comp_perm
     97#define u_sbox des1_f.u_sbox
     98#define un_pbox des1_f.un_pbox
     99#define ip_maskl des2_f.ip_maskl
     100#define ip_maskr des2_f.ip_maskr
     101#define fp_maskl des3_f.fp_maskl
     102#define fp_maskr des3_f.fp_maskr
     103#define key_perm_maskl des4_f.key_perm_maskl
     104#define key_perm_maskr des4_f.key_perm_maskr
     105#define comp_maskl des4_f.comp_maskl
     106#define comp_maskr des4_f.comp_maskr
    101107
    102108/* These need to be maintained per-process */
     
    838844des_snap(void **pf, void **pd)
    839845{
    840   *pf = malloc(sizeof(struct fixed));
    841   memcpy(*pf, &des_f, sizeof(des_f));
     846  uint8* pfc;
     847  *pf = malloc(sizeof(struct fixed1) + sizeof(struct fixed2) + sizeof(struct fixed3) + sizeof(struct fixed4));
     848  pfc = *pf;
     849  memcpy(pfc, &des1_f, sizeof(des1_f));
     850  pfc += sizeof(des1_f);
     851  memcpy(pfc, &des2_f, sizeof(des2_f));
     852  pfc += sizeof(des2_f);
     853  memcpy(pfc, &des3_f, sizeof(des3_f));
     854  pfc += sizeof(des3_f);
     855  memcpy(pfc, &des4_f, sizeof(des4_f));
    842856//      *pd = malloc(sizeof(struct Des_Context));
    843857//      memcpy(*pd, &des_ctx, sizeof(des_ctx));
     
    847861des_check(void *pf, void *pd)
    848862{
     863  uint8* pfc1, pfc2, pfc3, pfc4;
     864  pfc1 = pf;
     865  pfc2 = pfc1 + sizeof(des1_f);
     866  pfc3 = pfc2 + sizeof(des2_f);
     867  pfc4 = pfc3 + sizeof(des3_f);
    849868  printf("Fixed: do%s differ"/*", Context: do%s differ"*/"\n",
    850       memcmp(pf, &des_f, sizeof(des_f)) ? "" : "nt"
    851 //                      ,memcmp(pd, &des_ctx, sizeof(des_ctx)) ? "" : "nt"
    852       );
     869         (memcmp(pfc1, &des1_f, sizeof(des1_f)) ||
     870          memcmp(pfc2, &des2_f, sizeof(des2_f)) ||
     871          memcmp(pfc3, &des4_f, sizeof(des3_f)) ||
     872          memcmp(pfc4, &des4_f, sizeof(des4_f))) ? "" : "nt");
    853873}
    854874
Note: See TracChangeset for help on using the changeset viewer.