From 4333392a4befb5039c665477af1ba5dc88c17b2b Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 17 Feb 2004 23:53:44 +0000 Subject: [PATCH] * f_tables.h (DES_DO_ENCRYPT, DES_DO_DECRYPT): Allocate temporary variable locally instead of taking the extra argument. * d3_cbc.c (krb5int_des3_cbc_encrypt): Don't pass the extra argument, and delete the automatic variable. (krb5int_des3_cbc_decrypt): Likewise. * f_cbc.c (krb5int_des_cbc_encrypt, krb5int_des_cbc_decrypt): Likewise. * f_cksum.c (mit_des_cbc_cksum): Likewise. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16095 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/des/ChangeLog | 9 +++++++++ src/lib/crypto/des/d3_cbc.c | 14 ++++++-------- src/lib/crypto/des/f_cbc.c | 6 ++---- src/lib/crypto/des/f_cksum.c | 3 +-- src/lib/crypto/des/f_tables.h | 22 ++++++++++++---------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/lib/crypto/des/ChangeLog b/src/lib/crypto/des/ChangeLog index ae28fa253..0e469642d 100644 --- a/src/lib/crypto/des/ChangeLog +++ b/src/lib/crypto/des/ChangeLog @@ -1,5 +1,14 @@ 2004-02-17 Ken Raeburn + * f_tables.h (DES_DO_ENCRYPT, DES_DO_DECRYPT): Allocate temporary + variable locally instead of taking the extra argument. + * d3_cbc.c (krb5int_des3_cbc_encrypt): Don't pass the extra + argument, and delete the automatic variable. + (krb5int_des3_cbc_decrypt): Likewise. + * f_cbc.c (krb5int_des_cbc_encrypt, krb5int_des_cbc_decrypt): + Likewise. + * f_cksum.c (mit_des_cbc_cksum): Likewise. + * afsstring2key.c (krb5_afs_encrypt): Drop EDFLAG as an argument, make it local instead, since we always pass 0. (afs_crypt): Call changed. diff --git a/src/lib/crypto/des/d3_cbc.c b/src/lib/crypto/des/d3_cbc.c index abef25737..c49c6eafb 100644 --- a/src/lib/crypto/des/d3_cbc.c +++ b/src/lib/crypto/des/d3_cbc.c @@ -54,7 +54,6 @@ krb5int_des3_cbc_encrypt(const mit_des_cblock *in, const mit_des_cblock ivec) { register unsigned DES_INT32 left, right; - register unsigned DES_INT32 temp; const unsigned DES_INT32 *kp1, *kp2, *kp3; const unsigned char *ip; unsigned char *op; @@ -119,9 +118,9 @@ krb5int_des3_cbc_encrypt(const mit_des_cblock *in, /* * Encrypt what we have */ - DES_DO_ENCRYPT(left, right, temp, kp1); - DES_DO_DECRYPT(left, right, temp, kp2); - DES_DO_ENCRYPT(left, right, temp, kp3); + DES_DO_ENCRYPT(left, right, kp1); + DES_DO_DECRYPT(left, right, kp2); + DES_DO_ENCRYPT(left, right, kp3); /* * Copy the results out @@ -141,7 +140,6 @@ krb5int_des3_cbc_decrypt(const mit_des_cblock *in, const mit_des_cblock ivec) { register unsigned DES_INT32 left, right; - register unsigned DES_INT32 temp; const unsigned DES_INT32 *kp1, *kp2, *kp3; const unsigned char *ip; unsigned char *op; @@ -189,9 +187,9 @@ krb5int_des3_cbc_decrypt(const mit_des_cblock *in, /* * Decrypt this. */ - DES_DO_DECRYPT(left, right, temp, kp3); - DES_DO_ENCRYPT(left, right, temp, kp2); - DES_DO_DECRYPT(left, right, temp, kp1); + DES_DO_DECRYPT(left, right, kp3); + DES_DO_ENCRYPT(left, right, kp2); + DES_DO_DECRYPT(left, right, kp1); /* * Xor with the old cipher to get plain diff --git a/src/lib/crypto/des/f_cbc.c b/src/lib/crypto/des/f_cbc.c index dea27e702..aa15fefed 100644 --- a/src/lib/crypto/des/f_cbc.c +++ b/src/lib/crypto/des/f_cbc.c @@ -66,7 +66,6 @@ krb5int_des_cbc_encrypt(const mit_des_cblock *in, const mit_des_cblock ivec) { register unsigned DES_INT32 left, right; - register unsigned DES_INT32 temp; const unsigned DES_INT32 *kp; const unsigned char *ip; unsigned char *op; @@ -136,7 +135,7 @@ krb5int_des_cbc_encrypt(const mit_des_cblock *in, /* * Encrypt what we have */ - DES_DO_ENCRYPT(left, right, temp, kp); + DES_DO_ENCRYPT(left, right, kp); /* * Copy the results out @@ -154,7 +153,6 @@ krb5int_des_cbc_decrypt(const mit_des_cblock *in, const mit_des_cblock ivec) { register unsigned DES_INT32 left, right; - register unsigned DES_INT32 temp; const unsigned DES_INT32 *kp; const unsigned char *ip; unsigned char *op; @@ -200,7 +198,7 @@ krb5int_des_cbc_decrypt(const mit_des_cblock *in, /* * Decrypt this. */ - DES_DO_DECRYPT(left, right, temp, kp); + DES_DO_DECRYPT(left, right, kp); /* * Xor with the old cipher to get plain diff --git a/src/lib/crypto/des/f_cksum.c b/src/lib/crypto/des/f_cksum.c index 8c80751de..781a1f4fa 100644 --- a/src/lib/crypto/des/f_cksum.c +++ b/src/lib/crypto/des/f_cksum.c @@ -37,7 +37,6 @@ mit_des_cbc_cksum(in, out, length, schedule, ivec) const krb5_octet *ivec; { register unsigned DES_INT32 left, right; - register unsigned DES_INT32 temp; const unsigned DES_INT32 *kp; const unsigned char *ip; unsigned char *op; @@ -104,7 +103,7 @@ mit_des_cbc_cksum(in, out, length, schedule, ivec) * Encrypt what we have */ kp = (const unsigned DES_INT32 *)schedule; - DES_DO_ENCRYPT(left, right, temp, kp); + DES_DO_ENCRYPT(left, right, kp); } /* diff --git a/src/lib/crypto/des/f_tables.h b/src/lib/crypto/des/f_tables.h index a8b477d4d..5d49fc6d9 100644 --- a/src/lib/crypto/des/f_tables.h +++ b/src/lib/crypto/des/f_tables.h @@ -200,33 +200,35 @@ extern const unsigned DES_INT32 des_SP_table[8][64]; * 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, temp, kp) \ +#define DES_DO_ENCRYPT(left, right, kp) \ do { \ register int i; \ + register unsigned DES_INT32 temp1; \ DEB (("do_encrypt %8lX %8lX \n", left, right)); \ - DES_INITIAL_PERM((left), (right), (temp)); \ + DES_INITIAL_PERM((left), (right), (temp1)); \ DEB ((" after IP %8lX %8lX\n", left, right)); \ for (i = 0; i < 8; i++) { \ - DES_SP_ENCRYPT_ROUND((left), (right), (temp), (kp)); \ + DES_SP_ENCRYPT_ROUND((left), (right), (temp1), (kp)); \ DEB ((" round %2d %8lX %8lX \n", i*2, left, right)); \ - DES_SP_ENCRYPT_ROUND((right), (left), (temp), (kp)); \ + DES_SP_ENCRYPT_ROUND((right), (left), (temp1), (kp)); \ DEB ((" round %2d %8lX %8lX \n", 1+i*2, left, right)); \ } \ - DES_FINAL_PERM((left), (right), (temp)); \ + DES_FINAL_PERM((left), (right), (temp1)); \ (kp) -= (2 * 16); \ DEB ((" after FP %8lX %8lX \n", left, right)); \ } while (0) -#define DES_DO_DECRYPT(left, right, temp, kp) \ +#define DES_DO_DECRYPT(left, right, kp) \ do { \ register int i; \ - DES_INITIAL_PERM((left), (right), (temp)); \ + register unsigned DES_INT32 temp2; \ + DES_INITIAL_PERM((left), (right), (temp2)); \ (kp) += (2 * 16); \ for (i = 0; i < 8; i++) { \ - DES_SP_DECRYPT_ROUND((left), (right), (temp), (kp)); \ - DES_SP_DECRYPT_ROUND((right), (left), (temp), (kp)); \ + DES_SP_DECRYPT_ROUND((left), (right), (temp2), (kp)); \ + DES_SP_DECRYPT_ROUND((right), (left), (temp2), (kp)); \ } \ - DES_FINAL_PERM((left), (right), (temp)); \ + DES_FINAL_PERM((left), (right), (temp2)); \ } while (0) /* -- 2.26.2