use const for some inputs (when practical) without changing api
authorKen Raeburn <raeburn@mit.edu>
Tue, 10 Apr 2001 07:35:55 +0000 (07:35 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 10 Apr 2001 07:35:55 +0000 (07:35 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13164 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/des/ChangeLog
src/lib/crypto/des/des_int.h
src/lib/crypto/des/f_cbc.c
src/lib/crypto/des/f_cksum.c

index 148160182bc388c50ce8785f664cd1c3ebc4b2b6..c157d4811ff2b46ce39221cf2c6506a882e9f6b3 100644 (file)
@@ -1,5 +1,12 @@
 2001-04-10  Ken Raeburn  <raeburn@mit.edu>
 
+       * 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.
index 166353da520a3ebc38b4bae4893d91f4675e9702..01d840d0d3e80b9f3fef5e3d93ce11561e8dcc0b 100644 (file)
@@ -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 );
index cf81929e752f101248984277c6b0428b29695e3b..fdc12501692e9de33fe5519549aa202ee8781a25 100644 (file)
@@ -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);
 
index fab39ede385ee1f0d2573743d50399883124ef10..4fe97112387c9c7caf4f50e463e83a37247a6dc2 100644 (file)
 
 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