* d3_cbc.c (krb5int_des3_cbc_encrypt, krb5int_des3_cbc_decrypt): Don't declare
left and right variables as registers.
* f_cksum.c (mit_des_cbc_cksum): Likewise.
* f_cbc.c (krb5int_des_cbc_encrypt, krb5int_des_cbc_decrypt): Likewise.
(krb5int_des_cbc_encrypt): For full blocks, use GET_HALF_BLOCK to read and then
xor, instead of processing each byte individually.
(krb5int_des_do_encrypt_2, krb5int_des_do_decrypt_2) [CONFIG_SMALL]: New
functions, wrapping large macros with the DES inner loops.
* f_tables.h (DES_DO_ENCRYPT_1, DES_DO_DECRYPT_1): Renamed from non-_1 names.
(krb5int_des_do_encrypt_2, krb5int_des_do_decrypt_2): Declare if CONFIG_SMALL
is defined.
(DES_DO_ENCRYPT, DES_DO_DECRYPT): Expand to _1 macros or _2 function calls
depending on whether CONFIG_SMALL is defined.
With CONFIG_SMALL defined, on x86/gcc/glibc, this drops about 5K (25%) of the
code/table space.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17183
dc483132-0cff-0310-8789-
dd5450dbe970
+2005-04-13 Ken Raeburn <raeburn@mit.edu>
+
+ * d3_cbc.c (krb5int_des3_cbc_encrypt, krb5int_des3_cbc_decrypt):
+ Don't declare left and right variables as registers.
+ * f_cksum.c (mit_des_cbc_cksum): Likewise.
+ * f_cbc.c (krb5int_des_cbc_encrypt, krb5int_des_cbc_decrypt):
+ Likewise.
+ (krb5int_des_cbc_encrypt): For full blocks, use GET_HALF_BLOCK to
+ read and then xor, instead of processing each byte individually.
+ (krb5int_des_do_encrypt_2, krb5int_des_do_decrypt_2)
+ [CONFIG_SMALL]: New functions, wrapping large macros with the DES
+ inner loops.
+ * f_tables.h (DES_DO_ENCRYPT_1, DES_DO_DECRYPT_1): Renamed from
+ non-_1 names.
+ (krb5int_des_do_encrypt_2, krb5int_des_do_decrypt_2): Declare if
+ CONFIG_SMALL is defined.
+ (DES_DO_ENCRYPT, DES_DO_DECRYPT): Expand to _1 macros or _2
+ function calls depending on whether CONFIG_SMALL is defined.
+
2004-05-13 Ken Raeburn <raeburn@mit.edu>
* Makefile.in (verify, t_afss2k): Link test programs against
const mit_des_key_schedule ks3,
const mit_des_cblock ivec)
{
- register unsigned DES_INT32 left, right;
+ unsigned DES_INT32 left, right;
const unsigned DES_INT32 *kp1, *kp2, *kp3;
const unsigned char *ip;
unsigned char *op;
const mit_des_key_schedule ks3,
const mit_des_cblock ivec)
{
- register unsigned DES_INT32 left, right;
+ unsigned DES_INT32 left, right;
const unsigned DES_INT32 *kp1, *kp2, *kp3;
const unsigned char *ip;
unsigned char *op;
const mit_des_key_schedule schedule,
const mit_des_cblock ivec)
{
- register unsigned DES_INT32 left, right;
+ unsigned DES_INT32 left, right;
const unsigned DES_INT32 *kp;
const unsigned char *ip;
unsigned char *op;
* forward. Otherwise we have to fart around.
*/
if (length >= 8) {
- left ^= ((*ip++) & FF_UINT32) << 24;
- left ^= ((*ip++) & FF_UINT32) << 16;
- left ^= ((*ip++) & FF_UINT32) << 8;
- left ^= (*ip++) & FF_UINT32;
- right ^= ((*ip++) & FF_UINT32) << 24;
- right ^= ((*ip++) & FF_UINT32) << 16;
- right ^= ((*ip++) & FF_UINT32) << 8;
- right ^= (*ip++) & FF_UINT32;
+ unsigned DES_INT32 temp;
+ GET_HALF_BLOCK(temp, ip);
+ left ^= temp;
+ GET_HALF_BLOCK(temp, ip);
+ right ^= temp;
length -= 8;
} else {
/*
const mit_des_key_schedule schedule,
const mit_des_cblock ivec)
{
- register unsigned DES_INT32 left, right;
+ unsigned DES_INT32 left, right;
const unsigned DES_INT32 *kp;
const unsigned char *ip;
unsigned char *op;
}
}
}
+
+#ifdef CONFIG_SMALL
+void krb5int_des_do_encrypt_2 (unsigned DES_INT32 *left,
+ unsigned DES_INT32 *right,
+ const unsigned DES_INT32 *kp)
+{
+ DES_DO_ENCRYPT_1 (*left, *right, kp);
+}
+
+void krb5int_des_do_decrypt_2 (unsigned DES_INT32 *left,
+ unsigned DES_INT32 *right,
+ const unsigned DES_INT32 *kp)
+{
+ DES_DO_DECRYPT_1 (*left, *right, kp);
+}
+#endif
unsigned long length, const mit_des_key_schedule schedule,
const krb5_octet *ivec)
{
- register unsigned DES_INT32 left, right;
+ unsigned DES_INT32 left, right;
const unsigned DES_INT32 *kp;
const unsigned char *ip;
unsigned char *op;
* at each stage of the encryption, so that by comparing the output to
* a known good machine, the location of the first error can be found.
*/
-#define DES_DO_ENCRYPT(left, right, kp) \
+#define DES_DO_ENCRYPT_1(left, right, kp) \
do { \
register int i; \
register unsigned DES_INT32 temp1; \
DEB ((" after FP %8lX %8lX \n", left, right)); \
} while (0)
-#define DES_DO_DECRYPT(left, right, kp) \
+#define DES_DO_DECRYPT_1(left, right, kp) \
do { \
register int i; \
register unsigned DES_INT32 temp2; \
DES_FINAL_PERM((left), (right), (temp2)); \
} while (0)
+#ifdef CONFIG_SMALL
+extern void krb5int_des_do_encrypt_2(unsigned DES_INT32 *l,
+ unsigned DES_INT32 *r,
+ const unsigned DES_INT32 *k);
+extern void krb5int_des_do_decrypt_2(unsigned DES_INT32 *l,
+ unsigned DES_INT32 *r,
+ const unsigned DES_INT32 *k);
+#define DES_DO_ENCRYPT(L,R,K) krb5int_des_do_encrypt_2(&(L), &(R), (K))
+#define DES_DO_DECRYPT(L,R,K) krb5int_des_do_decrypt_2(&(L), &(R), (K))
+#else
+#define DES_DO_ENCRYPT DES_DO_ENCRYPT_1
+#define DES_DO_DECRYPT DES_DO_DECRYPT_1
+#endif
+
/*
* These are handy dandy utility thingies for straightening out bytes.
* Included here because they're used a couple of places.