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