1 /*
2 * Copyright (C) 1998 by the FundsXpress, INC.
3 *
4 * All rights reserved.
5 *
6 * Export of this software from the United States of America may require
7 * a specific license from the United States Government. It is the
8 * responsibility of any person or organization contemplating export to
9 * obtain such a license before exporting.
10 *
11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12 * distribute this software and its documentation for any purpose and
13 * without fee is hereby granted, provided that the above copyright
14 * notice appear in all copies and that both that copyright notice and
15 * this permission notice appear in supporting documentation, and that
16 * the name of FundsXpress. not be used in advertising or publicity pertaining
17 * to distribution of the software without specific, written prior
18 * permission. FundsXpress makes no representations about the suitability of
19 * this software for any purpose. It is provided "as is" without express
20 * or implied warranty.
21 *
22 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
24 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 */
26
27 #include "k5-int.h"
28 #include "cksumtypes.h"
29
30 /*ARGSUSED*/
31 krb5_error_code KRB5_CALLCONV
krb5_c_checksum_length(krb5_context context,krb5_cksumtype cksumtype,size_t * length)32 krb5_c_checksum_length(krb5_context context, krb5_cksumtype cksumtype,
33 size_t *length)
34 {
35 int i;
36
37 for (i=0; i<krb5_cksumtypes_length; i++) {
38 if (krb5_cksumtypes_list[i].ctype == cksumtype)
39 break;
40 }
41
42 if (i == krb5_cksumtypes_length)
43 return(KRB5_BAD_ENCTYPE);
44
45 if (krb5_cksumtypes_list[i].keyhash)
46 *length = krb5_cksumtypes_list[i].keyhash->hashsize;
47 else if (krb5_cksumtypes_list[i].trunc_size)
48 *length = krb5_cksumtypes_list[i].trunc_size;
49 else
50 *length = krb5_cksumtypes_list[i].hash->hashsize;
51
52 return(0);
53 }
54
55