From a1453efdd2480cf6249795a41cd1a21579e2ada9 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Tue, 17 Oct 2000 22:57:34 +0000 Subject: [PATCH] * des_int.h: Change prototypes for mit_des_cbc_encrypt(), mit_des_cbc_cksum(), and mit_des3_cbc_encrypt() to take unsigned long lengths. * d3_cbc.c (mit_des3_cbc_encrypt): Length argument now takes an unsigned long. * f_cbc.c (mit_des_cbc_encrypt): Length argument now takes an unsigned long. * f_cksum.c (mit_des_cbc_cksum): Length argument now takes an unsigned long. * string2key.c: Unsigned/signed int cleanup. Test for a salt-length of SALT_TYPE_AFS_LENGTH or -1 (for backwards compatibilty) for use of mit_afs_string_to_key(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12774 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/des/ChangeLog | 19 +++++++++++++++++++ src/lib/crypto/des/afsstring2key.c | 4 ++-- src/lib/crypto/des/d3_cbc.c | 2 +- src/lib/crypto/des/des_int.h | 7 ++++--- src/lib/crypto/des/f_cbc.c | 2 +- src/lib/crypto/des/f_cksum.c | 2 +- src/lib/crypto/des/string2key.c | 8 ++++---- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/lib/crypto/des/ChangeLog b/src/lib/crypto/des/ChangeLog index b90324639..0dab08ced 100644 --- a/src/lib/crypto/des/ChangeLog +++ b/src/lib/crypto/des/ChangeLog @@ -1,3 +1,22 @@ +2000-10-17 Ezra Peisach + + * des_int.h: Change prototypes for mit_des_cbc_encrypt(), + mit_des_cbc_cksum(), and mit_des3_cbc_encrypt() to take unsigned + long lengths. + + * d3_cbc.c (mit_des3_cbc_encrypt): Length argument now takes an + unsigned long. + + * f_cbc.c (mit_des_cbc_encrypt): Length argument now takes an + unsigned long. + + * f_cksum.c (mit_des_cbc_cksum): Length argument now takes an + unsigned long. + + * string2key.c: Unsigned/signed int cleanup. Test for a + salt-length of SALT_TYPE_AFS_LENGTH or -1 (for backwards + compatibilty) for use of mit_afs_string_to_key(). + 2000-06-30 Ezra Peisach * afsstring2key.c: Initialization of S[8][64] - each 64 elements diff --git a/src/lib/crypto/des/afsstring2key.c b/src/lib/crypto/des/afsstring2key.c index 4cef28996..c993f0e7f 100644 --- a/src/lib/crypto/des/afsstring2key.c +++ b/src/lib/crypto/des/afsstring2key.c @@ -50,7 +50,7 @@ mit_afs_string_to_key (keyblock, data, salt) set up. */ char *realm = salt->data; - register int i; + register unsigned int i; register krb5_octet *key = keyblock->contents; if (data->length <= 8) { @@ -76,7 +76,7 @@ mit_afs_string_to_key (keyblock, data, salt) mit_des_cblock ikey, tkey; static mit_des_key_schedule key_sked; - int pw_len = strlen(realm)+data->length; + unsigned int pw_len = strlen(realm)+data->length; char *password = malloc(pw_len+1); if (!password) return ENOMEM; diff --git a/src/lib/crypto/des/d3_cbc.c b/src/lib/crypto/des/d3_cbc.c index 18e1f1d07..0204b719b 100644 --- a/src/lib/crypto/des/d3_cbc.c +++ b/src/lib/crypto/des/d3_cbc.c @@ -31,7 +31,7 @@ int mit_des3_cbc_encrypt(in, out, length, ks1, ks2, ks3, ivec, encrypt) const mit_des_cblock FAR *in; mit_des_cblock FAR *out; - long length; + unsigned long length; mit_des_key_schedule ks1, ks2, ks3; mit_des_cblock ivec; int encrypt; diff --git a/src/lib/crypto/des/des_int.h b/src/lib/crypto/des/des_int.h index de8f2a480..ec2047a25 100644 --- a/src/lib/crypto/des/des_int.h +++ b/src/lib/crypto/des/des_int.h @@ -147,7 +147,7 @@ extern krb5_error_code mit_afs_string_to_key /* f_cksum.c */ extern unsigned long mit_des_cbc_cksum - PROTOTYPE((krb5_octet FAR *, krb5_octet FAR *, long , mit_des_key_schedule , + PROTOTYPE((krb5_octet FAR *, krb5_octet FAR *, unsigned long , mit_des_key_schedule , krb5_octet FAR *)); /* f_ecb.c */ @@ -156,7 +156,8 @@ extern int mit_des_ecb_encrypt /* f_cbc.c */ extern int mit_des_cbc_encrypt - PROTOTYPE((const mit_des_cblock FAR *in, mit_des_cblock FAR *out, long length, + PROTOTYPE((const mit_des_cblock FAR *in, mit_des_cblock FAR *out, + unsigned long length, mit_des_key_schedule schedule, mit_des_cblock ivec, int encrypt)); @@ -241,7 +242,7 @@ extern int mit_des3_ecb_encrypt extern int mit_des3_cbc_encrypt PROTOTYPE((const mit_des_cblock FAR *in, mit_des_cblock FAR *out, - long length, + unsigned long length, mit_des_key_schedule ks1, mit_des_key_schedule ks2, mit_des_key_schedule ks3, diff --git a/src/lib/crypto/des/f_cbc.c b/src/lib/crypto/des/f_cbc.c index bc4e2afe7..cf81929e7 100644 --- a/src/lib/crypto/des/f_cbc.c +++ b/src/lib/crypto/des/f_cbc.c @@ -40,7 +40,7 @@ int mit_des_cbc_encrypt(in, out, length, schedule, ivec, encrypt) const mit_des_cblock FAR *in; mit_des_cblock FAR *out; - long length; + unsigned long length; mit_des_key_schedule schedule; mit_des_cblock ivec; int encrypt; diff --git a/src/lib/crypto/des/f_cksum.c b/src/lib/crypto/des/f_cksum.c index 5b1ba854e..fab39ede3 100644 --- a/src/lib/crypto/des/f_cksum.c +++ b/src/lib/crypto/des/f_cksum.c @@ -32,7 +32,7 @@ unsigned long mit_des_cbc_cksum(in, out, length, schedule, ivec) krb5_octet FAR *in; krb5_octet FAR *out; - long length; + unsigned long length; mit_des_key_schedule schedule; krb5_octet FAR *ivec; { diff --git a/src/lib/crypto/des/string2key.c b/src/lib/crypto/des/string2key.c index 5381fdbc9..45a8500ec 100644 --- a/src/lib/crypto/des/string2key.c +++ b/src/lib/crypto/des/string2key.c @@ -75,13 +75,13 @@ krb5_keyblock FAR * keyblock; const krb5_data FAR * data; const krb5_data FAR * salt; { - register char *str, *copystr; + register krb5_octet *str, *copystr; register krb5_octet *key; register unsigned temp; register long i; register int j; - register long length; + register unsigned long length; unsigned char *k_p; int forward; register char *p_char; @@ -97,7 +97,7 @@ const krb5_data FAR * salt; key = keyblock->contents; if (salt) { - if (salt->length == -1) { + if (salt->length == SALT_TYPE_AFS_LENGTH || salt->length == (unsigned) -1) { /* cheat and do AFS string2key instead */ return mit_afs_string_to_key (keyblock, data, salt); } else @@ -178,7 +178,7 @@ const krb5_data FAR * salt; memset((char *)key_sked, 0, sizeof(key_sked)); /* clean & free the input string */ - memset(copystr, 0, (size_t) length); + memset(copystr, 0, length); krb5_xfree(copystr); /* now fix up key parity again */ -- 2.26.2