1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/krb5/krb/enc_helper.c */
4 * Copyright (C) 1998 by the FundsXpress, INC.
8 * Export of this software from the United States of America may require
9 * a specific license from the United States Government. It is the
10 * responsibility of any person or organization contemplating export to
11 * obtain such a license before exporting.
13 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14 * distribute this software and its documentation for any purpose and
15 * without fee is hereby granted, provided that the above copyright
16 * notice appear in all copies and that both that copyright notice and
17 * this permission notice appear in supporting documentation, and that
18 * the name of FundsXpress. not be used in advertising or publicity pertaining
19 * to distribution of the software without specific, written prior
20 * permission. FundsXpress makes no representations about the suitability of
21 * this software for any purpose. It is provided "as is" without express
22 * or implied warranty.
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
26 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32 krb5_encrypt_helper(krb5_context context,
33 const krb5_keyblock *key, krb5_keyusage usage,
34 const krb5_data *plain, krb5_enc_data *cipher)
39 if ((ret = krb5_c_encrypt_length(context, key->enctype, plain->length,
43 cipher->ciphertext.length = enclen;
44 if ((cipher->ciphertext.data = (char *) malloc(enclen)) == NULL)
46 ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher);
48 free(cipher->ciphertext.data);
49 cipher->ciphertext.data = NULL;