17c478bd9Sstevel@tonic-gate /*
2*159d09a2SMark Phalan * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate /*
77c478bd9Sstevel@tonic-gate * Copyright (C) 1998 by the FundsXpress, INC.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * All rights reserved.
107c478bd9Sstevel@tonic-gate *
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.
157c478bd9Sstevel@tonic-gate *
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.
267c478bd9Sstevel@tonic-gate *
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
32*159d09a2SMark Phalan #include "k5-int.h"
33*159d09a2SMark Phalan #include "etypes.h"
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate /*ARGSUSED*/
36505d05c7Sgtb krb5_error_code KRB5_CALLCONV
krb5_c_decrypt(krb5_context context,const krb5_keyblock * key,krb5_keyusage usage,const krb5_data * ivec,const krb5_enc_data * input,krb5_data * output)37505d05c7Sgtb krb5_c_decrypt(krb5_context context, const krb5_keyblock *key,
38505d05c7Sgtb krb5_keyusage usage, const krb5_data *ivec,
39505d05c7Sgtb const krb5_enc_data *input, krb5_data *output)
407c478bd9Sstevel@tonic-gate {
417c478bd9Sstevel@tonic-gate int i;
427c478bd9Sstevel@tonic-gate krb5_error_code ret = 0;
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate for (i=0; i<krb5_enctypes_length; i++) {
457c478bd9Sstevel@tonic-gate if (krb5_enctypes_list[i].etype == key->enctype)
467c478bd9Sstevel@tonic-gate break;
477c478bd9Sstevel@tonic-gate }
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate if (i == krb5_enctypes_length)
507c478bd9Sstevel@tonic-gate return(KRB5_BAD_ENCTYPE);
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate if ((input->enctype != ENCTYPE_UNKNOWN) &&
537c478bd9Sstevel@tonic-gate (krb5_enctypes_list[i].etype != input->enctype))
547c478bd9Sstevel@tonic-gate return(KRB5_BAD_ENCTYPE);
557c478bd9Sstevel@tonic-gate
56*159d09a2SMark Phalan /* Solaris Kerberos */
577c478bd9Sstevel@tonic-gate #ifdef _KERNEL
587c478bd9Sstevel@tonic-gate context->kef_cipher_mt = krb5_enctypes_list[i].kef_cipher_mt;
597c478bd9Sstevel@tonic-gate context->kef_hash_mt = krb5_enctypes_list[i].kef_hash_mt;
607c478bd9Sstevel@tonic-gate if (key->kef_key.ck_data == NULL)
617c478bd9Sstevel@tonic-gate ret = init_key_kef(context->kef_cipher_mt, (krb5_keyblock *)key);
627c478bd9Sstevel@tonic-gate if (ret)
637c478bd9Sstevel@tonic-gate return(ret);
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate #else
667c478bd9Sstevel@tonic-gate if ((ret = init_key_uef(krb_ctx_hSession(context), (krb5_keyblock *)key)))
677c478bd9Sstevel@tonic-gate return (ret);
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
707c478bd9Sstevel@tonic-gate
71*159d09a2SMark Phalan /* Solaris Kerberos */
727c478bd9Sstevel@tonic-gate return((*(krb5_enctypes_list[i].decrypt))
737c478bd9Sstevel@tonic-gate (context, krb5_enctypes_list[i].enc, krb5_enctypes_list[i].hash,
747c478bd9Sstevel@tonic-gate key, usage, ivec, &input->ciphertext, output));
757c478bd9Sstevel@tonic-gate }
76