17c64d375Smp /*
27c64d375Smp  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
37c64d375Smp  * Use is subject to license terms.
47c64d375Smp  */
57c64d375Smp 
67c478bd9Sstevel@tonic-gate /*
77c478bd9Sstevel@tonic-gate  * Copyright (C) 1998 by the FundsXpress, INC.
8*1da57d55SToomas Soome  *
97c478bd9Sstevel@tonic-gate  * All rights reserved.
10*1da57d55SToomas Soome  *
117c478bd9Sstevel@tonic-gate  * Export of this software from the United States of America may require
127c478bd9Sstevel@tonic-gate  * a specific license from the United States Government.  It is the
137c478bd9Sstevel@tonic-gate  * responsibility of any person or organization contemplating export to
147c478bd9Sstevel@tonic-gate  * obtain such a license before exporting.
15*1da57d55SToomas Soome  *
167c478bd9Sstevel@tonic-gate  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
177c478bd9Sstevel@tonic-gate  * distribute this software and its documentation for any purpose and
187c478bd9Sstevel@tonic-gate  * without fee is hereby granted, provided that the above copyright
197c478bd9Sstevel@tonic-gate  * notice appear in all copies and that both that copyright notice and
207c478bd9Sstevel@tonic-gate  * this permission notice appear in supporting documentation, and that
217c478bd9Sstevel@tonic-gate  * the name of FundsXpress. not be used in advertising or publicity pertaining
227c478bd9Sstevel@tonic-gate  * to distribution of the software without specific, written prior
237c478bd9Sstevel@tonic-gate  * permission.  FundsXpress makes no representations about the suitability of
247c478bd9Sstevel@tonic-gate  * this software for any purpose.  It is provided "as is" without express
257c478bd9Sstevel@tonic-gate  * or implied warranty.
26*1da57d55SToomas Soome  *
277c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
287c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
297c478bd9Sstevel@tonic-gate  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <k5-int.h>
337c478bd9Sstevel@tonic-gate #include <etypes.h>
34505d05c7Sgtb krb5_error_code KRB5_CALLCONV
krb5_enctype_to_string(krb5_enctype enctype,char * buffer,size_t buflen)35505d05c7Sgtb krb5_enctype_to_string(krb5_enctype enctype, char *buffer, size_t buflen)
367c478bd9Sstevel@tonic-gate {
377c478bd9Sstevel@tonic-gate     int i;
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate     for (i=0; i<krb5_enctypes_length; i++) {
407c478bd9Sstevel@tonic-gate 	if (krb5_enctypes_list[i].etype == enctype) {
417c478bd9Sstevel@tonic-gate 	    if ((strlen(krb5_enctypes_list[i].out_string)+1) > buflen)
427c478bd9Sstevel@tonic-gate 		return(ENOMEM);
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate 	    strcpy(buffer, krb5_enctypes_list[i].out_string);
457c478bd9Sstevel@tonic-gate 	    return(0);
467c478bd9Sstevel@tonic-gate 	}
477c478bd9Sstevel@tonic-gate     }
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate     return(EINVAL);
507c478bd9Sstevel@tonic-gate }
517c64d375Smp 
527c64d375Smp /* Solaris Kerberos */
537c64d375Smp krb5_error_code KRB5_CALLCONV
krb5_enctype_to_istring(krb5_enctype enctype,char * buffer,size_t buflen)547c64d375Smp krb5_enctype_to_istring(krb5_enctype enctype, char *buffer, size_t buflen)
557c64d375Smp {
567c64d375Smp     int i;
577c64d375Smp 
587c64d375Smp     for (i=0; i<krb5_enctypes_length; i++) {
597c64d375Smp 	if (krb5_enctypes_list[i].etype == enctype) {
607c64d375Smp 	    if ((strlen(krb5_enctypes_list[i].in_string)+1) > buflen)
617c64d375Smp 		return(ENOMEM);
627c64d375Smp 
637c64d375Smp 	    strlcpy(buffer, krb5_enctypes_list[i].in_string, buflen);
647c64d375Smp 	    return(0);
657c64d375Smp 	}
667c64d375Smp     }
677c64d375Smp 
687c64d375Smp     return(EINVAL);
697c64d375Smp }
70