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.
/* 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
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 );
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.
* 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);
/*
* 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);
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);
* 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) {
/*
/*
* Encrypt what we have
*/
- kp = (unsigned DES_INT32 *)schedule;
+ kp = (const unsigned DES_INT32 *)schedule;
DES_DO_ENCRYPT(left, right, temp, kp);
}
* 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