diff options
author | Greg Hudson <ghudson@mit.edu> | 2009-10-03 21:02:44 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2009-10-03 21:02:44 +0000 |
commit | 8258dbd7f56dc010ca08abd71263f1de99e2ad97 (patch) | |
tree | 104572c64e1638d9ee4101bfee3b72ec8df53a2d /src/lib/crypto/krb/keyed_checksum_types.c | |
parent | 53ec69c80a80151e67f657c79e2f7d6adbf1732b (diff) | |
download | krb5-8258dbd7f56dc010ca08abd71263f1de99e2ad97.zip krb5-8258dbd7f56dc010ca08abd71263f1de99e2ad97.tar.gz krb5-8258dbd7f56dc010ca08abd71263f1de99e2ad97.tar.bz2 |
Merge trunk changes from r22833 to r22841 to enc-perf branch
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/enc-perf@22842 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/krb/keyed_checksum_types.c')
-rw-r--r-- | src/lib/crypto/krb/keyed_checksum_types.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/src/lib/crypto/krb/keyed_checksum_types.c b/src/lib/crypto/krb/keyed_checksum_types.c index 04aa447..2fd239c 100644 --- a/src/lib/crypto/krb/keyed_checksum_types.c +++ b/src/lib/crypto/krb/keyed_checksum_types.c @@ -28,62 +28,54 @@ #include "etypes.h" #include "cksumtypes.h" -static int etype_match(krb5_enctype e1, krb5_enctype e2) +static krb5_boolean +etype_match(krb5_enctype e1, krb5_enctype e2) { - int i1, i2; + const struct krb5_keytypes *ktp1, *ktp2; - for (i1=0; i1<krb5_enctypes_length; i1++) - if (krb5_enctypes_list[i1].etype == e1) - break; - - for (i2=0; i2<krb5_enctypes_length; i2++) - if (krb5_enctypes_list[i2].etype == e2) - break; - - return((i1 < krb5_enctypes_length) && - (i2 < krb5_enctypes_length) && - (krb5_enctypes_list[i1].enc == krb5_enctypes_list[i2].enc)); + ktp1 = find_enctype(e1); + ktp2 = find_enctype(e2); + return (ktp1 != NULL && ktp2 != NULL && ktp1->enc == ktp2->enc); } krb5_error_code KRB5_CALLCONV krb5_c_keyed_checksum_types(krb5_context context, krb5_enctype enctype, unsigned int *count, krb5_cksumtype **cksumtypes) { - unsigned int i, c; + unsigned int i, c, nctypes; + krb5_cksumtype *ctypes; + const struct krb5_cksumtypes *ct; - c = 0; - for (i=0; i<krb5_cksumtypes_length; i++) { - if ((krb5_cksumtypes_list[i].keyhash && - etype_match(krb5_cksumtypes_list[i].keyed_etype, enctype)) || - (krb5_cksumtypes_list[i].flags & KRB5_CKSUMFLAG_DERIVE)) { - c++; - } - } + *count = 0; + *cksumtypes = NULL; - *count = c; + nctypes = 0; + for (i = 0; i < krb5_cksumtypes_length; i++) { + ct = &krb5_cksumtypes_list[i]; + if ((ct->keyhash && etype_match(ct->keyed_etype, enctype)) || + (ct->flags & KRB5_CKSUMFLAG_DERIVE)) + nctypes++; + } - if ((*cksumtypes = (krb5_cksumtype *) malloc(c*sizeof(krb5_cksumtype))) - == NULL) - return(ENOMEM); + ctypes = malloc(nctypes * sizeof(krb5_cksumtype)); + if (ctypes == NULL) + return ENOMEM; c = 0; - for (i=0; i<krb5_cksumtypes_length; i++) { - if ((krb5_cksumtypes_list[i].keyhash && - etype_match(krb5_cksumtypes_list[i].keyed_etype, enctype)) || - (krb5_cksumtypes_list[i].flags & KRB5_CKSUMFLAG_DERIVE)) { - (*cksumtypes)[c] = krb5_cksumtypes_list[i].ctype; - c++; - } + for (i = 0; i < krb5_cksumtypes_length; i++) { + ct = &krb5_cksumtypes_list[i]; + if ((ct->keyhash && etype_match(ct->keyed_etype, enctype)) || + (ct->flags & KRB5_CKSUMFLAG_DERIVE)) + ctypes[c++] = krb5_cksumtypes_list[i].ctype; } - return(0); + *count = nctypes; + *cksumtypes = ctypes; + return 0; } void KRB5_CALLCONV krb5_free_cksumtypes(krb5_context context, krb5_cksumtype *val) { - if (val) - free(val); - return; + free(val); } - |