summaryrefslogtreecommitdiffstats
path: root/src/lib/des425/str_to_key.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2001-04-10 02:47:42 +0000
committerKen Raeburn <raeburn@mit.edu>2001-04-10 02:47:42 +0000
commit9f6c7f0b8c26905fbc1b6d5cbb240fe6faeea778 (patch)
tree1166f14819db3580d9383453c686140bf6d50e09 /src/lib/des425/str_to_key.c
parente20674d9d3295ade4fa0525f6127ec69a67585ff (diff)
downloadkrb5-9f6c7f0b8c26905fbc1b6d5cbb240fe6faeea778.tar.gz
krb5-9f6c7f0b8c26905fbc1b6d5cbb240fe6faeea778.tar.xz
krb5-9f6c7f0b8c26905fbc1b6d5cbb240fe6faeea778.zip
* des425.h: Deleted to avoid confusion with the other des.h in the tree. All
files changed to include des_int.h and (the other) des.h instead. * new_rnd_key.c (des_init_random_number_generator): Cast seed data pointer to keep compiler happy. * read_passwd.c (intr_routine, des_read_pw_string): Add prototypes. (des_read_password): Fix call sequence for des_string_to_key. * str_to_key.c (des_string_to_key): Remove static storage in favor of automatic storage. Fix call sequence to des_key_sched. Delete no-op while loop. * t_quad.c (main): Fix call sequence for des_quad_cksum. * verify.c (des_string_to_key, des_key_sched, des_ecb_encrypt, des_cbc_encrypt): Removed declarations. (do_encrypt, do_decrypt): Prototype. Make args point to unsigned char, and return types void. (main): Declare return type. Make automatic var in_length be unsigned long; discard some casts, but cast it when passing to memcmp. Remove extra arg passed to des_cbc_cksum. (flip): Delete unused function. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13150 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/des425/str_to_key.c')
-rw-r--r--src/lib/des425/str_to_key.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/lib/des425/str_to_key.c b/src/lib/des425/str_to_key.c
index 7bf75fb8d7..4489471250 100644
--- a/src/lib/des425/str_to_key.c
+++ b/src/lib/des425/str_to_key.c
@@ -43,13 +43,23 @@
#include <stdio.h>
#include <string.h>
-#include "des425.h"
-/* #include "des_internal.h" */
+#include "des_int.h"
+#include "des.h"
extern int mit_des_debug;
/*
- * convert an arbitrary length string to a DES key
+ * Convert an arbitrary length string to a DES key.
+ */
+
+/*
+ * For krb5, a change was made to this algorithm: When each key is
+ * generated, after fixing parity, a check for weak and semi-weak keys
+ * is done. If the key is weak or semi-weak, we XOR the last byte
+ * with 0xF0. (In the case of the intermediate key, the weakness is
+ * probably irrelevant, but there it is.) The odds that this will
+ * generate a different key for a random input string are pretty low,
+ * but non-zero. So we need this different function for krb4 to use.
*/
KRB5_DLLIMP int KRB5_CALLCONV
des_string_to_key(str,key)
@@ -60,11 +70,11 @@ des_string_to_key(str,key)
register unsigned temp;
register int j;
register long i, length;
- static unsigned char *k_p;
- static int forward;
+ unsigned char *k_p;
+ int forward;
register char *p_char;
- static char k_char[64];
- static mit_des_key_schedule key_sked;
+ char k_char[64];
+ mit_des_key_schedule key_sked;
extern void des_cbc_cksum();
in_str = str;
@@ -97,7 +107,7 @@ des_string_to_key(str,key)
else
*--p_char ^= (int) temp & 01;
temp = temp >> 1;
- } while (--j > 0);
+ }
/* check and flip direction */
if ((i%8) == 0)
@@ -119,7 +129,7 @@ des_string_to_key(str,key)
des_fixup_key_parity(key);
/* Now one-way encrypt it with the folded key */
- (void) des_key_sched(key,key_sked);
+ (void) des_key_sched(key, *(Key_schedule *)&key_sked);
(void) des_cbc_cksum((des_cblock *)in_str,key,length,key_sked,key);
/* erase key_sked */
memset((char *)key_sked, 0,sizeof(key_sked));