From: John Kohl Date: Thu, 17 May 1990 17:00:46 +0000 (+0000) Subject: name/prototype cleanup X-Git-Tag: krb5-1.0-alpha2~523 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b8e2a1d770bb8131ba08c7ea39df16480d4670a7;p=krb5.git name/prototype cleanup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@882 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/crypto/des/cbc_cksum.c b/src/lib/crypto/des/cbc_cksum.c index a0fc70368..6bb8ef9eb 100644 --- a/src/lib/crypto/des/cbc_cksum.c +++ b/src/lib/crypto/des/cbc_cksum.c @@ -30,10 +30,7 @@ static char des_cbc_checksum_c[] = #include #include -#include - -extern void des_cbc_cksum(); -extern int des_key_sched(); +#include "des_int.h" /* produces cbc cheksum of sequence "in" of the length "in_length" @@ -56,19 +53,19 @@ OLDDECLARG(krb5_pointer, key) OLDDECLARG(size_t, key_size) OLDDECLARG(krb5_checksum *, cksum) { - struct des_ks_struct *schedule; /* pointer to key schedules */ + struct mit_des_ks_struct *schedule; /* pointer to key schedules */ krb5_octet *contents; - if (key_size != sizeof(des_cblock)) + if (key_size != sizeof(mit_des_cblock)) return KRB5_BAD_KEYSIZE; - if (!(schedule = (struct des_ks_struct *) malloc(sizeof(des_key_schedule)))) + if (!(schedule = (struct mit_des_ks_struct *) malloc(sizeof(mit_des_key_schedule)))) return ENOMEM; -#define cleanup() { bzero((char *)schedule, sizeof(des_key_schedule));\ +#define cleanup() { bzero((char *)schedule, sizeof(mit_des_key_schedule));\ free( (char *) schedule); } - switch (des_key_sched ((krb5_octet *)key, schedule)) { + switch (mit_des_key_sched ((krb5_octet *)key, schedule)) { case -1: cleanup(); return KRB5DES_BAD_KEYPAR; /* XXX error code-bad key parity */ @@ -81,16 +78,16 @@ OLDDECLARG(krb5_checksum *, cksum) ; } - if (!(contents = (krb5_octet *) malloc(sizeof(des_cblock)))) { + if (!(contents = (krb5_octet *) malloc(sizeof(mit_des_cblock)))) { cleanup(); return ENOMEM; } - des_cbc_cksum((krb5_octet *)in, contents, in_length, + mit_des_cbc_cksum((krb5_octet *)in, contents, in_length, schedule, (krb5_octet *)key); cksum->checksum_type = CKSUMTYPE_DESCBC; - cksum->length = sizeof(des_cblock); + cksum->length = sizeof(mit_des_cblock); cksum->contents = contents; cleanup(); diff --git a/src/lib/crypto/des/cksum.c b/src/lib/crypto/des/cksum.c index a22494463..15952cdc0 100644 --- a/src/lib/crypto/des/cksum.c +++ b/src/lib/crypto/des/cksum.c @@ -30,12 +30,9 @@ static char rcsid_cksum_c[] = #include #include -#include -#include "des_internal.h" +#include "des_int.h" -extern int des_debug; -extern int des_debug_print(); -extern int des_ecb_encrypt(); +extern int mit_des_debug; /* * This routine performs DES cipher-block-chaining checksum operation, @@ -53,11 +50,11 @@ extern int des_ecb_encrypt(); */ void -des_cbc_cksum(in,out,length,key,iv) +mit_des_cbc_cksum(in,out,length,key,iv) krb5_octet *in; /* >= length bytes of inputtext */ krb5_octet *out; /* >= length bytes of outputtext */ register long length; /* in bytes */ - des_key_schedule key; /* precomputed key schedule */ + mit_des_key_schedule key; /* precomputed key schedule */ krb5_octet *iv; /* 8 bytes of ivec */ { register unsigned long *input = (unsigned long *) in; @@ -102,18 +99,18 @@ des_cbc_cksum(in,out,length,key,iv) *(t_in_p+j)= 0; #ifdef DEBUG - if (des_debug) - des_debug_print("clear",length,t_input[0],t_input[1]); + if (mit_des_debug) + mit_des_debug_print("clear",length,t_input[0],t_input[1]); #endif /* do the xor for cbc into the temp */ t_input[0] ^= t_output[0] ; t_input[1] ^= t_output[1] ; /* encrypt */ - (void) des_ecb_encrypt(t_input,t_output,key,1); + (void) mit_des_ecb_encrypt(t_input,t_output,key,1); #ifdef DEBUG - if (des_debug) { - des_debug_print("xor'ed",i,t_input[0],t_input[1]); - des_debug_print("cipher",i,t_output[0],t_output[1]); + if (mit_des_debug) { + mit_des_debug_print("xor'ed",i,t_input[0],t_input[1]); + mit_des_debug_print("cipher",i,t_output[0],t_output[1]); } #else #ifdef lint diff --git a/src/lib/crypto/des/cs_entry.c b/src/lib/crypto/des/cs_entry.c index d3038a716..cce44ade8 100644 --- a/src/lib/crypto/des/cs_entry.c +++ b/src/lib/crypto/des/cs_entry.c @@ -18,7 +18,7 @@ static char rcsid_des_cs_ent_c[] = #include #include -#include +#include extern krb5_error_code mit_des_encrypt_func PROTOTYPE((const krb5_pointer, krb5_pointer, @@ -53,9 +53,9 @@ krb5_cryptosystem_entry mit_des_cryptosystem_entry = { mit_des_init_random_key, mit_des_finish_random_key, mit_des_random_key, - sizeof(des_cblock), + sizeof(mit_des_cblock), 0, - sizeof(des_cblock), + sizeof(mit_des_cblock), ETYPE_DES_CBC_CRC, KEYTYPE_DES }; @@ -71,7 +71,7 @@ extern krb5_error_code mit_des_cbc_checksum PROTOTYPE ((krb5_pointer , krb5_checksum * )); -krb5_checksum_entry des_cbc_cksumtable_entry = { +krb5_checksum_entry mit_des_cbc_cksumtable_entry = { mit_des_cbc_checksum, - sizeof(des_cblock) + sizeof(mit_des_cblock) }; diff --git a/src/lib/crypto/des/des.c b/src/lib/crypto/des/des.c index 73e529ddf..d24fbb66f 100644 --- a/src/lib/crypto/des/des.c +++ b/src/lib/crypto/des/des.c @@ -43,29 +43,26 @@ static char rcsid_des_c[] = #include #include -#include -#include "des_internal.h" +#include "des_int.h" #include "s_table.h" #include "p_table.h" #ifdef DEBUG -#define DBG_PRINT(s) if (des_debug & 2) \ - des_debug_print(s,i,L1&0xffff,(L1>>16)&0xffff, \ +#define DBG_PRINT(s) if (mit_des_debug & 2) \ + mit_des_debug_print(s,i,L1&0xffff,(L1>>16)&0xffff, \ R1&0xffff,(R1>>16)&0xffff) #else #define DBG_PRINT(s) #endif -extern int des_debug; -extern des_cblock_print_file (); -extern des_debug_print (); +extern int mit_des_debug; int -des_ecb_encrypt(clear, cipher, schedule, encrypt) +mit_des_ecb_encrypt(clear, cipher, schedule, encrypt) unsigned long *clear; unsigned long *cipher; int encrypt; /* 0 ==> decrypt, else encrypt */ - register des_key_schedule schedule; /* r11 */ + register mit_des_key_schedule schedule; /* r11 */ { /* better pass 8 bytes, length not checked here */ @@ -132,14 +129,14 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) } #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { printf("All values printed from low byte (bit 0)"); printf(" --> high byte (bit 63)\n"); i = 0; dbg_tmp[0] = L1; dbg_tmp[1] = R1; printf("iter = %2d before IP\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } DBG_PRINT("before IP"); @@ -157,11 +154,11 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) for (i = 0; i <= (AUTH_DES_ITER-1); i++) { #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { dbg_tmp[0] = L1; dbg_tmp[1] = R1; printf("iter = %2d start loop\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); DBG_PRINT("start loop"); } @@ -221,12 +218,12 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) R1 = R2; #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { dbg_tmp[0] = L1; dbg_tmp[1] = R1; DBG_PRINT("after e"); printf("iter = %2d after e\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } #endif @@ -253,12 +250,12 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) /* dont have to reset input to L1, R1 */ #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { dbg_tmp[0] = L1; dbg_tmp[1] = R1; DBG_PRINT("after xor"); printf("iter = %2d after xor\n\t\tL1 R1 =",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } #endif @@ -364,12 +361,12 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) #endif #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { dbg_tmp[0] = L1; dbg_tmp[1] = R1; DBG_PRINT("after s"); printf("iter = %2d after s\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } #endif @@ -380,12 +377,12 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) R1 = R2; #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { dbg_tmp[0] = L1; dbg_tmp[1] = R1; DBG_PRINT("after p"); printf("iter = %2d after p\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } #endif @@ -406,12 +403,12 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) R1 = R2; #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { dbg_tmp[0] = L1; dbg_tmp[1] = R1; DBG_PRINT("before FP"); printf("iter = %2d before FP\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } #endif @@ -440,14 +437,14 @@ des_ecb_encrypt(clear, cipher, schedule, encrypt) } #ifdef DEBUG - if (des_debug & 2) { + if (mit_des_debug & 2) { L1 = L2; R1 = R2; dbg_tmp[0] = L1; dbg_tmp[1] = R1; DBG_PRINT("done"); printf("iter = %2d done\n\t\tL1 R1 = ",i); - des_cblock_print_file (dbg_tmp, stdout); + mit_des_cblock_print_file (dbg_tmp, stdout); } #endif diff --git a/src/lib/crypto/des/des_int.h b/src/lib/crypto/des/des_int.h index a995080bd..0f5ada1d5 100644 --- a/src/lib/crypto/des/des_int.h +++ b/src/lib/crypto/des/des_int.h @@ -17,6 +17,7 @@ #include #include +#include /* * number of iterations of the inner @@ -93,72 +94,90 @@ typedef struct { /* cbc_cksum.c */ -krb5_error_code mit_des_cbc_checksum +extern krb5_error_code mit_des_cbc_checksum PROTOTYPE((krb5_pointer, size_t,krb5_pointer,size_t, krb5_checksum * )); /* cksum.c */ -void mit_des_cbc_cksum +extern void mit_des_cbc_cksum PROTOTYPE((krb5_octet *, krb5_octet *, long , mit_des_key_schedule , krb5_octet *)); /* des.c */ -int des_ecb_encrypt - PROTOTYPE((unsigned long *, unsigned long *, des_key_schedule , int )); +extern int mit_des_ecb_encrypt + PROTOTYPE((unsigned long *, unsigned long *, mit_des_key_schedule , int )); /* enc_dec.c */ -krb5_error_code mit_des_encrypt_func +extern krb5_error_code mit_des_encrypt_func PROTOTYPE(( krb5_pointer, krb5_pointer, size_t, krb5_encrypt_block *, krb5_pointer )); -krb5_error_code mit_des_decrypt_func +extern krb5_error_code mit_des_decrypt_func PROTOTYPE(( krb5_pointer, krb5_pointer, size_t, krb5_encrypt_block *, krb5_pointer )); -krb5_error_code mit_des_cbc_encrypt +extern krb5_error_code mit_des_cbc_encrypt PROTOTYPE((krb5_octet *, krb5_octet *, long, mit_des_key_schedule, krb5_octet *, int)); /* fin_rndkey.c */ -krb5_error_code mit_des_finish_random_key +extern krb5_error_code mit_des_finish_random_key PROTOTYPE(( krb5_pointer *)); /* finish_key.c */ -krb5_error_code mit_des_finish_key +extern krb5_error_code mit_des_finish_key PROTOTYPE(( krb5_encrypt_block *)); /* init_rkey.c */ -krb5_error_code mit_des_init_random_key +extern krb5_error_code mit_des_init_random_key PROTOTYPE(( krb5_keyblock *, krb5_pointer *)); /* key_parity.c */ -void mit_des_fixup_key_parity PROTOTYPE((mit_des_cblock )); -int mit_des_check_key_parity PROTOTYPE((mit_des_cblock )); +extern void mit_des_fixup_key_parity PROTOTYPE((mit_des_cblock )); +extern int mit_des_check_key_parity PROTOTYPE((mit_des_cblock )); /* key_sched.c */ -int mit_des_key_sched PROTOTYPE((mit_des_cblock , mit_des_key_schedule )); +extern int mit_des_key_sched + PROTOTYPE((mit_des_cblock , mit_des_key_schedule )); /* new_rnd_key.c */ -int mit_des_new_random_key PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *)); -void mit_des_init_random_number_generator - PROTOTYPE((mit_des_cblock, mit_des_random_key_seed)); -void mit_des_set_random_generator_seed +extern int mit_des_new_random_key PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *)); -void mit_des_set_sequence_number +extern void mit_des_init_random_number_generator + PROTOTYPE((mit_des_cblock, mit_des_random_key_seed *)); +extern void mit_des_set_random_generator_seed PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *)); -void mit_des_generate_random_block +extern void mit_des_set_sequence_number + PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *)); +extern void mit_des_generate_random_block PROTOTYPE((mit_des_cblock , mit_des_random_key_seed *)); /* process_ky.c */ -krb5_error_code mit_des_process_key +extern krb5_error_code mit_des_process_key PROTOTYPE(( krb5_encrypt_block *, krb5_keyblock *)); /* random_key.c */ -krb5_error_code mit_des_random_key +extern krb5_error_code mit_des_random_key PROTOTYPE(( krb5_pointer , krb5_keyblock **)); /* string2key.c */ -krb5_error_code mit_des_string_to_key +extern krb5_error_code mit_des_string_to_key PROTOTYPE((krb5_keytype, krb5_keyblock *, krb5_data *, krb5_principal )); /* weak_key.c */ -int mit_des_is_weak_key PROTOTYPE((mit_des_cblock )); +extern int mit_des_is_weak_key PROTOTYPE((mit_des_cblock )); + +/* misc.c */ +extern void swap_bits PROTOTYPE((char *)); +extern unsigned long long_swap_bits PROTOTYPE((unsigned long )); +extern unsigned long swap_six_bits_to_ansi PROTOTYPE((unsigned long )); +extern unsigned long swap_four_bits_to_ansi PROTOTYPE((unsigned long )); +extern unsigned long swap_bit_pos_1 PROTOTYPE((unsigned long )); +extern unsigned long swap_bit_pos_0 PROTOTYPE((unsigned long )); +extern unsigned long swap_bit_pos_0_to_ansi PROTOTYPE((unsigned long )); +extern unsigned long rev_swap_bit_pos_0 PROTOTYPE((unsigned long )); +extern unsigned long swap_byte_bits PROTOTYPE((unsigned long )); +extern unsigned long swap_long_bytes_bit_number PROTOTYPE((unsigned long )); +#ifdef FILE +/* XXX */ +extern void test_set PROTOTYPE((FILE *, const char *, int, const char *, int)); +#endif #undef P #endif /*DES_INTERNAL_DEFS*/ diff --git a/src/lib/crypto/des/enc_dec.c b/src/lib/crypto/des/enc_dec.c index 1fd47b151..9e6666328 100644 --- a/src/lib/crypto/des/enc_dec.c +++ b/src/lib/crypto/des/enc_dec.c @@ -35,13 +35,12 @@ static char des_enc_dec_c[] = #include #include -#include +#include "des_int.h" #ifdef DEBUG #include -extern int des_debug; -extern int des_debug_print(); +extern int mit_des_debug; #endif @@ -67,7 +66,6 @@ OLDDECLARG(size_t, size) OLDDECLARG(krb5_encrypt_block *, key) OLDDECLARG(krb5_pointer, ivec) { - krb5_error_code des_cbc_encrypt(); krb5_octet *iv; if ( ivec == 0 ) @@ -76,12 +74,12 @@ OLDDECLARG(krb5_pointer, ivec) iv = (krb5_octet *)ivec; /* XXX should check that key sched is valid here? */ - return (des_cbc_encrypt((krb5_octet *)in, + return (mit_des_cbc_encrypt((krb5_octet *)in, (krb5_octet *)out, size, - (struct des_ks_struct *)key->priv, + (struct mit_des_ks_struct *)key->priv, iv, - DES_ENCRYPT)); + MIT_DES_ENCRYPT)); } /* @@ -108,7 +106,6 @@ OLDDECLARG(size_t, size) OLDDECLARG(krb5_encrypt_block *, key) OLDDECLARG(krb5_pointer, ivec) { - krb5_error_code des_cbc_encrypt(); krb5_octet *iv; if ( ivec == 0 ) @@ -117,12 +114,12 @@ OLDDECLARG(krb5_pointer, ivec) iv = (krb5_octet *)ivec; /* XXX should check that key sched is valid here? */ - return (des_cbc_encrypt ((krb5_octet *)in, + return (mit_des_cbc_encrypt ((krb5_octet *)in, (krb5_octet *)out, size, - (struct des_ks_struct *)key->priv, + (struct mit_des_ks_struct *)key->priv, iv, - DES_DECRYPT)); + MIT_DES_DECRYPT)); } /* * This routine performs DES cipher-block-chaining operation, either @@ -144,15 +141,15 @@ OLDDECLARG(krb5_pointer, ivec) */ krb5_error_code -des_cbc_encrypt(in,out,length,key,iv,encrypt) +mit_des_cbc_encrypt(in,out,length,key,iv,encrypt) krb5_octet *in; /* >= length bytes of input text */ krb5_octet *out; /* >= length bytes of output text */ register long length; /* in bytes */ - int encrypt; /* 0 ==> decrypt, else encrypt */ - des_key_schedule key; /* precomputed key schedule */ + mit_des_key_schedule key; /* precomputed key schedule */ krb5_octet *iv; /* 8 bytes of ivec */ + int encrypt; /* 0 ==> decrypt, else encrypt */ { - int des_ecb_encrypt(); + int mit_des_ecb_encrypt(); register unsigned long *input = (unsigned long *) in; register unsigned long *output = (unsigned long *) out; @@ -198,14 +195,14 @@ des_cbc_encrypt(in,out,length,key,iv,encrypt) *(t_in_p+j)= 0; #ifdef DEBUG - if (des_debug) - des_debug_print("clear",length,t_input[0],t_input[1]); + if (mit_des_debug) + mit_des_debug_print("clear",length,t_input[0],t_input[1]); #endif /* do the xor for cbc into the temp */ t_input[0] ^= t_output[0]; t_input[1] ^= t_output[1]; /* encrypt */ - (void) des_ecb_encrypt(t_input,t_output,key,encrypt); + (void) mit_des_ecb_encrypt(t_input,t_output,key,encrypt); /* copy temp output and save it for cbc */ #ifdef MUSTALIGN if ((long) output & 3) { @@ -222,9 +219,9 @@ des_cbc_encrypt(in,out,length,key,iv,encrypt) } #ifdef DEBUG - if (des_debug) { - des_debug_print("xor'ed",i,t_input[0],t_input[1]); - des_debug_print("cipher",i,t_output[0],t_output[1]); + if (mit_des_debug) { + mit_des_debug_print("xor'ed",i,t_input[0],t_input[1]); + mit_des_debug_print("cipher",i,t_output[0],t_output[1]); } #endif } @@ -261,18 +258,18 @@ des_cbc_encrypt(in,out,length,key,iv,encrypt) /* no padding for decrypt */ #ifdef DEBUG - if (des_debug) - des_debug_print("cipher",i,t_input[0],t_input[1]); + if (mit_des_debug) + mit_des_debug_print("cipher",i,t_input[0],t_input[1]); #else #ifdef lint i = i; #endif #endif /* encrypt */ - (void) des_ecb_encrypt(t_input,t_output,key,encrypt); + (void) mit_des_ecb_encrypt(t_input,t_output,key,encrypt); #ifdef DEBUG - if (des_debug) - des_debug_print("out pre xor",i,t_output[0],t_output[1]); + if (mit_des_debug) + mit_des_debug_print("out pre xor",i,t_output[0],t_output[1]); #endif /* do the xor for cbc into the output */ t_output[0] ^= xor_0; @@ -296,8 +293,8 @@ des_cbc_encrypt(in,out,length,key,iv,encrypt) xor_0 = t_input[0]; xor_1 = t_input[1]; #ifdef DEBUG - if (des_debug) - des_debug_print("clear",i,t_output[0],t_output[1]); + if (mit_des_debug) + mit_des_debug_print("clear",i,t_output[0],t_output[1]); #endif } return 0; diff --git a/src/lib/crypto/des/fin_rndkey.c b/src/lib/crypto/des/fin_rndkey.c index 28dfe9e6e..b70792314 100644 --- a/src/lib/crypto/des/fin_rndkey.c +++ b/src/lib/crypto/des/fin_rndkey.c @@ -19,7 +19,7 @@ static char des_fnr_key_c[] = #include #include -#include +#include #include /* @@ -29,7 +29,7 @@ static char des_fnr_key_c[] = krb5_error_code mit_des_finish_random_key (DECLARG(krb5_pointer *, seed)) OLDDECLARG(krb5_pointer *, seed) { - bzero( (char *)*seed, sizeof(des_random_key_seed) ); + bzero( (char *)*seed, sizeof(mit_des_random_key_seed) ); free((char *)*seed); *seed = 0; return 0; /* XXX init_random_key */ diff --git a/src/lib/crypto/des/finish_key.c b/src/lib/crypto/des/finish_key.c index bbaa82010..338688e9f 100644 --- a/src/lib/crypto/des/finish_key.c +++ b/src/lib/crypto/des/finish_key.c @@ -21,7 +21,7 @@ static char des_fin_key_c[] = #include #include -#include +#include /* does any necessary clean-up on the eblock (such as releasing @@ -33,7 +33,7 @@ static char des_fin_key_c[] = krb5_error_code mit_des_finish_key (DECLARG(krb5_encrypt_block *,eblock)) OLDDECLARG(krb5_encrypt_block *,eblock) { - bzero((char *)eblock->priv, sizeof(des_key_schedule)); + bzero((char *)eblock->priv, sizeof(mit_des_key_schedule)); free(eblock->priv); eblock->priv = 0; /* free/clear other stuff here? */ diff --git a/src/lib/crypto/des/init_rkey.c b/src/lib/crypto/des/init_rkey.c index 21324cf03..8094222b6 100644 --- a/src/lib/crypto/des/init_rkey.c +++ b/src/lib/crypto/des/init_rkey.c @@ -19,11 +19,10 @@ static char des_inr_key_c[] = #include #include -#include #include #include -extern void des_init_random_number_generator(); +#include "des_int.h" /* initialize the random key generator using the encryption key, @@ -38,14 +37,14 @@ krb5_error_code mit_des_init_random_key (DECLARG(krb5_keyblock *,seedblock), OLDDECLARG(krb5_keyblock *,seedblock) OLDDECLARG(krb5_pointer *,seed) { - des_random_key_seed * p_seed; + mit_des_random_key_seed * p_seed; if (seedblock->keytype != KEYTYPE_DES) return KRB5_BAD_KEYTYPE; /* XXX error code bad keytype */ - if ( !(p_seed = (des_random_key_seed *) - malloc(sizeof(des_random_key_seed))) ) + if ( !(p_seed = (mit_des_random_key_seed *) + malloc(sizeof(mit_des_random_key_seed))) ) return ENOMEM; - bzero( (char *)p_seed, sizeof(des_random_key_seed) ); - des_init_random_number_generator(seedblock->contents, p_seed); + bzero( (char *)p_seed, sizeof(mit_des_random_key_seed) ); + mit_des_init_random_number_generator(seedblock->contents, p_seed); *seed = (krb5_pointer) p_seed; return 0; } diff --git a/src/lib/crypto/des/key_parity.c b/src/lib/crypto/des/key_parity.c index a6db13b10..62d2f4971 100644 --- a/src/lib/crypto/des/key_parity.c +++ b/src/lib/crypto/des/key_parity.c @@ -24,8 +24,7 @@ static char key_parity_c[] = #include #include -#include -#include "des_internal.h" +#include "des_int.h" #include "odd.h" /* Load compile-time generated odd_parity table */ @@ -35,12 +34,12 @@ static char key_parity_c[] = * vax order. */ void -des_fixup_key_parity(key) - register des_cblock key; +mit_des_fixup_key_parity(key) + register mit_des_cblock key; { int i; - for (i=0; i -#include "des_internal.h" #include #include -#include +#include "des_int.h" #include "key_perm.h" -extern int des_debug; -extern rev_swap_bit_pos_0(); -extern int des_check_key_parity(); -extern int des_is_weak_key(); +extern int mit_des_debug; typedef char key[64]; /* the following are really void but cc86 doesnt allow it */ -void make_key_sched(); - +static void make_key_sched PROTOTYPE((key, mit_des_key_schedule)); int -des_key_sched(k,schedule) - register des_cblock k; /* r11 */ - des_key_schedule schedule; +mit_des_key_sched(k,schedule) + register mit_des_cblock k; /* r11 */ + mit_des_key_schedule schedule; { /* better pass 8 bytes, length not checked here */ @@ -72,17 +67,17 @@ des_key_sched(k,schedule) n = n; /* fool it in case of VAXASM */ #endif #ifdef DEBUG - if (des_debug) + if (mit_des_debug) fprintf(stderr,"\n\ninput key, left to right = "); #endif - if (!des_check_key_parity(k)) /* bad parity --> return -1 */ + if (!mit_des_check_key_parity(k)) /* bad parity --> return -1 */ return(-1); do { /* get next input key byte */ #ifdef DEBUG - if (des_debug) + if (mit_des_debug) fprintf(stderr,"%02x ",*k & 0xff); #endif temp = (unsigned int) ((unsigned char) *k++); @@ -100,7 +95,7 @@ des_key_sched(k,schedule) } while (--i > 0); #ifdef DEBUG - if (des_debug) { + if (mit_des_debug) { p_char = k_char; fprintf(stderr,"\nKey bits, from zero to 63"); for (i = 0; i <= 7; i++) { @@ -116,9 +111,9 @@ des_key_sched(k,schedule) #endif /* check against weak keys */ - k -= sizeof(des_cblock); + k -= sizeof(mit_des_cblock); - if (des_is_weak_key(k)) + if (mit_des_is_weak_key(k)) return(-2); make_key_sched(k_char,schedule); @@ -130,7 +125,7 @@ des_key_sched(k,schedule) static void make_key_sched(Key,Schedule) register key Key; /* r11 */ - des_key_schedule Schedule; + mit_des_key_schedule Schedule; { /* * The key has been converted to an array to make this run faster; @@ -235,7 +230,7 @@ make_key_sched(Key,Schedule) } while (--iter > 0); #ifdef DEBUG - if (des_debug) { + if (mit_des_debug) { char *n; int q; fprintf(stderr,"\nKey Schedule, left to right"); diff --git a/src/lib/crypto/des/make_e.c b/src/lib/crypto/des/make_e.c index 5db85ee13..032eff291 100644 --- a/src/lib/crypto/des/make_e.c +++ b/src/lib/crypto/des/make_e.c @@ -12,7 +12,8 @@ */ #include -#include "des_internal.h" +#include +#include "des_int.h" #include "tables.h" void gen(stream) diff --git a/src/lib/crypto/des/make_fp.c b/src/lib/crypto/des/make_fp.c index 7e19bd081..0bfb8a56d 100644 --- a/src/lib/crypto/des/make_fp.c +++ b/src/lib/crypto/des/make_fp.c @@ -15,15 +15,9 @@ #include #include #include -#include "des_internal.h" +#include "des_int.h" #include "tables.h" -extern unsigned int swap_bit_pos_0_to_ansi PROTOTYPE((unsigned int)); -extern long swap_long_bytes(); -extern unsigned long swap_long_bytes_bit_number(); -extern void test_set PROTOTYPE((FILE *, char const *, int, - char const *, int)); - void gen (stream) FILE * stream; { diff --git a/src/lib/crypto/des/make_ip.c b/src/lib/crypto/des/make_ip.c index 54e927c50..40cb7e77d 100644 --- a/src/lib/crypto/des/make_ip.c +++ b/src/lib/crypto/des/make_ip.c @@ -13,14 +13,10 @@ #include #include -#include "des_internal.h" +#include +#include "des_int.h" #include "tables.h" -extern long swap_bit_pos_0(); -extern long rev_swap_bit_pos_0(); -extern void test_set(); -extern unsigned long swap_long_bytes_bit_number(); -unsigned long swap_bit_pos_0_to_ansi(); #define SWAP(x) swap_long_bytes_bit_number(swap_bit_pos_0_to_ansi(x)) diff --git a/src/lib/crypto/des/make_kp.c b/src/lib/crypto/des/make_kp.c index 18c334215..dc337fa24 100644 --- a/src/lib/crypto/des/make_kp.c +++ b/src/lib/crypto/des/make_kp.c @@ -19,7 +19,8 @@ #include #include #include -#include "des_internal.h" +#include +#include "des_int.h" #ifndef lint static char rcsid[]= @@ -27,10 +28,7 @@ static char rcsid[]= #endif /* lint */ char *progname; -extern char *errmsg(); extern int errno; -extern long swap_bit_pos_1(); -extern long swap_bit_pos_0(); int sflag; int vflag; int dflag; @@ -91,7 +89,7 @@ int pc_2[48+1] = { 0, int ks_perm[16+1][48+1]; -int des_debug; +int mit_des_debug; void gen(stream) FILE *stream; @@ -125,7 +123,7 @@ void gen(stream) * start at iter = 1, not zero. */ for (iter = 1; iter <= 16; iter++) { - if (des_debug) { + if (mit_des_debug) { /* for debugging */ printf( "/* DEBUG-- start iteration = %d shifts = %d", @@ -159,7 +157,7 @@ void gen(stream) } - if (des_debug) { + if (mit_des_debug) { /* for debugging */ printf("/* DEBUG:\n"); printf(" * after shifts, iteration = %d shifts = %d", diff --git a/src/lib/crypto/des/make_p.c b/src/lib/crypto/des/make_p.c index becac62f3..65b809000 100644 --- a/src/lib/crypto/des/make_p.c +++ b/src/lib/crypto/des/make_p.c @@ -12,7 +12,8 @@ #include #include -#include "des_internal.h" +#include +#include "des_int.h" #include "tables.h" void gen(stream) diff --git a/src/lib/crypto/des/make_pt.c b/src/lib/crypto/des/make_pt.c index 2d8787b76..f0c2a10c3 100644 --- a/src/lib/crypto/des/make_pt.c +++ b/src/lib/crypto/des/make_pt.c @@ -11,11 +11,10 @@ #include #include -#include "des_internal.h" +#include +#include "des_int.h" #include "tables.h" -extern unsigned long swap_byte_bits(); -extern unsigned long rev_swap_bit_pos_0(); static unsigned char P_temp[32]; static unsigned long P_prime[4][256]; diff --git a/src/lib/crypto/des/make_s.c b/src/lib/crypto/des/make_s.c index 1e1781702..e4c42caca 100644 --- a/src/lib/crypto/des/make_s.c +++ b/src/lib/crypto/des/make_s.c @@ -10,7 +10,8 @@ #include #include -#include "des_internal.h" +#include +#include "des_int.h" #include "s_table.h" void gen(stream) diff --git a/src/lib/crypto/des/make_st.c b/src/lib/crypto/des/make_st.c index 78601e03d..f267e0607 100644 --- a/src/lib/crypto/des/make_st.c +++ b/src/lib/crypto/des/make_st.c @@ -10,14 +10,12 @@ #include #include -#include "des_internal.h" +#include +#include "des_int.h" #include "tables.h" -extern unsigned long swap_bit_pos_0(); -extern unsigned long swap_six_bits_to_ansi(); -extern unsigned long swap_four_bits_to_ansi(); char temp[8][64]; -int des_debug; +int mit_des_debug; void gen(stream) FILE *stream; @@ -45,7 +43,7 @@ void gen(stream) m = S[i][l]; /* restore in host order */ n = swap_four_bits_to_ansi(m); - if (des_debug) + if (mit_des_debug) fprintf(stderr, "i = %d, j = %d, k = %d, l = %d, m = %d, n = %d\n", i,j,k,l,m,n); diff --git a/src/lib/crypto/des/misc.c b/src/lib/crypto/des/misc.c index a7add4c66..c596f82eb 100644 --- a/src/lib/crypto/des/misc.c +++ b/src/lib/crypto/des/misc.c @@ -19,8 +19,7 @@ #include #include -#include -#include "des_internal.h" +#include "des_int.h" /* * The DES algorithm is defined in terms of MSBFIRST, so sometimes, @@ -131,7 +130,7 @@ unsigned long swap_bit_pos_1(x) */ register y,z; - /* always do it, only used by des_make_key_perm.c so far */ + /* always do it, only used by mit_des_make_key_perm.c so far */ y = (x-1)/8; z = (x-1)%8; @@ -291,7 +290,7 @@ void test_set(stream, src, testbit, dest, setbit) } extern void gen PROTOTYPE((FILE *)); -int des_debug; +int mit_des_debug; char const *whoami; void @@ -310,7 +309,7 @@ main(argc, argv) arg = *argv; if (*arg == '-') { if (!strcmp(arg, "-d") && !strcmp(arg, "-debug")) - des_debug++; + mit_des_debug++; else { fprintf(stderr, "%s: unknown control argument %s\n", whoami, arg); diff --git a/src/lib/crypto/des/new_rn_key.c b/src/lib/crypto/des/new_rn_key.c index 437e88c9a..58f98fe72 100644 --- a/src/lib/crypto/des/new_rn_key.c +++ b/src/lib/crypto/des/new_rn_key.c @@ -24,41 +24,33 @@ static char new_rnd_key_c[] = #include #include -#include -#include "des_internal.h" - -extern void des_fixup_key_parity(); -extern int des_is_weak_key(); -extern int des_ecb_encrypt(); -extern int des_key_sched(); -void des_set_random_generator_seed(), des_set_sequence_number(); -void des_generate_random_block(); +#include "des_int.h" /* - * des_new_random_key: create a random des key + * mit_des_new_random_key: create a random des key * - * Requires: des_set_random_number_generater_seed must be at called least + * Requires: mit_des_set_random_number_generater_seed must be at called least * once before this routine is called. * * Notes: the returned key has correct parity and is guarenteed not - * to be a weak des key. Des_generate_random_block is used to + * to be a weak des key. Mit_Des_generate_random_block is used to * provide the random bits. */ int -des_new_random_key(key, p_seed) - des_cblock key; - des_random_key_seed *p_seed; +mit_des_new_random_key(key, p_seed) + mit_des_cblock key; + mit_des_random_key_seed *p_seed; { do { - des_generate_random_block(key, p_seed); - des_fixup_key_parity(key); - } while (des_is_weak_key(key)); + mit_des_generate_random_block(key, p_seed); + mit_des_fixup_key_parity(key); + } while (mit_des_is_weak_key(key)); return(0); } /* - * des_init_random_number_generator: + * mit_des_init_random_number_generator: * * This routine takes a secret key possibly shared by a number * of servers and uses it to generate a random number stream that is @@ -69,7 +61,7 @@ des_new_random_key(key, p_seed) * This routine is used for example, by the kerberos server(s) with the * key in question being the kerberos master key. * - * Note: this routine calls des_set_random_generator_seed. + * Note: this routine calls mit_des_set_random_generator_seed. */ #ifndef BSDUNIX you lose... (aka, you get to implement an analog of this for your @@ -78,18 +70,18 @@ des_new_random_key(key, p_seed) #include #include -extern long gethostid(); +extern long gethostid(); /* XXX */ -void des_init_random_number_generator(key,p_seed) - des_cblock key; - des_random_key_seed *p_seed; +void mit_des_init_random_number_generator(key,p_seed) + mit_des_cblock key; + mit_des_random_key_seed *p_seed; { struct { /* This must be 64 bits exactly */ long process_id; long host_id; } seed; struct timeval time; /* this must also be 64 bits exactly */ - des_cblock new_key; + mit_des_cblock new_key; /* * use a host id and process id in generating the seed to ensure @@ -102,28 +94,28 @@ void des_init_random_number_generator(key,p_seed) * Generate a tempory value that depends on the key, host_id, and * process_id such that it gives no useful information about the key: */ - des_set_random_generator_seed(key, p_seed); - des_set_sequence_number((unsigned char *)&seed, p_seed); - des_new_random_key(new_key, p_seed); + mit_des_set_random_generator_seed(key, p_seed); + mit_des_set_sequence_number((unsigned char *)&seed, p_seed); + mit_des_new_random_key(new_key, p_seed); /* * use it to select a random stream: */ - des_set_random_generator_seed(new_key, p_seed); + mit_des_set_random_generator_seed(new_key, p_seed); /* * use a time stamp to ensure that a server started later does not reuse * an old stream: */ gettimeofday(&time, (struct timezone *)0); - des_set_sequence_number((unsigned char *)&time, p_seed); + mit_des_set_sequence_number((unsigned char *)&time, p_seed); /* * use the time stamp finally to select the final seed using the * current random number stream: */ - des_new_random_key(new_key, p_seed); - des_set_random_generator_seed(new_key, p_seed); + mit_des_new_random_key(new_key, p_seed); + mit_des_set_random_generator_seed(new_key, p_seed); } #endif /* ifdef BSDUNIX */ @@ -135,7 +127,7 @@ void des_init_random_number_generator(key,p_seed) */ /* - * des_set_random_generator_seed: this routine is used to select a random + * mit_des_set_random_generator_seed: this routine is used to select a random * number stream. The stream that results is * totally determined by the passed in key. * (I.e., calling this routine again with the @@ -146,14 +138,14 @@ void des_init_random_number_generator(key,p_seed) * weak des key. */ void -des_set_random_generator_seed(key, p_seed) - des_cblock key; - des_random_key_seed *p_seed; +mit_des_set_random_generator_seed(key, p_seed) + mit_des_cblock key; + mit_des_random_key_seed *p_seed; { register int i; /* select the new stream: (note errors are not possible here...) */ - des_key_sched(key, p_seed->random_sequence_key); + mit_des_key_sched(key, p_seed->random_sequence_key); /* "seek" to the start of the stream: */ for (i=0; i<8; i++) @@ -161,40 +153,40 @@ des_set_random_generator_seed(key, p_seed) } /* - * des_set_sequence_number: this routine is used to set the sequence number + * mit_des_set_sequence_number: this routine is used to set the sequence number * of the current random number stream. This routine * may be used to "seek" within the current random * number stream. * - * Note that des_set_random_generator_seed resets the sequence number to 0. + * Note that mit_des_set_random_generator_seed resets the sequence number to 0. */ void -des_set_sequence_number(new_sequence_number, p_seed) - des_cblock new_sequence_number; - des_random_key_seed *p_seed; +mit_des_set_sequence_number(new_sequence_number, p_seed) + mit_des_cblock new_sequence_number; + mit_des_random_key_seed *p_seed; { bcopy((char *)new_sequence_number, (char *)p_seed->sequence_number, sizeof(p_seed->sequence_number)); } /* - * des_generate_random_block: routine to return the next random number + * mit_des_generate_random_block: routine to return the next random number * from the current random number stream. * The returned number is 64 bits long. * - * Requires: des_set_random_generator_seed must have been called at least once + * Requires: mit_des_set_random_generator_seed must have been called at least once * before this routine is called. */ -void des_generate_random_block(block, p_seed) - des_cblock block; - des_random_key_seed *p_seed; +void mit_des_generate_random_block(block, p_seed) + mit_des_cblock block; + mit_des_random_key_seed *p_seed; { int i; /* * Encrypt the sequence number to get the new random block: */ - des_ecb_encrypt((unsigned long *)p_seed->sequence_number, + mit_des_ecb_encrypt((unsigned long *)p_seed->sequence_number, (unsigned long *)block, p_seed->random_sequence_key, 1); diff --git a/src/lib/crypto/des/process_ky.c b/src/lib/crypto/des/process_ky.c index 51a2087a1..5060911f9 100644 --- a/src/lib/crypto/des/process_ky.c +++ b/src/lib/crypto/des/process_ky.c @@ -19,11 +19,11 @@ static char des_prc_key_c[] = #include #include -#include #include #include -extern int des_key_sched(); +#include "des_int.h" + /* does any necessary key preprocessing (such as computing key schedules for DES). @@ -43,16 +43,16 @@ krb5_error_code mit_des_process_key (DECLARG(krb5_encrypt_block *, eblock), OLDDECLARG(krb5_encrypt_block *, eblock) OLDDECLARG(krb5_keyblock *,keyblock) { - struct des_ks_struct *schedule; /* pointer to key schedules */ + struct mit_des_ks_struct *schedule; /* pointer to key schedules */ - if (keyblock->length != sizeof (des_cblock)) + if (keyblock->length != sizeof (mit_des_cblock)) return KRB5_BAD_KEYSIZE; /* XXX error code-bad key size */ - if ( !(schedule = (struct des_ks_struct *) malloc(sizeof(des_key_schedule))) ) + if ( !(schedule = (struct mit_des_ks_struct *) malloc(sizeof(mit_des_key_schedule))) ) return ENOMEM; #define cleanup() { free( (char *) schedule); } - switch (des_key_sched (keyblock->contents, schedule)) { + switch (mit_des_key_sched (keyblock->contents, schedule)) { case -1: cleanup(); return KRB5DES_BAD_KEYPAR; /* XXX error code-bad key parity */ diff --git a/src/lib/crypto/des/random_key.c b/src/lib/crypto/des/random_key.c index 76d76d739..84930d79a 100644 --- a/src/lib/crypto/des/random_key.c +++ b/src/lib/crypto/des/random_key.c @@ -19,11 +19,9 @@ static char des_ran_key_c[] = #include #include -#include #include -extern int des_new_random_key(); - +#include "des_int.h" /* generate a random encryption key, allocating storage for it and filling in the keyblock address in *keyblock @@ -38,13 +36,13 @@ OLDDECLARG(krb5_keyblock **, keyblock) if (!(randkey = (krb5_keyblock *)malloc(sizeof(*randkey)))) return ENOMEM; - if (!(randkey->contents = (krb5_octet *)malloc(sizeof(des_cblock)))) { + if (!(randkey->contents = (krb5_octet *)malloc(sizeof(mit_des_cblock)))) { free((char *)randkey); return ENOMEM; } - randkey->length = sizeof(des_cblock); + randkey->length = sizeof(mit_des_cblock); randkey->keytype = KEYTYPE_DES; - des_new_random_key(randkey->contents, (des_random_key_seed *) seed); + mit_des_new_random_key(randkey->contents, (mit_des_random_key_seed *) seed); *keyblock = randkey; return 0; } diff --git a/src/lib/crypto/des/string2key.c b/src/lib/crypto/des/string2key.c index f1de4f40a..d3732fd15 100644 --- a/src/lib/crypto/des/string2key.c +++ b/src/lib/crypto/des/string2key.c @@ -20,21 +20,16 @@ static char des_st2_key_c[] = #include #include -#include #include #include -#include "des_internal.h" +#include "des_int.h" #ifdef DEBUG #include extern int des_debug; -extern int des_debug_print(); #endif -extern void des_fixup_key_parity(); -extern int des_key_sched(); -extern void des_cbc_cksum(); /* converts the string pointed to by "data" into an encryption key of type "keytype". *keyblock is filled in with the key info; @@ -72,7 +67,7 @@ OLDDECLARG(krb5_principal, princ) static int forward; register char *p_char; static char k_char[64]; - static des_key_schedule key_sked; + static mit_des_key_schedule key_sked; #define min(A, B) ((A) < (B) ? (A): (B)) @@ -83,14 +78,14 @@ OLDDECLARG(krb5_principal, princ) if ( keytype != KEYTYPE_DES ) return (KRB5_PROG_KEYTYPE_NOSUPP); - if ( !(keyblock->contents = (krb5_octet *)malloc(sizeof(des_cblock))) ) + if ( !(keyblock->contents = (krb5_octet *)malloc(sizeof(mit_des_cblock))) ) return(ENOMEM); -#define cleanup() {bzero(keyblock->contents, sizeof(des_cblock));\ +#define cleanup() {bzero(keyblock->contents, sizeof(mit_des_cblock));\ (void) free((char *) keyblock->contents);} keyblock->keytype = KEYTYPE_DES; - keyblock->length = sizeof(des_cblock); + keyblock->length = sizeof(mit_des_cblock); key = keyblock->contents; bzero(copystr, sizeof(copystr)); (void) strncpy(copystr, data->data, min(data->length,511)); @@ -104,7 +99,7 @@ OLDDECLARG(krb5_principal, princ) bzero(k_char,sizeof(k_char)); #ifdef DEBUG - if (des_debug) + if (mit_des_debug) fprintf(stdout, "\n\ninput str length = %d string = %s\nstring = 0x ", length,str); @@ -115,7 +110,7 @@ OLDDECLARG(krb5_principal, princ) /* get next input key byte */ temp = (unsigned int) *str++; #ifdef DEBUG - if (des_debug) + if (mit_des_debug) fprintf(stdout,"%02x ",temp & 0xff); #endif /* loop through bits within byte, ignore parity */ @@ -132,7 +127,7 @@ OLDDECLARG(krb5_principal, princ) forward = !forward; } - /* now stuff into the key des_cblock, and force odd parity */ + /* now stuff into the key mit_des_cblock, and force odd parity */ p_char = k_char; k_p = (unsigned char *) key; @@ -144,19 +139,19 @@ OLDDECLARG(krb5_principal, princ) } /* fix key parity */ - des_fixup_key_parity(key); + mit_des_fixup_key_parity(key); /* Now one-way encrypt it with the folded key */ - (void) des_key_sched(key, key_sked); - (void) des_cbc_cksum((krb5_octet *)copystr, key, length, key_sked, key); + (void) mit_des_key_sched(key, key_sked); + (void) mit_des_cbc_cksum((krb5_octet *)copystr, key, length, key_sked, key); /* erase key_sked */ bzero((char *)key_sked, sizeof(key_sked)); /* now fix up key parity again */ - des_fixup_key_parity(key); + mit_des_fixup_key_parity(key); #ifdef DEBUG - if (des_debug) + if (mit_des_debug) fprintf(stdout, "\nResulting string_to_key = 0x%x 0x%x\n", *((unsigned long *) key), diff --git a/src/lib/crypto/des/verify.c b/src/lib/crypto/des/verify.c index 54ac58e61..464a09b96 100644 --- a/src/lib/crypto/des/verify.c +++ b/src/lib/crypto/des/verify.c @@ -24,22 +24,19 @@ static char rcsid_verify_c[] = #include #include #include -#include +#include #include +#include -extern void com_err(); extern int errno; extern krb5_cryptosystem_entry mit_des_cryptosystem_entry; -extern des_cbc_cksum(); -extern des_ecb_encrypt(); -extern exit(); char *progname; int nflag = 2; int vflag; int mflag; int zflag; int pid; -int des_debug; +int mit_des_debug; krb5_encrypt_block eblock; krb5_keyblock keyblock; @@ -59,7 +56,7 @@ unsigned char default_key[8] = { }; unsigned char key2[8] = { 0x08,0x19,0x2a,0x3b,0x4c,0x5d,0x6e,0x7f }; unsigned char key3[8] = { 0x80,1,1,1,1,1,1,1 }; -des_cblock s_key; +mit_des_cblock s_key; unsigned char default_ivec[8] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef }; @@ -97,7 +94,7 @@ main(argc,argv) /* debug flag */ case 'd': - des_debug=3; + mit_des_debug=3; continue; case 'z': @@ -125,7 +122,7 @@ main(argc,argv) eblock.crypto_entry = &mit_des_cryptosystem_entry; keyblock.keytype = KEYTYPE_DES; - keyblock.length = sizeof (des_cblock); + keyblock.length = sizeof (mit_des_cblock); /* use known input and key */ @@ -267,7 +264,7 @@ main(argc,argv) printf("\tchecksum\t58 d2 e7 7e 86 06 27 33, "); printf("or some part thereof\n"); input = clear_text2; - des_cbc_cksum(input,cipher_text,(long) strlen(input),eblock.priv,ivec,1); + mit_des_cbc_cksum(input,cipher_text,(long) strlen(input),eblock.priv,ivec,1); printf("ACTUAL CBC checksum\n"); printf("\t\tencrypted cksum = (low to high bytes)\n\t\t"); for (j = 0; j<=7; j++) @@ -308,8 +305,8 @@ do_encrypt(in,out) char *out; { for (i =1; i<=nflag; i++) { - des_ecb_encrypt(in,out,(struct des_ks_struct *)eblock.priv,1); - if (des_debug) { + mit_des_ecb_encrypt(in,out,(struct mit_des_ks_struct *)eblock.priv,1); + if (mit_des_debug) { printf("\nclear %s\n",in); for (j = 0; j<=7; j++) printf("%02 X ",in[j] & 0xff); @@ -327,8 +324,8 @@ do_decrypt(in,out) /* try to invert it */ { for (i =1; i<=nflag; i++) { - des_ecb_encrypt(out,in,(struct des_ks_struct *)eblock.priv,0); - if (des_debug) { + mit_des_ecb_encrypt(out,in,(struct mit_des_ks_struct *)eblock.priv,0); + if (mit_des_debug) { printf("clear %s\n",in); for (j = 0; j<=7; j++) printf("%02X ",in[j] & 0xff); diff --git a/src/lib/crypto/des/weak_key.c b/src/lib/crypto/des/weak_key.c index ffb9c64e4..5aa19d103 100644 --- a/src/lib/crypto/des/weak_key.c +++ b/src/lib/crypto/des/weak_key.c @@ -21,14 +21,13 @@ static char weak_key_c[] = #endif /* !lint & !SABER */ #include -#include #include -#include "des_internal.h" +#include "des_int.h" /* * The following are the weak DES keys: */ -static des_cblock weak[16] = { +static mit_des_cblock weak[16] = { /* weak keys */ {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, {0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe}, @@ -56,19 +55,19 @@ static des_cblock weak[16] = { }; /* - * des_is_weak_key: returns true iff key is a [semi-]weak des key. + * mit_des_is_weak_key: returns true iff key is a [semi-]weak des key. * * Requires: key has correct odd parity. */ int -des_is_weak_key(key) - des_cblock key; +mit_des_is_weak_key(key) + mit_des_cblock key; { int i; - des_cblock *weak_p = weak; + mit_des_cblock *weak_p = weak; - for (i = 0; i < (sizeof(weak)/sizeof(des_cblock)); i++) { - if (!bcmp((char *)weak_p++,(char *)key,sizeof(des_cblock))) + for (i = 0; i < (sizeof(weak)/sizeof(mit_des_cblock)); i++) { + if (!bcmp((char *)weak_p++,(char *)key,sizeof(mit_des_cblock))) return 1; }