From: Ken Raeburn Date: Tue, 10 Apr 2001 07:35:55 +0000 (+0000) Subject: use const for some inputs (when practical) without changing api X-Git-Tag: krb5-1.3-alpha1~1582 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6b0fe1f1a05b5445cbb68d3f873d02ee9ac47ef6;p=krb5.git use const for some inputs (when practical) without changing api git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13164 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/crypto/des/ChangeLog b/src/lib/crypto/des/ChangeLog index 148160182..c157d4811 100644 --- a/src/lib/crypto/des/ChangeLog +++ b/src/lib/crypto/des/ChangeLog @@ -1,5 +1,12 @@ 2001-04-10 Ken Raeburn + * f_cksum.c (mit_des_cbc_cksum): Use const for input, key + schedule, and initial vector. + * f_cbc.c (mit_des_cbc_encrypt): Likewise. + * des_int.h (mit_des_cbc_cksum, mit_des_cbc_encrypt): Update + decls. + (mit_des_string_to_key_int): New decl. + * des_int.h (des_cblock, des_key_schedule): Duplicate definitions here and in kerberosIV/des.h, using macro KRB5INT_DES_TYPES_DEFINED to avoid duplication. diff --git a/src/lib/crypto/des/des_int.h b/src/lib/crypto/des/des_int.h index 166353da5..01d840d0d 100644 --- a/src/lib/crypto/des/des_int.h +++ b/src/lib/crypto/des/des_int.h @@ -152,19 +152,19 @@ extern krb5_error_code mit_afs_string_to_key /* f_cksum.c */ extern unsigned long mit_des_cbc_cksum - (krb5_octet FAR *, krb5_octet FAR *, unsigned long , mit_des_key_schedule , - krb5_octet FAR *); + (const krb5_octet FAR *, krb5_octet FAR *, unsigned long , + const mit_des_key_schedule, const krb5_octet FAR *); /* f_ecb.c */ extern int mit_des_ecb_encrypt (const mit_des_cblock FAR *, mit_des_cblock FAR *, mit_des_key_schedule , int ); /* f_cbc.c */ -extern int mit_des_cbc_encrypt - (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); +extern int mit_des_cbc_encrypt (const mit_des_cblock FAR *in, + mit_des_cblock FAR *out, + unsigned long length, + const mit_des_key_schedule schedule, + const mit_des_cblock ivec, int encrypt); /* fin_rndkey.c */ extern krb5_error_code mit_des_finish_random_key @@ -202,6 +202,8 @@ extern krb5_error_code mit_des_random_key extern krb5_error_code mit_des_string_to_key ( const krb5_encrypt_block FAR *, krb5_keyblock FAR *, const krb5_data FAR *, const krb5_data FAR *); +extern krb5_error_code mit_des_string_to_key_int + (krb5_keyblock FAR *, const krb5_data FAR *, const krb5_data FAR *); /* weak_key.c */ extern int mit_des_is_weak_key (mit_des_cblock ); diff --git a/src/lib/crypto/des/f_cbc.c b/src/lib/crypto/des/f_cbc.c index cf81929e7..fdc125016 100644 --- a/src/lib/crypto/des/f_cbc.c +++ b/src/lib/crypto/des/f_cbc.c @@ -41,19 +41,20 @@ mit_des_cbc_encrypt(in, out, length, schedule, ivec, encrypt) const mit_des_cblock FAR *in; mit_des_cblock FAR *out; unsigned long length; - mit_des_key_schedule schedule; - mit_des_cblock ivec; + const mit_des_key_schedule schedule; + const mit_des_cblock ivec; int encrypt; { register unsigned DES_INT32 left, right; register unsigned DES_INT32 temp; - register unsigned DES_INT32 *kp; - register unsigned char *ip, *op; + const unsigned DES_INT32 *kp; + const unsigned char *ip; + unsigned char *op; /* * Get key pointer here. This won't need to be reinitialized */ - kp = (unsigned DES_INT32 *)schedule; + kp = (const unsigned DES_INT32 *)schedule; /* * Deal with encryption and decryption separately. @@ -63,7 +64,7 @@ mit_des_cbc_encrypt(in, out, length, schedule, ivec, encrypt) * Initialize left and right with the contents of the initial * vector. */ - ip = (unsigned char *)ivec; + ip = (const unsigned char *)ivec; GET_HALF_BLOCK(left, ip); GET_HALF_BLOCK(right, ip); @@ -142,7 +143,7 @@ mit_des_cbc_encrypt(in, out, length, schedule, ivec, encrypt) /* * Prime the old cipher with ivec. */ - ip = (unsigned char *)ivec; + ip = (const unsigned char *)ivec; GET_HALF_BLOCK(ocipherl, ip); GET_HALF_BLOCK(ocipherr, ip); diff --git a/src/lib/crypto/des/f_cksum.c b/src/lib/crypto/des/f_cksum.c index fab39ede3..4fe971123 100644 --- a/src/lib/crypto/des/f_cksum.c +++ b/src/lib/crypto/des/f_cksum.c @@ -30,23 +30,24 @@ unsigned long mit_des_cbc_cksum(in, out, length, schedule, ivec) - krb5_octet FAR *in; + const krb5_octet FAR *in; krb5_octet FAR *out; unsigned long length; - mit_des_key_schedule schedule; - krb5_octet FAR *ivec; + const mit_des_key_schedule schedule; + const krb5_octet FAR *ivec; { register unsigned DES_INT32 left, right; register unsigned DES_INT32 temp; - register unsigned DES_INT32 *kp; - register unsigned char *ip; + const unsigned DES_INT32 *kp; + const unsigned char *ip; + unsigned char *op; register DES_INT32 len; /* * Initialize left and right with the contents of the initial * vector. */ - ip = (unsigned char *)ivec; + ip = (const unsigned char *)ivec; GET_HALF_BLOCK(left, ip); GET_HALF_BLOCK(right, ip); @@ -54,7 +55,7 @@ mit_des_cbc_cksum(in, out, length, schedule, ivec) * Suitably initialized, now work the length down 8 bytes * at a time. */ - ip = (unsigned char *)in; + ip = (const unsigned char *)in; len = length; while (len > 0) { /* @@ -102,7 +103,7 @@ mit_des_cbc_cksum(in, out, length, schedule, ivec) /* * Encrypt what we have */ - kp = (unsigned DES_INT32 *)schedule; + kp = (const unsigned DES_INT32 *)schedule; DES_DO_ENCRYPT(left, right, temp, kp); } @@ -110,9 +111,9 @@ mit_des_cbc_cksum(in, out, length, schedule, ivec) * Done. Left and right have the checksum. Put it into * the output. */ - ip = (unsigned char *)out; - PUT_HALF_BLOCK(left, ip); - PUT_HALF_BLOCK(right, ip); + op = (unsigned char *)out; + PUT_HALF_BLOCK(left, op); + PUT_HALF_BLOCK(right, op); /* * Return right. I'll bet the MIT code returns this