Change des_key_schedule to be an array of DES_LONG instead of abusing
struct and union semantics.
This commit is contained in:
parent
8fe92db798
commit
e1b2ea7ce9
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: des.h,v 1.4 2003/07/24 14:16:30 itojun Exp $ */
|
||||
/* $NetBSD: des.h,v 1.5 2006/03/19 19:35:00 christos Exp $ */
|
||||
|
||||
/* crypto/des/des.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
@ -77,6 +77,10 @@ typedef /* const */ unsigned char const_des_cblock[8];
|
||||
/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock *
|
||||
* and const_des_cblock * are incompatible pointer types. */
|
||||
|
||||
#define DES_KEY_SZ 8 /*(sizeof(des_cblock))*/
|
||||
#define DES_SCHEDULE_SZ 128 /*(sizeof(des_key_schedule))*/
|
||||
|
||||
#ifdef notdef
|
||||
typedef struct des_ks_struct
|
||||
{
|
||||
union {
|
||||
@ -89,9 +93,9 @@ typedef struct des_ks_struct
|
||||
int weak_key;
|
||||
#endif
|
||||
} des_key_schedule[16];
|
||||
|
||||
#define DES_KEY_SZ 8 /*(sizeof(des_cblock))*/
|
||||
#define DES_SCHEDULE_SZ 128 /*(sizeof(des_key_schedule))*/
|
||||
#else
|
||||
typedef DES_LONG des_key_schedule[DES_SCHEDULE_SZ / sizeof(DES_LONG)];
|
||||
#endif
|
||||
|
||||
#define DES_ENCRYPT 1
|
||||
#define DES_DECRYPT 0
|
||||
|
@ -84,7 +84,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
|
||||
r=ROTATE(r,29)&0xffffffffL;
|
||||
l=ROTATE(l,29)&0xffffffffL;
|
||||
|
||||
s=ks->ks.deslong;
|
||||
s=ks;
|
||||
/* I don't know if it is worth the effort of loop unrolling the
|
||||
* inner loop */
|
||||
if (enc)
|
||||
@ -180,7 +180,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
|
||||
r=ROTATE(r,29)&0xffffffffL;
|
||||
l=ROTATE(l,29)&0xffffffffL;
|
||||
|
||||
s=ks->ks.deslong;
|
||||
s=ks;
|
||||
/* I don't know if it is worth the effort of loop unrolling the
|
||||
* inner loop */
|
||||
if (enc)
|
||||
|
@ -342,7 +342,7 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule)
|
||||
register DES_LONG *k;
|
||||
register int i;
|
||||
|
||||
k = &schedule->ks.deslong[0];
|
||||
k = schedule;
|
||||
in = &(*key)[0];
|
||||
|
||||
c2l(in,c);
|
||||
|
Loading…
Reference in New Issue
Block a user