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/prf.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/prf.c')
-rw-r--r-- | src/lib/crypto/krb/prf.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/src/lib/crypto/krb/prf.c b/src/lib/crypto/krb/prf.c index 67e1bc8..d2c633e 100644 --- a/src/lib/crypto/krb/prf.c +++ b/src/lib/crypto/krb/prf.c @@ -37,51 +37,35 @@ #include <assert.h> krb5_error_code KRB5_CALLCONV -krb5_c_prf_length(krb5_context context, krb5_enctype enctype, - size_t *len) +krb5_c_prf_length(krb5_context context, krb5_enctype enctype, size_t *len) { - int i; - assert (len); + const struct krb5_keytypes *ktp; - for (i=0; i<krb5_enctypes_length; i++) { - if (krb5_enctypes_list[i].etype == enctype) - break; - } - - if (i == krb5_enctypes_length) - return(KRB5_BAD_ENCTYPE); - - *len = krb5_enctypes_list[i].prf_length; + assert(len); + ktp = find_enctype(enctype); + if (ktp == NULL) + return KRB5_BAD_ENCTYPE; + *len = ktp->prf_length; return 0; - } krb5_error_code KRB5_CALLCONV krb5_c_prf(krb5_context context, const krb5_keyblock *key, krb5_data *input, krb5_data *output) { - int i; - size_t len; - assert(input && output); - assert (output->data); + const struct krb5_keytypes *ktp; + assert(input && output); + assert(output->data); - 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); + ktp = find_enctype(key->enctype); + if (ktp == NULL) + return KRB5_BAD_ENCTYPE; + if (ktp->prf == NULL) + return KRB5_CRYPTO_INTERNAL; output->magic = KV5M_DATA; - if (!krb5_enctypes_list[i].prf) - return (KRB5_CRYPTO_INTERNAL); - krb5_c_prf_length (context, key->enctype, &len); - if (len != output->length) - return (KRB5_CRYPTO_INTERNAL); - return((*(krb5_enctypes_list[i].prf)) - (krb5_enctypes_list[i].enc, krb5_enctypes_list[i].hash, - key, input, output)); + if (ktp->prf_length != output->length) + return KRB5_CRYPTO_INTERNAL; + return (*ktp->prf)(ktp->enc, ktp->hash, key, input, output); } - |