1*d3273b5bSchristos /* $NetBSD: mit_glue.c,v 1.2 2017/01/28 21:31:49 christos Exp $ */
2ca1c9b0cSelric
3ca1c9b0cSelric /*
4ca1c9b0cSelric * Copyright (c) 2003 Kungliga Tekniska Högskolan
5ca1c9b0cSelric * (Royal Institute of Technology, Stockholm, Sweden).
6ca1c9b0cSelric * All rights reserved.
7ca1c9b0cSelric *
8ca1c9b0cSelric * Redistribution and use in source and binary forms, with or without
9ca1c9b0cSelric * modification, are permitted provided that the following conditions
10ca1c9b0cSelric * are met:
11ca1c9b0cSelric *
12ca1c9b0cSelric * 1. Redistributions of source code must retain the above copyright
13ca1c9b0cSelric * notice, this list of conditions and the following disclaimer.
14ca1c9b0cSelric *
15ca1c9b0cSelric * 2. Redistributions in binary form must reproduce the above copyright
16ca1c9b0cSelric * notice, this list of conditions and the following disclaimer in the
17ca1c9b0cSelric * documentation and/or other materials provided with the distribution.
18ca1c9b0cSelric *
19ca1c9b0cSelric * 3. Neither the name of the Institute nor the names of its contributors
20ca1c9b0cSelric * may be used to endorse or promote products derived from this software
21ca1c9b0cSelric * without specific prior written permission.
22ca1c9b0cSelric *
23ca1c9b0cSelric * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24ca1c9b0cSelric * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25ca1c9b0cSelric * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ca1c9b0cSelric * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27ca1c9b0cSelric * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28ca1c9b0cSelric * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29ca1c9b0cSelric * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30ca1c9b0cSelric * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31ca1c9b0cSelric * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32ca1c9b0cSelric * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33ca1c9b0cSelric * SUCH DAMAGE.
34ca1c9b0cSelric */
35ca1c9b0cSelric
36ca1c9b0cSelric #include "krb5_locl.h"
37ca1c9b0cSelric
38ca1c9b0cSelric #ifndef HEIMDAL_SMALLER
39ca1c9b0cSelric
40ca1c9b0cSelric /*
41ca1c9b0cSelric * Glue for MIT API
42ca1c9b0cSelric */
43ca1c9b0cSelric
44ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_make_checksum(krb5_context context,krb5_cksumtype cksumtype,const krb5_keyblock * key,krb5_keyusage usage,const krb5_data * input,krb5_checksum * cksum)45ca1c9b0cSelric krb5_c_make_checksum(krb5_context context,
46ca1c9b0cSelric krb5_cksumtype cksumtype,
47ca1c9b0cSelric const krb5_keyblock *key,
48ca1c9b0cSelric krb5_keyusage usage,
49ca1c9b0cSelric const krb5_data *input,
50ca1c9b0cSelric krb5_checksum *cksum)
51ca1c9b0cSelric {
52ca1c9b0cSelric krb5_error_code ret;
53ca1c9b0cSelric krb5_crypto crypto;
54ca1c9b0cSelric
55ca1c9b0cSelric ret = krb5_crypto_init(context, key, 0, &crypto);
56ca1c9b0cSelric if (ret)
57ca1c9b0cSelric return ret;
58ca1c9b0cSelric
59ca1c9b0cSelric ret = krb5_create_checksum(context, crypto, usage, cksumtype,
60ca1c9b0cSelric input->data, input->length, cksum);
61ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
62ca1c9b0cSelric
63ca1c9b0cSelric return ret ;
64ca1c9b0cSelric }
65ca1c9b0cSelric
66ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_verify_checksum(krb5_context context,const krb5_keyblock * key,krb5_keyusage usage,const krb5_data * data,const krb5_checksum * cksum,krb5_boolean * valid)67ca1c9b0cSelric krb5_c_verify_checksum(krb5_context context, const krb5_keyblock *key,
68ca1c9b0cSelric krb5_keyusage usage, const krb5_data *data,
69ca1c9b0cSelric const krb5_checksum *cksum, krb5_boolean *valid)
70ca1c9b0cSelric {
71ca1c9b0cSelric krb5_error_code ret;
72ca1c9b0cSelric krb5_checksum data_cksum;
73ca1c9b0cSelric
74ca1c9b0cSelric *valid = 0;
75ca1c9b0cSelric
76ca1c9b0cSelric ret = krb5_c_make_checksum(context, cksum->cksumtype,
77ca1c9b0cSelric key, usage, data, &data_cksum);
78ca1c9b0cSelric if (ret)
79ca1c9b0cSelric return ret;
80ca1c9b0cSelric
81ca1c9b0cSelric if (data_cksum.cksumtype == cksum->cksumtype
82ca1c9b0cSelric && krb5_data_ct_cmp(&data_cksum.checksum, &cksum->checksum) == 0)
83ca1c9b0cSelric *valid = 1;
84ca1c9b0cSelric
85ca1c9b0cSelric krb5_free_checksum_contents(context, &data_cksum);
86ca1c9b0cSelric
87ca1c9b0cSelric return 0;
88ca1c9b0cSelric }
89ca1c9b0cSelric
90ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_get_checksum(krb5_context context,const krb5_checksum * cksum,krb5_cksumtype * type,krb5_data ** data)91ca1c9b0cSelric krb5_c_get_checksum(krb5_context context, const krb5_checksum *cksum,
92ca1c9b0cSelric krb5_cksumtype *type, krb5_data **data)
93ca1c9b0cSelric {
94ca1c9b0cSelric krb5_error_code ret;
95ca1c9b0cSelric
96ca1c9b0cSelric if (type)
97ca1c9b0cSelric *type = cksum->cksumtype;
98ca1c9b0cSelric if (data) {
99ca1c9b0cSelric *data = malloc(sizeof(**data));
100ca1c9b0cSelric if (*data == NULL)
101b9d004c6Schristos return krb5_enomem(context);
102ca1c9b0cSelric
103ca1c9b0cSelric ret = der_copy_octet_string(&cksum->checksum, *data);
104ca1c9b0cSelric if (ret) {
105ca1c9b0cSelric free(*data);
106ca1c9b0cSelric *data = NULL;
107ca1c9b0cSelric return ret;
108ca1c9b0cSelric }
109ca1c9b0cSelric }
110ca1c9b0cSelric return 0;
111ca1c9b0cSelric }
112ca1c9b0cSelric
113ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_set_checksum(krb5_context context,krb5_checksum * cksum,krb5_cksumtype type,const krb5_data * data)114ca1c9b0cSelric krb5_c_set_checksum(krb5_context context, krb5_checksum *cksum,
115ca1c9b0cSelric krb5_cksumtype type, const krb5_data *data)
116ca1c9b0cSelric {
117ca1c9b0cSelric cksum->cksumtype = type;
118ca1c9b0cSelric return der_copy_octet_string(data, &cksum->checksum);
119ca1c9b0cSelric }
120ca1c9b0cSelric
121ca1c9b0cSelric KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_free_checksum(krb5_context context,krb5_checksum * cksum)122ca1c9b0cSelric krb5_free_checksum (krb5_context context, krb5_checksum *cksum)
123ca1c9b0cSelric {
124ca1c9b0cSelric krb5_checksum_free(context, cksum);
125ca1c9b0cSelric free(cksum);
126ca1c9b0cSelric }
127ca1c9b0cSelric
128ca1c9b0cSelric KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_free_checksum_contents(krb5_context context,krb5_checksum * cksum)129ca1c9b0cSelric krb5_free_checksum_contents(krb5_context context, krb5_checksum *cksum)
130ca1c9b0cSelric {
131ca1c9b0cSelric krb5_checksum_free(context, cksum);
132ca1c9b0cSelric memset(cksum, 0, sizeof(*cksum));
133ca1c9b0cSelric }
134ca1c9b0cSelric
135ca1c9b0cSelric KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_checksum_free(krb5_context context,krb5_checksum * cksum)136ca1c9b0cSelric krb5_checksum_free(krb5_context context, krb5_checksum *cksum)
137ca1c9b0cSelric {
138ca1c9b0cSelric free_Checksum(cksum);
139ca1c9b0cSelric }
140ca1c9b0cSelric
141ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
krb5_c_valid_enctype(krb5_enctype etype)142ca1c9b0cSelric krb5_c_valid_enctype (krb5_enctype etype)
143ca1c9b0cSelric {
1444f77a458Spettai return !krb5_enctype_valid(NULL, etype);
145ca1c9b0cSelric }
146ca1c9b0cSelric
147ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
krb5_c_valid_cksumtype(krb5_cksumtype ctype)148ca1c9b0cSelric krb5_c_valid_cksumtype(krb5_cksumtype ctype)
149ca1c9b0cSelric {
150ca1c9b0cSelric return krb5_cksumtype_valid(NULL, ctype);
151ca1c9b0cSelric }
152ca1c9b0cSelric
153ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
krb5_c_is_coll_proof_cksum(krb5_cksumtype ctype)154ca1c9b0cSelric krb5_c_is_coll_proof_cksum(krb5_cksumtype ctype)
155ca1c9b0cSelric {
156ca1c9b0cSelric return krb5_checksum_is_collision_proof(NULL, ctype);
157ca1c9b0cSelric }
158ca1c9b0cSelric
159ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_boolean KRB5_LIB_CALL
krb5_c_is_keyed_cksum(krb5_cksumtype ctype)160ca1c9b0cSelric krb5_c_is_keyed_cksum(krb5_cksumtype ctype)
161ca1c9b0cSelric {
162ca1c9b0cSelric return krb5_checksum_is_keyed(NULL, ctype);
163ca1c9b0cSelric }
164ca1c9b0cSelric
165ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_copy_checksum(krb5_context context,const krb5_checksum * old,krb5_checksum ** new)166ca1c9b0cSelric krb5_copy_checksum (krb5_context context,
167ca1c9b0cSelric const krb5_checksum *old,
168ca1c9b0cSelric krb5_checksum **new)
169ca1c9b0cSelric {
170ca1c9b0cSelric *new = malloc(sizeof(**new));
171ca1c9b0cSelric if (*new == NULL)
172b9d004c6Schristos return krb5_enomem(context);
173ca1c9b0cSelric return copy_Checksum(old, *new);
174ca1c9b0cSelric }
175ca1c9b0cSelric
176ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_checksum_length(krb5_context context,krb5_cksumtype cksumtype,size_t * length)177ca1c9b0cSelric krb5_c_checksum_length (krb5_context context, krb5_cksumtype cksumtype,
178ca1c9b0cSelric size_t *length)
179ca1c9b0cSelric {
180ca1c9b0cSelric return krb5_checksumsize(context, cksumtype, length);
181ca1c9b0cSelric }
182ca1c9b0cSelric
183ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_block_size(krb5_context context,krb5_enctype enctype,size_t * blocksize)184ca1c9b0cSelric krb5_c_block_size(krb5_context context,
185ca1c9b0cSelric krb5_enctype enctype,
186ca1c9b0cSelric size_t *blocksize)
187ca1c9b0cSelric {
188ca1c9b0cSelric krb5_error_code ret;
189ca1c9b0cSelric krb5_crypto crypto;
190ca1c9b0cSelric krb5_keyblock key;
191ca1c9b0cSelric
192ca1c9b0cSelric ret = krb5_generate_random_keyblock(context, enctype, &key);
193ca1c9b0cSelric if (ret)
194ca1c9b0cSelric return ret;
195ca1c9b0cSelric
196ca1c9b0cSelric ret = krb5_crypto_init(context, &key, 0, &crypto);
197ca1c9b0cSelric krb5_free_keyblock_contents(context, &key);
198ca1c9b0cSelric if (ret)
199ca1c9b0cSelric return ret;
200ca1c9b0cSelric ret = krb5_crypto_getblocksize(context, crypto, blocksize);
201ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
202ca1c9b0cSelric
203ca1c9b0cSelric return ret;
204ca1c9b0cSelric }
205ca1c9b0cSelric
206ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_decrypt(krb5_context context,const krb5_keyblock key,krb5_keyusage usage,const krb5_data * ivec,krb5_enc_data * input,krb5_data * output)207ca1c9b0cSelric krb5_c_decrypt(krb5_context context,
208ca1c9b0cSelric const krb5_keyblock key,
209ca1c9b0cSelric krb5_keyusage usage,
210ca1c9b0cSelric const krb5_data *ivec,
211ca1c9b0cSelric krb5_enc_data *input,
212ca1c9b0cSelric krb5_data *output)
213ca1c9b0cSelric {
214ca1c9b0cSelric krb5_error_code ret;
215ca1c9b0cSelric krb5_crypto crypto;
216ca1c9b0cSelric
217ca1c9b0cSelric ret = krb5_crypto_init(context, &key, input->enctype, &crypto);
218ca1c9b0cSelric if (ret)
219ca1c9b0cSelric return ret;
220ca1c9b0cSelric
221ca1c9b0cSelric if (ivec) {
222ca1c9b0cSelric size_t blocksize;
223ca1c9b0cSelric
224ca1c9b0cSelric ret = krb5_crypto_getblocksize(context, crypto, &blocksize);
225ca1c9b0cSelric if (ret) {
226ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
227ca1c9b0cSelric return ret;
228ca1c9b0cSelric }
229ca1c9b0cSelric
230ca1c9b0cSelric if (blocksize > ivec->length) {
231ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
232ca1c9b0cSelric return KRB5_BAD_MSIZE;
233ca1c9b0cSelric }
234ca1c9b0cSelric }
235ca1c9b0cSelric
236ca1c9b0cSelric ret = krb5_decrypt_ivec(context, crypto, usage,
237ca1c9b0cSelric input->ciphertext.data, input->ciphertext.length,
238ca1c9b0cSelric output,
239ca1c9b0cSelric ivec ? ivec->data : NULL);
240ca1c9b0cSelric
241ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
242ca1c9b0cSelric
243ca1c9b0cSelric return ret ;
244ca1c9b0cSelric }
245ca1c9b0cSelric
246ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_encrypt(krb5_context context,const krb5_keyblock * key,krb5_keyusage usage,const krb5_data * ivec,const krb5_data * input,krb5_enc_data * output)247ca1c9b0cSelric krb5_c_encrypt(krb5_context context,
248ca1c9b0cSelric const krb5_keyblock *key,
249ca1c9b0cSelric krb5_keyusage usage,
250ca1c9b0cSelric const krb5_data *ivec,
251ca1c9b0cSelric const krb5_data *input,
252ca1c9b0cSelric krb5_enc_data *output)
253ca1c9b0cSelric {
254ca1c9b0cSelric krb5_error_code ret;
255ca1c9b0cSelric krb5_crypto crypto;
256ca1c9b0cSelric
257ca1c9b0cSelric ret = krb5_crypto_init(context, key, 0, &crypto);
258ca1c9b0cSelric if (ret)
259ca1c9b0cSelric return ret;
260ca1c9b0cSelric
261ca1c9b0cSelric if (ivec) {
262ca1c9b0cSelric size_t blocksize;
263ca1c9b0cSelric
264ca1c9b0cSelric ret = krb5_crypto_getblocksize(context, crypto, &blocksize);
265ca1c9b0cSelric if (ret) {
266ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
267ca1c9b0cSelric return ret;
268ca1c9b0cSelric }
269ca1c9b0cSelric
270ca1c9b0cSelric if (blocksize > ivec->length) {
271ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
272ca1c9b0cSelric return KRB5_BAD_MSIZE;
273ca1c9b0cSelric }
274ca1c9b0cSelric }
275ca1c9b0cSelric
276ca1c9b0cSelric ret = krb5_encrypt_ivec(context, crypto, usage,
277ca1c9b0cSelric input->data, input->length,
278ca1c9b0cSelric &output->ciphertext,
279ca1c9b0cSelric ivec ? ivec->data : NULL);
280ca1c9b0cSelric output->kvno = 0;
281ca1c9b0cSelric krb5_crypto_getenctype(context, crypto, &output->enctype);
282ca1c9b0cSelric
283ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
284ca1c9b0cSelric
285ca1c9b0cSelric return ret ;
286ca1c9b0cSelric }
287ca1c9b0cSelric
288ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_encrypt_length(krb5_context context,krb5_enctype enctype,size_t inputlen,size_t * length)289ca1c9b0cSelric krb5_c_encrypt_length(krb5_context context,
290ca1c9b0cSelric krb5_enctype enctype,
291ca1c9b0cSelric size_t inputlen,
292ca1c9b0cSelric size_t *length)
293ca1c9b0cSelric {
294ca1c9b0cSelric krb5_error_code ret;
295ca1c9b0cSelric krb5_crypto crypto;
296ca1c9b0cSelric krb5_keyblock key;
297ca1c9b0cSelric
298ca1c9b0cSelric ret = krb5_generate_random_keyblock(context, enctype, &key);
299ca1c9b0cSelric if (ret)
300ca1c9b0cSelric return ret;
301ca1c9b0cSelric
302ca1c9b0cSelric ret = krb5_crypto_init(context, &key, 0, &crypto);
303ca1c9b0cSelric krb5_free_keyblock_contents(context, &key);
304ca1c9b0cSelric if (ret)
305ca1c9b0cSelric return ret;
306ca1c9b0cSelric
307ca1c9b0cSelric *length = krb5_get_wrapped_length(context, crypto, inputlen);
308ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
309ca1c9b0cSelric
310ca1c9b0cSelric return 0;
311ca1c9b0cSelric }
312ca1c9b0cSelric
313ca1c9b0cSelric /**
314ca1c9b0cSelric * Deprecated: keytypes doesn't exists, they are really enctypes.
315ca1c9b0cSelric *
316ca1c9b0cSelric * @ingroup krb5_deprecated
317ca1c9b0cSelric */
318ca1c9b0cSelric
319ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_enctype_compare(krb5_context context,krb5_enctype e1,krb5_enctype e2,krb5_boolean * similar)320ca1c9b0cSelric krb5_c_enctype_compare(krb5_context context,
321ca1c9b0cSelric krb5_enctype e1,
322ca1c9b0cSelric krb5_enctype e2,
323ca1c9b0cSelric krb5_boolean *similar)
3244f77a458Spettai KRB5_DEPRECATED_FUNCTION("Use X instead")
325ca1c9b0cSelric {
326ca1c9b0cSelric *similar = (e1 == e2);
327ca1c9b0cSelric return 0;
328ca1c9b0cSelric }
329ca1c9b0cSelric
330ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_make_random_key(krb5_context context,krb5_enctype enctype,krb5_keyblock * random_key)331ca1c9b0cSelric krb5_c_make_random_key(krb5_context context,
332ca1c9b0cSelric krb5_enctype enctype,
333ca1c9b0cSelric krb5_keyblock *random_key)
334ca1c9b0cSelric {
335ca1c9b0cSelric return krb5_generate_random_keyblock(context, enctype, random_key);
336ca1c9b0cSelric }
337ca1c9b0cSelric
338ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_keylengths(krb5_context context,krb5_enctype enctype,size_t * ilen,size_t * keylen)339ca1c9b0cSelric krb5_c_keylengths(krb5_context context,
340ca1c9b0cSelric krb5_enctype enctype,
341ca1c9b0cSelric size_t *ilen,
342ca1c9b0cSelric size_t *keylen)
343ca1c9b0cSelric {
344ca1c9b0cSelric krb5_error_code ret;
345ca1c9b0cSelric
346ca1c9b0cSelric ret = krb5_enctype_keybits(context, enctype, ilen);
347ca1c9b0cSelric if (ret)
348ca1c9b0cSelric return ret;
349ca1c9b0cSelric *ilen = (*ilen + 7) / 8;
350ca1c9b0cSelric return krb5_enctype_keysize(context, enctype, keylen);
351ca1c9b0cSelric }
352ca1c9b0cSelric
353ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_prf_length(krb5_context context,krb5_enctype type,size_t * length)354ca1c9b0cSelric krb5_c_prf_length(krb5_context context,
355ca1c9b0cSelric krb5_enctype type,
356ca1c9b0cSelric size_t *length)
357ca1c9b0cSelric {
358ca1c9b0cSelric return krb5_crypto_prf_length(context, type, length);
359ca1c9b0cSelric }
360ca1c9b0cSelric
361ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_prf(krb5_context context,const krb5_keyblock * key,const krb5_data * input,krb5_data * output)362ca1c9b0cSelric krb5_c_prf(krb5_context context,
363ca1c9b0cSelric const krb5_keyblock *key,
364ca1c9b0cSelric const krb5_data *input,
365ca1c9b0cSelric krb5_data *output)
366ca1c9b0cSelric {
367ca1c9b0cSelric krb5_crypto crypto;
368ca1c9b0cSelric krb5_error_code ret;
369ca1c9b0cSelric
370ca1c9b0cSelric ret = krb5_crypto_init(context, key, 0, &crypto);
371ca1c9b0cSelric if (ret)
372ca1c9b0cSelric return ret;
373ca1c9b0cSelric
374ca1c9b0cSelric ret = krb5_crypto_prf(context, crypto, input, output);
375ca1c9b0cSelric krb5_crypto_destroy(context, crypto);
376ca1c9b0cSelric
377ca1c9b0cSelric return ret;
378ca1c9b0cSelric }
379ca1c9b0cSelric
380ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_c_random_make_octets(krb5_context context,krb5_data * data)381ca1c9b0cSelric krb5_c_random_make_octets(krb5_context context, krb5_data * data)
382ca1c9b0cSelric {
383b9d004c6Schristos krb5_generate_random_block(data->data, data->length);
384b9d004c6Schristos return 0;
385ca1c9b0cSelric }
386ca1c9b0cSelric
387ca1c9b0cSelric /**
388ca1c9b0cSelric * MIT compat glue
389ca1c9b0cSelric *
390ca1c9b0cSelric * @ingroup krb5_ccache
391ca1c9b0cSelric */
392ca1c9b0cSelric
393ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_cc_copy_creds(krb5_context context,const krb5_ccache from,krb5_ccache to)394ca1c9b0cSelric krb5_cc_copy_creds(krb5_context context,
395ca1c9b0cSelric const krb5_ccache from,
396ca1c9b0cSelric krb5_ccache to)
397ca1c9b0cSelric {
398ca1c9b0cSelric return krb5_cc_copy_cache(context, from, to);
399ca1c9b0cSelric }
400ca1c9b0cSelric
401ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_auth_con_getsendsubkey(krb5_context context,krb5_auth_context auth_context,krb5_keyblock ** keyblock)402ca1c9b0cSelric krb5_auth_con_getsendsubkey(krb5_context context, krb5_auth_context auth_context,
403ca1c9b0cSelric krb5_keyblock **keyblock)
404ca1c9b0cSelric {
405ca1c9b0cSelric return krb5_auth_con_getlocalsubkey(context, auth_context, keyblock);
406ca1c9b0cSelric }
407ca1c9b0cSelric
408ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_auth_con_getrecvsubkey(krb5_context context,krb5_auth_context auth_context,krb5_keyblock ** keyblock)409ca1c9b0cSelric krb5_auth_con_getrecvsubkey(krb5_context context, krb5_auth_context auth_context,
410ca1c9b0cSelric krb5_keyblock **keyblock)
411ca1c9b0cSelric {
412ca1c9b0cSelric return krb5_auth_con_getremotesubkey(context, auth_context, keyblock);
413ca1c9b0cSelric }
414ca1c9b0cSelric
415ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_auth_con_setsendsubkey(krb5_context context,krb5_auth_context auth_context,krb5_keyblock * keyblock)416ca1c9b0cSelric krb5_auth_con_setsendsubkey(krb5_context context, krb5_auth_context auth_context,
417ca1c9b0cSelric krb5_keyblock *keyblock)
418ca1c9b0cSelric {
419ca1c9b0cSelric return krb5_auth_con_setlocalsubkey(context, auth_context, keyblock);
420ca1c9b0cSelric }
421ca1c9b0cSelric
422ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_auth_con_setrecvsubkey(krb5_context context,krb5_auth_context auth_context,krb5_keyblock * keyblock)423ca1c9b0cSelric krb5_auth_con_setrecvsubkey(krb5_context context, krb5_auth_context auth_context,
424ca1c9b0cSelric krb5_keyblock *keyblock)
425ca1c9b0cSelric {
426ca1c9b0cSelric return krb5_auth_con_setremotesubkey(context, auth_context, keyblock);
427ca1c9b0cSelric }
428ca1c9b0cSelric
429ca1c9b0cSelric KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_free_default_realm(krb5_context context,krb5_realm realm)430ca1c9b0cSelric krb5_free_default_realm(krb5_context context, krb5_realm realm)
431ca1c9b0cSelric {
432ca1c9b0cSelric return krb5_xfree(realm);
433ca1c9b0cSelric }
434ca1c9b0cSelric
435ca1c9b0cSelric #endif /* HEIMDAL_SMALLER */
436