2009-06-18 Chris Johns <chrisj@rtems.org>

* telnetd/des.c: Split the des_f struct into smaller parts so
        targets that cannot address large structs can be supported.
This commit is contained in:
Chris Johns
2009-06-17 22:29:52 +00:00
parent 73c421b8ff
commit c0075af37a
2 changed files with 44 additions and 19 deletions

View File

@@ -1,3 +1,8 @@
2009-06-18 Chris Johns <chrisj@rtems.org>
* telnetd/des.c: Split the des_f struct into smaller parts so
targets that cannot address large structs can be supported.
2009-06-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* score/src/objectshrinkinformation.c: Fix spelling error.

View File

@@ -75,29 +75,35 @@
* struct crypt_data to make this really reentrant... */
/* TS; not really - only the stuff in Des_Context */
static struct fixed {
static struct fixed1 {
u_char inv_key_perm[64];
u_char inv_comp_perm[56];
u_char u_sbox[8][64];
u_char un_pbox[32];
} des1_f;
static struct fixed2 {
u_int32_t ip_maskl[8][256], ip_maskr[8][256];
} des2_f;
static struct fixed3 {
u_int32_t fp_maskl[8][256], fp_maskr[8][256];
} des3_f;
static struct fixed4 {
u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
u_int32_t comp_maskl[8][128], comp_maskr[8][128];
} des_f;
} des4_f;
#define inv_key_perm des_f.inv_key_perm
#define inv_comp_perm des_f.inv_comp_perm
#define u_sbox des_f.u_sbox
#define un_pbox des_f.un_pbox
#define ip_maskl des_f.ip_maskl
#define ip_maskr des_f.ip_maskr
#define fp_maskl des_f.fp_maskl
#define fp_maskr des_f.fp_maskr
#define key_perm_maskl des_f.key_perm_maskl
#define key_perm_maskr des_f.key_perm_maskr
#define comp_maskl des_f.comp_maskl
#define comp_maskr des_f.comp_maskr
#define inv_key_perm des1_f.inv_key_perm
#define inv_comp_perm des1_f.inv_comp_perm
#define u_sbox des1_f.u_sbox
#define un_pbox des1_f.un_pbox
#define ip_maskl des2_f.ip_maskl
#define ip_maskr des2_f.ip_maskr
#define fp_maskl des3_f.fp_maskl
#define fp_maskr des3_f.fp_maskr
#define key_perm_maskl des4_f.key_perm_maskl
#define key_perm_maskr des4_f.key_perm_maskr
#define comp_maskl des4_f.comp_maskl
#define comp_maskr des4_f.comp_maskr
/* These need to be maintained per-process */
struct Des_Context {
@@ -837,8 +843,16 @@ __des_crypt(const char *key, const char *setting)
void
des_snap(void **pf, void **pd)
{
*pf = malloc(sizeof(struct fixed));
memcpy(*pf, &des_f, sizeof(des_f));
uint8* pfc;
*pf = malloc(sizeof(struct fixed1) + sizeof(struct fixed2) + sizeof(struct fixed3) + sizeof(struct fixed4));
pfc = *pf;
memcpy(pfc, &des1_f, sizeof(des1_f));
pfc += sizeof(des1_f);
memcpy(pfc, &des2_f, sizeof(des2_f));
pfc += sizeof(des2_f);
memcpy(pfc, &des3_f, sizeof(des3_f));
pfc += sizeof(des3_f);
memcpy(pfc, &des4_f, sizeof(des4_f));
// *pd = malloc(sizeof(struct Des_Context));
// memcpy(*pd, &des_ctx, sizeof(des_ctx));
}
@@ -846,10 +860,16 @@ des_snap(void **pf, void **pd)
void
des_check(void *pf, void *pd)
{
uint8* pfc1, pfc2, pfc3, pfc4;
pfc1 = pf;
pfc2 = pfc1 + sizeof(des1_f);
pfc3 = pfc2 + sizeof(des2_f);
pfc4 = pfc3 + sizeof(des3_f);
printf("Fixed: do%s differ"/*", Context: do%s differ"*/"\n",
memcmp(pf, &des_f, sizeof(des_f)) ? "" : "nt"
// ,memcmp(pd, &des_ctx, sizeof(des_ctx)) ? "" : "nt"
);
(memcmp(pfc1, &des1_f, sizeof(des1_f)) ||
memcmp(pfc2, &des2_f, sizeof(des2_f)) ||
memcmp(pfc3, &des4_f, sizeof(des3_f)) ||
memcmp(pfc4, &des4_f, sizeof(des4_f))) ? "" : "nt");
}
#endif