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