1*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 2*7c478bd9Sstevel@tonic-gate /* 3*7c478bd9Sstevel@tonic-gate * Copyright (C) 1998 by the FundsXpress, INC. 4*7c478bd9Sstevel@tonic-gate * 5*7c478bd9Sstevel@tonic-gate * All rights reserved. 6*7c478bd9Sstevel@tonic-gate * 7*7c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may require 8*7c478bd9Sstevel@tonic-gate * a specific license from the United States Government. It is the 9*7c478bd9Sstevel@tonic-gate * responsibility of any person or organization contemplating export to 10*7c478bd9Sstevel@tonic-gate * obtain such a license before exporting. 11*7c478bd9Sstevel@tonic-gate * 12*7c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 13*7c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and 14*7c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright 15*7c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and 16*7c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that 17*7c478bd9Sstevel@tonic-gate * the name of FundsXpress. not be used in advertising or publicity pertaining 18*7c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior 19*7c478bd9Sstevel@tonic-gate * permission. FundsXpress makes no representations about the suitability of 20*7c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express 21*7c478bd9Sstevel@tonic-gate * or implied warranty. 22*7c478bd9Sstevel@tonic-gate * 23*7c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 24*7c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 25*7c478bd9Sstevel@tonic-gate * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26*7c478bd9Sstevel@tonic-gate */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #include <k5-int.h> 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate krb5_error_code 31*7c478bd9Sstevel@tonic-gate krb5_encrypt_helper(context, key, usage, plain, cipher) 32*7c478bd9Sstevel@tonic-gate krb5_context context; 33*7c478bd9Sstevel@tonic-gate krb5_const krb5_keyblock *key; 34*7c478bd9Sstevel@tonic-gate krb5_keyusage usage; 35*7c478bd9Sstevel@tonic-gate krb5_const krb5_data *plain; 36*7c478bd9Sstevel@tonic-gate krb5_enc_data *cipher; 37*7c478bd9Sstevel@tonic-gate { 38*7c478bd9Sstevel@tonic-gate krb5_error_code ret; 39*7c478bd9Sstevel@tonic-gate size_t enclen; 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate if (ret = krb5_c_encrypt_length(context, key->enctype, plain->length, 42*7c478bd9Sstevel@tonic-gate &enclen)) 43*7c478bd9Sstevel@tonic-gate return(ret); 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate cipher->ciphertext.length = enclen; 46*7c478bd9Sstevel@tonic-gate if ((cipher->ciphertext.data = (char *) malloc(enclen)) == NULL) 47*7c478bd9Sstevel@tonic-gate return(ret); 48*7c478bd9Sstevel@tonic-gate ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher); 49*7c478bd9Sstevel@tonic-gate if (ret) { 50*7c478bd9Sstevel@tonic-gate free(cipher->ciphertext.data); 51*7c478bd9Sstevel@tonic-gate cipher->ciphertext.data = NULL; 52*7c478bd9Sstevel@tonic-gate } 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate return(ret); 55*7c478bd9Sstevel@tonic-gate } 56*7c478bd9Sstevel@tonic-gate 57