xref: /illumos-gate/usr/src/lib/gss_mechs/mech_krb5/crypto/enctype_compare.c (revision 505d05c73a6e56769f263d4803b22eddd168ee24)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 /*
3  * Copyright (C) 1998 by the FundsXpress, INC.
4  *
5  * All rights reserved.
6  *
7  * Export of this software from the United States of America may require
8  * a specific license from the United States Government.  It is the
9  * responsibility of any person or organization contemplating export to
10  * obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of FundsXpress. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  FundsXpress makes no representations about the suitability of
20  * this software for any purpose.  It is provided "as is" without express
21  * or implied warranty.
22  *
23  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
25  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26  */
27 
28 #include <k5-int.h>
29 #include <etypes.h>
30 
31 /*ARGSUSED*/
32 krb5_error_code KRB5_CALLCONV
33 krb5_c_enctype_compare(krb5_context context, krb5_enctype e1, krb5_enctype e2,
34 		    krb5_boolean *similar)
35 {
36     int i, j;
37 
38     for (i=0; i<krb5_enctypes_length; i++)
39 	if (krb5_enctypes_list[i].etype == e1)
40 	    break;
41 
42     if (i == krb5_enctypes_length)
43 	return(KRB5_BAD_ENCTYPE);
44 
45     for (j=0; j<krb5_enctypes_length; j++)
46 	if (krb5_enctypes_list[j].etype == e2)
47 	    break;
48 
49     if (j == krb5_enctypes_length)
50 	return(KRB5_BAD_ENCTYPE);
51 
52     *similar =
53 	((krb5_enctypes_list[i].enc == krb5_enctypes_list[j].enc) &&
54 	 (krb5_enctypes_list[i].str2key == krb5_enctypes_list[j].str2key));
55 
56     return(0);
57 }
58