From: Alexandra Ellwood Date: Thu, 6 Mar 2003 20:16:20 +0000 (+0000) Subject: * mac_des_glue.c, des.c, enc_dec.c, key_sched.c, str_to_key.c: Move KfM des function... X-Git-Tag: krb5-1.3-alpha1~27 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=49878953fe4e9d8066f980959c004dcdce75606c;p=krb5.git * mac_des_glue.c, des.c, enc_dec.c, key_sched.c, str_to_key.c: Move KfM des functions into their own file. They are all deprecated on KfM and shouldn't even get built on stock krb5 builds. * read_passwd.c: Added warning comment that des_read_pw_string is an exported function on KfM, so we should not change its ABI git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15250 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/des425/ChangeLog b/src/lib/des425/ChangeLog index cb2881b5e..acd4ea66e 100644 --- a/src/lib/des425/ChangeLog +++ b/src/lib/des425/ChangeLog @@ -1,3 +1,12 @@ +2003-03-06 Alexandra Ellwood + + * mac_des_glue.c, des.c, enc_dec.c, key_sched.c, str_to_key.c: + Move KfM des functions into their own file. They are all + deprecated on KfM and shouldn't even get built on stock krb5 builds. + + * read_passwd.c: Added warning comment that des_read_pw_string + is an exported function on KfM, so we should not change its ABI. + 2003-02-10 Tom Yu * str_to_key.c (afs_string_to_key): Move out from under diff --git a/src/lib/des425/des.c b/src/lib/des425/des.c index df636d238..27245bb36 100644 --- a/src/lib/des425/des.c +++ b/src/lib/des425/des.c @@ -41,15 +41,3 @@ des_ecb_encrypt(clear, cipher, schedule, enc) return (mit_des_cbc_encrypt((const des_cblock *)clear, cipher, 8, schedule, iv, enc)); } - -#if TARGET_OS_MAC -void -des_3ecb_encrypt(des_cblock *clear, des_cblock *cipher, - des_key_schedule ks1, des_key_schedule ks2, - des_key_schedule ks3, int enc) -{ - static const des_cblock iv; - - mit_des3_cbc_encrypt((const des_cblock *)clear, cipher, 8, ks1, ks2, ks3, iv, enc); -} -#endif diff --git a/src/lib/des425/enc_dec.c b/src/lib/des425/enc_dec.c index a25b744f6..69e4a57cb 100644 --- a/src/lib/des425/enc_dec.c +++ b/src/lib/des425/enc_dec.c @@ -44,15 +44,3 @@ des_cbc_encrypt(in,out,length,key,iv,enc) (const unsigned char *)iv, /* YUCK! */ enc)); } - -#if TARGET_OS_MAC -void des_3cbc_encrypt(des_cblock *in, des_cblock *out, long length, - des_key_schedule ks1, des_key_schedule ks2, - des_key_schedule ks3, des_cblock *iv, int enc) -{ - mit_des3_cbc_encrypt((const des_cblock *)in, out, (unsigned long)length, - ks1, ks2, ks3, - (const unsigned char *)iv, /* YUCK! */ - enc); -} -#endif diff --git a/src/lib/des425/key_sched.c b/src/lib/des425/key_sched.c index 0034ff375..70f61ce5e 100644 --- a/src/lib/des425/key_sched.c +++ b/src/lib/des425/key_sched.c @@ -38,10 +38,3 @@ des_key_sched(k,schedule) { return (mit_des_key_sched(k, schedule)); } - -#if TARGET_OS_MAC -int make_key_sched(des_cblock *k, des_key_schedule schedule) -{ - return mit_des_key_sched((unsigned char *)k, schedule); /* YUCK! */ -} -#endif diff --git a/src/lib/des425/mac_des_glue.c b/src/lib/des425/mac_des_glue.c new file mode 100644 index 000000000..130ced4bc --- /dev/null +++ b/src/lib/des425/mac_des_glue.c @@ -0,0 +1,103 @@ +#include "des_int.h" +#include "des.h" + +/* These functions are exported on KfM for ABI compatibility with + * older versions of the library. They have been pulled from the headers + * in the hope that someday we can remove them. + * + * Do not change the ABIs of any of these functions! + */ + +//int des_read_pw_string(char *, int, char *, int); +char *des_crypt(const char *, const char *); +char *des_fcrypt(const char *, const char *, char *); + +int make_key_sched(des_cblock *, des_key_schedule); +int des_set_key(des_cblock *, des_key_schedule); + +void des_3cbc_encrypt(des_cblock *, des_cblock *, long, + des_key_schedule, des_key_schedule, des_key_schedule, + des_cblock *, int); +void des_3ecb_encrypt(des_cblock *, des_cblock *, + des_key_schedule, des_key_schedule, des_key_schedule, + int); + +void des_generate_random_block(des_cblock); +void des_set_random_generator_seed(des_cblock); +void des_set_sequence_number(des_cblock); + +#pragma mark - + +/* Why was this exported on KfM? Who knows... */ +int des_debug = 0; + +char *des_crypt(const char *str, const char *salt) +{ + char afs_buf[16]; + + return des_fcrypt(str, salt, afs_buf); +} + + +char *des_fcrypt(const char *str, const char *salt, char *buf) +{ + return mit_afs_crypt(str, salt, buf); +} + + +int make_key_sched(des_cblock *k, des_key_schedule schedule) +{ + return mit_des_key_sched((unsigned char *)k, schedule); /* YUCK! */ +} + + +int des_set_key(des_cblock *key, des_key_schedule schedule) +{ + return make_key_sched(key, schedule); +} + + +void des_3cbc_encrypt(des_cblock *in, des_cblock *out, long length, + des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3, + des_cblock *iv, int enc) +{ + mit_des3_cbc_encrypt((const des_cblock *)in, out, (unsigned long)length, + ks1, ks2, ks3, + (const unsigned char *)iv, /* YUCK! */ + enc); +} + + +void des_3ecb_encrypt(des_cblock *clear, des_cblock *cipher, + des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3, + int enc) +{ + static const des_cblock iv; + + mit_des3_cbc_encrypt((const des_cblock *)clear, cipher, 8, ks1, ks2, ks3, iv, enc); +} + + +void des_generate_random_block(des_cblock block) +{ + krb5_data data; + + data.length = sizeof(des_cblock); + data.data = (char *)block; + + /* This function can return an error, however we must ignore it. */ + /* The worst that happens is that the resulting block is non-random */ + krb5_c_random_make_octets(/* XXX */ 0, &data); +} + + +void des_set_random_generator_seed(des_cblock block) +{ + des_init_random_number_generator(block); /* XXX */ +} + + +void des_set_sequence_number(des_cblock block) +{ + des_init_random_number_generator(block); /* XXX */ +} diff --git a/src/lib/des425/new_rnd_key.c b/src/lib/des425/new_rnd_key.c index 1f50f9e59..126ddf500 100644 --- a/src/lib/des425/new_rnd_key.c +++ b/src/lib/des425/new_rnd_key.c @@ -94,27 +94,3 @@ des_new_random_key(key) return 0; } - -#if TARGET_OS_MAC - -void des_generate_random_block(des_cblock block) -{ - krb5_data data; - - data.length = sizeof(des_cblock); - data.data = (char *)block; - if (krb5_c_random_make_octets(/* XXX */ 0, &data)) - abort(); /* XXX */ -} - -void des_set_random_generator_seed(des_cblock block) -{ - des_init_random_number_generator(block); /* XXX */ -} - -void des_set_sequence_number(des_cblock block) -{ - des_init_random_number_generator(block); /* XXX */ -} - -#endif diff --git a/src/lib/des425/read_passwd.c b/src/lib/des425/read_passwd.c index 03efe698e..e1b4c713c 100644 --- a/src/lib/des425/read_passwd.c +++ b/src/lib/des425/read_passwd.c @@ -102,6 +102,7 @@ des_read_password(k,prompt,verify) return ok; } +/* Note: this function is exported on KfM. Do not change its ABI. */ int KRB5_CALLCONV des_read_pw_string(s, max, prompt, verify) char *s; diff --git a/src/lib/des425/str_to_key.c b/src/lib/des425/str_to_key.c index ce95a531f..4ddcaed4a 100644 --- a/src/lib/des425/str_to_key.c +++ b/src/lib/des425/str_to_key.c @@ -150,8 +150,6 @@ des_string_to_key(str,key) /* can do dumb things sometimes */ } -char *mit_afs_crypt (const char *, const char *, const char *); - void afs_string_to_key(char *str, char *cell, des_cblock key) { krb5_data str_data; @@ -168,24 +166,3 @@ void afs_string_to_key(char *str, char *cell, des_cblock key) mit_afs_string_to_key(&keyblock, &str_data, &cell_data); } - -#if TARGET_OS_MAC -char *des_crypt(const char *str, const char *salt) -{ - char afs_buf[16]; - - return des_fcrypt(str, salt, afs_buf); -} - -char *des_fcrypt(const char *str, const char *salt, char *buf) -{ - return mit_afs_crypt(str, salt, buf); -} - -/* Is this correct? */ -int des_set_key(des_cblock *key, des_key_schedule schedule) -{ - return make_key_sched(key, schedule); -} - -#endif /* TARGET_OS_MAC */