diff options
author | Greg Hudson <ghudson@mit.edu> | 2009-10-03 16:03:15 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2009-10-03 16:03:15 +0000 |
commit | 8025c33f6285b8773a927351c0b3503d878565f1 (patch) | |
tree | fe8100e32b4efb5b03a88e065d0bcbc88691c303 /src/lib/crypto/krb/state.c | |
parent | 0faf98575f91452efee9f4c8d100c83fa9971e46 (diff) | |
download | krb5-8025c33f6285b8773a927351c0b3503d878565f1.zip krb5-8025c33f6285b8773a927351c0b3503d878565f1.tar.gz krb5-8025c33f6285b8773a927351c0b3503d878565f1.tar.bz2 |
Update the crypto API glue to conform to most of the current coding
practices (except lack of tabs). Use the helper functions k5alloc,
zapfree, and find_enctype to reduce code size.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22839 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/krb/state.c')
-rw-r--r-- | src/lib/crypto/krb/state.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/lib/crypto/krb/state.c b/src/lib/crypto/krb/state.c index f69746c..152ebec 100644 --- a/src/lib/crypto/krb/state.c +++ b/src/lib/crypto/krb/state.c @@ -39,34 +39,22 @@ krb5_error_code KRB5_CALLCONV krb5_c_init_state (krb5_context context, const krb5_keyblock *key, krb5_keyusage keyusage, krb5_data *new_state) { - int i; + const struct krb5_keytypes *ktp; - for (i=0; i<krb5_enctypes_length; i++) { - if (krb5_enctypes_list[i].etype == key->enctype) - break; - } - - if (i == krb5_enctypes_length) - return(KRB5_BAD_ENCTYPE); - - return (*(krb5_enctypes_list[i].enc->init_state)) - (key, keyusage, new_state); + ktp = find_enctype(key->enctype); + if (ktp == NULL) + return KRB5_BAD_ENCTYPE; + return ktp->enc->init_state(key, keyusage, new_state); } krb5_error_code KRB5_CALLCONV -krb5_c_free_state (krb5_context context, const krb5_keyblock *key, - krb5_data *state) +krb5_c_free_state(krb5_context context, const krb5_keyblock *key, + krb5_data *state) { - int i; - - for (i=0; i<krb5_enctypes_length; i++) { - if (krb5_enctypes_list[i].etype == key->enctype) - break; - } - - if (i == krb5_enctypes_length) - return(KRB5_BAD_ENCTYPE); + const struct krb5_keytypes *ktp; - return (*(krb5_enctypes_list[i].enc->free_state)) - (state); + ktp = find_enctype(key->enctype); + if (ktp == NULL) + return KRB5_BAD_ENCTYPE; + return ktp->enc->free_state(state); } |