1 /*
2  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 /*
8  * Copyright (C) 1998 by the FundsXpress, INC.
9  *
10  * All rights reserved.
11  *
12  * Export of this software from the United States of America may require
13  * a specific license from the United States Government.  It is the
14  * responsibility of any person or organization contemplating export to
15  * obtain such a license before exporting.
16  *
17  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
18  * distribute this software and its documentation for any purpose and
19  * without fee is hereby granted, provided that the above copyright
20  * notice appear in all copies and that both that copyright notice and
21  * this permission notice appear in supporting documentation, and that
22  * the name of FundsXpress. not be used in advertising or publicity pertaining
23  * to distribution of the software without specific, written prior
24  * permission.  FundsXpress makes no representations about the suitability of
25  * this software for any purpose.  It is provided "as is" without express
26  * or implied warranty.
27  *
28  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
29  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
30  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31  */
32 
33 #include <k5-int.h>
34 #include <etypes.h>
35 krb5_error_code KRB5_CALLCONV
krb5_enctype_to_string(krb5_enctype enctype,char * buffer,size_t buflen)36 krb5_enctype_to_string(krb5_enctype enctype, char *buffer, size_t buflen)
37 {
38     int i;
39 
40     for (i=0; i<krb5_enctypes_length; i++) {
41 	if (krb5_enctypes_list[i].etype == enctype) {
42 	    if ((strlen(krb5_enctypes_list[i].out_string)+1) > buflen)
43 		return(ENOMEM);
44 
45 	    strcpy(buffer, krb5_enctypes_list[i].out_string);
46 	    return(0);
47 	}
48     }
49 
50     return(EINVAL);
51 }
52 
53 /* Solaris Kerberos */
54 krb5_error_code KRB5_CALLCONV
krb5_enctype_to_istring(krb5_enctype enctype,char * buffer,size_t buflen)55 krb5_enctype_to_istring(krb5_enctype enctype, char *buffer, size_t buflen)
56 {
57     int i;
58 
59     for (i=0; i<krb5_enctypes_length; i++) {
60 	if (krb5_enctypes_list[i].etype == enctype) {
61 	    if ((strlen(krb5_enctypes_list[i].in_string)+1) > buflen)
62 		return(ENOMEM);
63 
64 	    strlcpy(buffer, krb5_enctypes_list[i].in_string, buflen);
65 	    return(0);
66 	}
67     }
68 
69     return(EINVAL);
70 }
71