1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/krb5/krb/enc_keyhelper.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.
28 * krb5_encrypt_keyhelper()
35 krb5_encrypt_keyhelper(krb5_context context, krb5_key key, krb5_keyusage usage,
36 const krb5_data *plain, krb5_enc_data *cipher)
42 enctype = krb5_k_key_enctype(context, key);
43 ret = krb5_c_encrypt_length(context, enctype, plain->length, &enclen);
47 cipher->ciphertext.length = enclen;
48 cipher->ciphertext.data = malloc(enclen);
49 if (cipher->ciphertext.data == NULL)
51 ret = krb5_k_encrypt(context, key, usage, 0, plain, cipher);
53 free(cipher->ciphertext.data);
54 cipher->ciphertext.data = NULL;