17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * Copyright (C) 1998 by the FundsXpress, INC.
3*55fea89dSDan Cross *
47c478bd9Sstevel@tonic-gate * All rights reserved.
5*55fea89dSDan Cross *
67c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may require
77c478bd9Sstevel@tonic-gate * a specific license from the United States Government. It is the
87c478bd9Sstevel@tonic-gate * responsibility of any person or organization contemplating export to
97c478bd9Sstevel@tonic-gate * obtain such a license before exporting.
10*55fea89dSDan Cross *
117c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
127c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and
137c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright
147c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and
157c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that
167c478bd9Sstevel@tonic-gate * the name of FundsXpress. not be used in advertising or publicity pertaining
177c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior
187c478bd9Sstevel@tonic-gate * permission. FundsXpress makes no representations about the suitability of
197c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express
207c478bd9Sstevel@tonic-gate * or implied warranty.
21*55fea89dSDan Cross *
227c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
237c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
247c478bd9Sstevel@tonic-gate * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <k5-int.h>
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate krb5_error_code
krb5_encrypt_helper(krb5_context context,const krb5_keyblock * key,krb5_keyusage usage,const krb5_data * plain,krb5_enc_data * cipher)30505d05c7Sgtb krb5_encrypt_helper(krb5_context context, const krb5_keyblock *key, krb5_keyusage usage, const krb5_data *plain, krb5_enc_data *cipher)
317c478bd9Sstevel@tonic-gate {
327c478bd9Sstevel@tonic-gate krb5_error_code ret;
337c478bd9Sstevel@tonic-gate size_t enclen;
347c478bd9Sstevel@tonic-gate
35505d05c7Sgtb if ((ret = krb5_c_encrypt_length(context, key->enctype, plain->length,
36505d05c7Sgtb &enclen)))
377c478bd9Sstevel@tonic-gate return(ret);
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate cipher->ciphertext.length = enclen;
404a9e65b6SMark Phalan
414a9e65b6SMark Phalan /* Solaris Kerberos */
424a9e65b6SMark Phalan if ((cipher->ciphertext.data = (char *) malloc(enclen)) == NULL) {
434a9e65b6SMark Phalan cipher->ciphertext.length = 0;
444a9e65b6SMark Phalan return(ENOMEM);
454a9e65b6SMark Phalan }
467c478bd9Sstevel@tonic-gate ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher);
477c478bd9Sstevel@tonic-gate if (ret) {
487c478bd9Sstevel@tonic-gate free(cipher->ciphertext.data);
497c478bd9Sstevel@tonic-gate cipher->ciphertext.data = NULL;
507c478bd9Sstevel@tonic-gate }
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate return(ret);
537c478bd9Sstevel@tonic-gate }
54*55fea89dSDan Cross
55