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