1*10db1377Sgtb /*
2*10db1377Sgtb * CDDL HEADER START
3*10db1377Sgtb *
4*10db1377Sgtb * The contents of this file are subject to the terms of the
5*10db1377Sgtb * Common Development and Distribution License (the "License").
6*10db1377Sgtb * You may not use this file except in compliance with the License.
7*10db1377Sgtb *
8*10db1377Sgtb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*10db1377Sgtb * or http://www.opensolaris.org/os/licensing.
10*10db1377Sgtb * See the License for the specific language governing permissions
11*10db1377Sgtb * and limitations under the License.
12*10db1377Sgtb *
13*10db1377Sgtb * When distributing Covered Code, include this CDDL HEADER in each
14*10db1377Sgtb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*10db1377Sgtb * If applicable, add the following below this CDDL HEADER, with the
16*10db1377Sgtb * fields enclosed by brackets "[]" replaced with your own identifying
17*10db1377Sgtb * information: Portions Copyright [yyyy] [name of copyright owner]
18*10db1377Sgtb *
19*10db1377Sgtb * CDDL HEADER END
20*10db1377Sgtb */
21*10db1377Sgtb
22*10db1377Sgtb /*
23*10db1377Sgtb * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24*10db1377Sgtb * Use is subject to license terms.
25*10db1377Sgtb */
26*10db1377Sgtb
27*10db1377Sgtb #include "k5-int.h"
28*10db1377Sgtb
29*10db1377Sgtb krb5_error_code KRB5_CALLCONV
krb5_init_allocated_keyblock(krb5_context context,krb5_enctype enctype,unsigned int length,krb5_keyblock * kb)30*10db1377Sgtb krb5_init_allocated_keyblock(
31*10db1377Sgtb krb5_context context,
32*10db1377Sgtb krb5_enctype enctype,
33*10db1377Sgtb unsigned int length,
34*10db1377Sgtb krb5_keyblock *kb)
35*10db1377Sgtb {
36*10db1377Sgtb
37*10db1377Sgtb if (!kb)
38*10db1377Sgtb return (EINVAL);
39*10db1377Sgtb
40*10db1377Sgtb (void) memset(kb, 0, sizeof (*kb));
41*10db1377Sgtb kb->enctype = enctype;
42*10db1377Sgtb kb->length = length;
43*10db1377Sgtb
44*10db1377Sgtb if (length) {
45*10db1377Sgtb kb->contents = malloc(length);
46*10db1377Sgtb if (!kb->contents) {
47*10db1377Sgtb return (ENOMEM);
48*10db1377Sgtb }
49*10db1377Sgtb (void) memset(kb->contents, 0, length);
50*10db1377Sgtb } else {
51*10db1377Sgtb kb->contents = NULL;
52*10db1377Sgtb }
53*10db1377Sgtb
54*10db1377Sgtb kb->dk_list = NULL;
55*10db1377Sgtb
56*10db1377Sgtb #ifdef _KERNEL
57*10db1377Sgtb kb->kef_key = NULL;
58*10db1377Sgtb #else
59*10db1377Sgtb kb->hKey = CK_INVALID_HANDLE;
60*10db1377Sgtb #endif
61*10db1377Sgtb
62*10db1377Sgtb return (0);
63*10db1377Sgtb }
64