source: heimdal/trunk/lib/krb5/deprecated.c

Last change on this file was 1, checked in by Paul Smedley, 10 years ago

Initial commit of Heimdal 1.5.3

File size: 14.7 KB
Line 
1/*
2 * Copyright (c) 1997 - 2009 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include "krb5_locl.h"
35
36#undef __attribute__
37#define __attribute__(x)
38
39#ifndef HEIMDAL_SMALLER
40
41/**
42 * Same as krb5_data_free(). MIT compat.
43 *
44 * Deprecated: use krb5_data_free().
45 *
46 * @param context Kerberos 5 context.
47 * @param data krb5_data to free.
48 *
49 * @ingroup krb5_deprecated
50 */
51
52KRB5_LIB_FUNCTION void KRB5_LIB_CALL
53krb5_free_data_contents(krb5_context context, krb5_data *data)
54 KRB5_DEPRECATED_FUNCTION("Use X instead")
55{
56 krb5_data_free(data);
57}
58
59/**
60 * Deprecated: keytypes doesn't exists, they are really enctypes.
61 *
62 * @ingroup krb5_deprecated
63 */
64
65KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
66krb5_keytype_to_enctypes_default (krb5_context context,
67 krb5_keytype keytype,
68 unsigned *len,
69 krb5_enctype **val)
70 KRB5_DEPRECATED_FUNCTION("Use X instead")
71{
72 unsigned int i, n;
73 krb5_enctype *ret;
74
75 if (keytype != KEYTYPE_DES || context->etypes_des == NULL)
76 return krb5_keytype_to_enctypes (context, keytype, len, val);
77
78 for (n = 0; context->etypes_des[n]; ++n)
79 ;
80 ret = malloc (n * sizeof(*ret));
81 if (ret == NULL && n != 0) {
82 krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", ""));
83 return ENOMEM;
84 }
85 for (i = 0; i < n; ++i)
86 ret[i] = context->etypes_des[i];
87 *len = n;
88 *val = ret;
89 return 0;
90}
91
92
93static struct {
94 const char *name;
95 krb5_keytype type;
96} keys[] = {
97 { "null", ENCTYPE_NULL },
98 { "des", ETYPE_DES_CBC_CRC },
99 { "des3", ETYPE_OLD_DES3_CBC_SHA1 },
100 { "aes-128", ETYPE_AES128_CTS_HMAC_SHA1_96 },
101 { "aes-256", ETYPE_AES256_CTS_HMAC_SHA1_96 },
102 { "arcfour", ETYPE_ARCFOUR_HMAC_MD5 },
103 { "arcfour-56", ETYPE_ARCFOUR_HMAC_MD5_56 }
104};
105
106static int num_keys = sizeof(keys) / sizeof(keys[0]);
107
108/**
109 * Deprecated: keytypes doesn't exists, they are really enctypes in
110 * most cases, use krb5_enctype_to_string().
111 *
112 * @ingroup krb5_deprecated
113 */
114
115KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
116krb5_keytype_to_string(krb5_context context,
117 krb5_keytype keytype,
118 char **string)
119 KRB5_DEPRECATED_FUNCTION("Use X instead")
120{
121 const char *name = NULL;
122 int i;
123
124 for(i = 0; i < num_keys; i++) {
125 if(keys[i].type == keytype) {
126 name = keys[i].name;
127 break;
128 }
129 }
130
131 if(i >= num_keys) {
132 krb5_set_error_message(context, KRB5_PROG_KEYTYPE_NOSUPP,
133 "key type %d not supported", keytype);
134 return KRB5_PROG_KEYTYPE_NOSUPP;
135 }
136 *string = strdup(name);
137 if(*string == NULL) {
138 krb5_set_error_message(context, ENOMEM,
139 N_("malloc: out of memory", ""));
140 return ENOMEM;
141 }
142 return 0;
143}
144
145/**
146 * Deprecated: keytypes doesn't exists, they are really enctypes in
147 * most cases, use krb5_string_to_enctype().
148 *
149 * @ingroup krb5_deprecated
150 */
151
152KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
153krb5_string_to_keytype(krb5_context context,
154 const char *string,
155 krb5_keytype *keytype)
156 KRB5_DEPRECATED_FUNCTION("Use X instead")
157{
158 char *end;
159 int i;
160
161 for(i = 0; i < num_keys; i++)
162 if(strcasecmp(keys[i].name, string) == 0){
163 *keytype = keys[i].type;
164 return 0;
165 }
166
167 /* check if the enctype is a number */
168 *keytype = strtol(string, &end, 0);
169 if(*end == '\0' && *keytype != 0) {
170 if (krb5_enctype_valid(context, *keytype) == 0)
171 return 0;
172 }
173
174 krb5_set_error_message(context, KRB5_PROG_KEYTYPE_NOSUPP,
175 "key type %s not supported", string);
176 return KRB5_PROG_KEYTYPE_NOSUPP;
177}
178
179/**
180 * Deprecated: use krb5_get_init_creds() and friends.
181 *
182 * @ingroup krb5_deprecated
183 */
184
185KRB5_LIB_FUNCTION krb5_error_code KRB5_CALLCONV
186krb5_password_key_proc (krb5_context context,
187 krb5_enctype type,
188 krb5_salt salt,
189 krb5_const_pointer keyseed,
190 krb5_keyblock **key)
191 KRB5_DEPRECATED_FUNCTION("Use X instead")
192{
193 krb5_error_code ret;
194 const char *password = (const char *)keyseed;
195 char buf[BUFSIZ];
196
197 *key = malloc (sizeof (**key));
198 if (*key == NULL) {
199 krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
200 return ENOMEM;
201 }
202 if (password == NULL) {
203 if(UI_UTIL_read_pw_string (buf, sizeof(buf), "Password: ", 0)) {
204 free (*key);
205 krb5_clear_error_message(context);
206 return KRB5_LIBOS_PWDINTR;
207 }
208 password = buf;
209 }
210 ret = krb5_string_to_key_salt (context, type, password, salt, *key);
211 memset (buf, 0, sizeof(buf));
212 return ret;
213}
214
215/**
216 * Deprecated: use krb5_get_init_creds() and friends.
217 *
218 * @ingroup krb5_deprecated
219 */
220
221KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
222krb5_get_in_tkt_with_password (krb5_context context,
223 krb5_flags options,
224 krb5_addresses *addrs,
225 const krb5_enctype *etypes,
226 const krb5_preauthtype *pre_auth_types,
227 const char *password,
228 krb5_ccache ccache,
229 krb5_creds *creds,
230 krb5_kdc_rep *ret_as_reply)
231 KRB5_DEPRECATED_FUNCTION("Use X instead")
232{
233 return krb5_get_in_tkt (context,
234 options,
235 addrs,
236 etypes,
237 pre_auth_types,
238 krb5_password_key_proc,
239 password,
240 NULL,
241 NULL,
242 creds,
243 ccache,
244 ret_as_reply);
245}
246
247static krb5_error_code KRB5_CALLCONV
248krb5_skey_key_proc (krb5_context context,
249 krb5_enctype type,
250 krb5_salt salt,
251 krb5_const_pointer keyseed,
252 krb5_keyblock **key)
253{
254 return krb5_copy_keyblock (context, keyseed, key);
255}
256
257/**
258 * Deprecated: use krb5_get_init_creds() and friends.
259 *
260 * @ingroup krb5_deprecated
261 */
262
263KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
264krb5_get_in_tkt_with_skey (krb5_context context,
265 krb5_flags options,
266 krb5_addresses *addrs,
267 const krb5_enctype *etypes,
268 const krb5_preauthtype *pre_auth_types,
269 const krb5_keyblock *key,
270 krb5_ccache ccache,
271 krb5_creds *creds,
272 krb5_kdc_rep *ret_as_reply)
273 KRB5_DEPRECATED_FUNCTION("Use X instead")
274{
275 if(key == NULL)
276 return krb5_get_in_tkt_with_keytab (context,
277 options,
278 addrs,
279 etypes,
280 pre_auth_types,
281 NULL,
282 ccache,
283 creds,
284 ret_as_reply);
285 else
286 return krb5_get_in_tkt (context,
287 options,
288 addrs,
289 etypes,
290 pre_auth_types,
291 krb5_skey_key_proc,
292 key,
293 NULL,
294 NULL,
295 creds,
296 ccache,
297 ret_as_reply);
298}
299
300/**
301 * Deprecated: use krb5_get_init_creds() and friends.
302 *
303 * @ingroup krb5_deprecated
304 */
305
306KRB5_LIB_FUNCTION krb5_error_code KRB5_CALLCONV
307krb5_keytab_key_proc (krb5_context context,
308 krb5_enctype enctype,
309 krb5_salt salt,
310 krb5_const_pointer keyseed,
311 krb5_keyblock **key)
312 KRB5_DEPRECATED_FUNCTION("Use X instead")
313{
314 krb5_keytab_key_proc_args *args = rk_UNCONST(keyseed);
315 krb5_keytab keytab = args->keytab;
316 krb5_principal principal = args->principal;
317 krb5_error_code ret;
318 krb5_keytab real_keytab;
319 krb5_keytab_entry entry;
320
321 if(keytab == NULL)
322 krb5_kt_default(context, &real_keytab);
323 else
324 real_keytab = keytab;
325
326 ret = krb5_kt_get_entry (context, real_keytab, principal,
327 0, enctype, &entry);
328
329 if (keytab == NULL)
330 krb5_kt_close (context, real_keytab);
331
332 if (ret)
333 return ret;
334
335 ret = krb5_copy_keyblock (context, &entry.keyblock, key);
336 krb5_kt_free_entry(context, &entry);
337 return ret;
338}
339
340/**
341 * Deprecated: use krb5_get_init_creds() and friends.
342 *
343 * @ingroup krb5_deprecated
344 */
345
346KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
347krb5_get_in_tkt_with_keytab (krb5_context context,
348 krb5_flags options,
349 krb5_addresses *addrs,
350 const krb5_enctype *etypes,
351 const krb5_preauthtype *pre_auth_types,
352 krb5_keytab keytab,
353 krb5_ccache ccache,
354 krb5_creds *creds,
355 krb5_kdc_rep *ret_as_reply)
356 KRB5_DEPRECATED_FUNCTION("Use X instead")
357{
358 krb5_keytab_key_proc_args a;
359
360 a.principal = creds->client;
361 a.keytab = keytab;
362
363 return krb5_get_in_tkt (context,
364 options,
365 addrs,
366 etypes,
367 pre_auth_types,
368 krb5_keytab_key_proc,
369 &a,
370 NULL,
371 NULL,
372 creds,
373 ccache,
374 ret_as_reply);
375}
376
377/**
378 * Generate a new ccache of type `ops' in `id'.
379 *
380 * Deprecated: use krb5_cc_new_unique() instead.
381 *
382 * @return Return an error code or 0, see krb5_get_error_message().
383 *
384 * @ingroup krb5_ccache
385 */
386
387
388KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
389krb5_cc_gen_new(krb5_context context,
390 const krb5_cc_ops *ops,
391 krb5_ccache *id)
392 KRB5_DEPRECATED_FUNCTION("Use X instead")
393{
394 return krb5_cc_new_unique(context, ops->prefix, NULL, id);
395}
396
397/**
398 * Deprecated: use krb5_principal_get_realm()
399 *
400 * @ingroup krb5_deprecated
401 */
402
403KRB5_LIB_FUNCTION krb5_realm * KRB5_LIB_CALL
404krb5_princ_realm(krb5_context context,
405 krb5_principal principal)
406 KRB5_DEPRECATED_FUNCTION("Use X instead")
407{
408 return &principal->realm;
409}
410
411
412/**
413 * Deprecated: use krb5_principal_set_realm()
414 *
415 * @ingroup krb5_deprecated
416 */
417
418KRB5_LIB_FUNCTION void KRB5_LIB_CALL
419krb5_princ_set_realm(krb5_context context,
420 krb5_principal principal,
421 krb5_realm *realm)
422 KRB5_DEPRECATED_FUNCTION("Use X instead")
423{
424 principal->realm = *realm;
425}
426
427/**
428 * Deprecated: use krb5_free_cred_contents()
429 *
430 * @ingroup krb5_deprecated
431 */
432
433/* keep this for compatibility with older code */
434KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
435krb5_free_creds_contents (krb5_context context, krb5_creds *c)
436 KRB5_DEPRECATED_FUNCTION("Use X instead")
437{
438 return krb5_free_cred_contents (context, c);
439}
440
441/**
442 * Free the error message returned by krb5_get_error_string().
443 *
444 * Deprecated: use krb5_free_error_message()
445 *
446 * @param context Kerberos context
447 * @param str error message to free
448 *
449 * @ingroup krb5_deprecated
450 */
451
452KRB5_LIB_FUNCTION void KRB5_LIB_CALL
453krb5_free_error_string(krb5_context context, char *str)
454 KRB5_DEPRECATED_FUNCTION("Use X instead")
455{
456 krb5_free_error_message(context, str);
457}
458
459/**
460 * Set the error message returned by krb5_get_error_string().
461 *
462 * Deprecated: use krb5_get_error_message()
463 *
464 * @param context Kerberos context
465 * @param fmt error message to free
466 *
467 * @return Return an error code or 0.
468 *
469 * @ingroup krb5_deprecated
470 */
471
472KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
473krb5_set_error_string(krb5_context context, const char *fmt, ...)
474 __attribute__((format (printf, 2, 3)))
475 KRB5_DEPRECATED_FUNCTION("Use X instead")
476{
477 va_list ap;
478
479 va_start(ap, fmt);
480 krb5_vset_error_message (context, 0, fmt, ap);
481 va_end(ap);
482 return 0;
483}
484
485/**
486 * Set the error message returned by krb5_get_error_string(),
487 * deprecated, use krb5_set_error_message().
488 *
489 * Deprecated: use krb5_vset_error_message()
490 *
491 * @param context Kerberos context
492 * @param msg error message to free
493 *
494 * @return Return an error code or 0.
495 *
496 * @ingroup krb5_deprecated
497 */
498
499KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
500krb5_vset_error_string(krb5_context context, const char *fmt, va_list args)
501 __attribute__ ((format (printf, 2, 0)))
502 KRB5_DEPRECATED_FUNCTION("Use X instead")
503{
504 krb5_vset_error_message(context, 0, fmt, args);
505 return 0;
506}
507
508/**
509 * Clear the error message returned by krb5_get_error_string().
510 *
511 * Deprecated: use krb5_clear_error_message()
512 *
513 * @param context Kerberos context
514 *
515 * @ingroup krb5_deprecated
516 */
517
518KRB5_LIB_FUNCTION void KRB5_LIB_CALL
519krb5_clear_error_string(krb5_context context)
520 KRB5_DEPRECATED_FUNCTION("Use X instead")
521{
522 krb5_clear_error_message(context);
523}
524
525/**
526 * Deprecated: use krb5_get_credentials_with_flags().
527 *
528 * @ingroup krb5_deprecated
529 */
530
531KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
532krb5_get_cred_from_kdc_opt(krb5_context context,
533 krb5_ccache ccache,
534 krb5_creds *in_creds,
535 krb5_creds **out_creds,
536 krb5_creds ***ret_tgts,
537 krb5_flags flags)
538 KRB5_DEPRECATED_FUNCTION("Use X instead")
539{
540 krb5_kdc_flags f;
541 f.i = flags;
542 return _krb5_get_cred_kdc_any(context, f, ccache,
543 in_creds, NULL, NULL,
544 out_creds, ret_tgts);
545}
546
547/**
548 * Deprecated: use krb5_get_credentials_with_flags().
549 *
550 * @ingroup krb5_deprecated
551 */
552
553KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
554krb5_get_cred_from_kdc(krb5_context context,
555 krb5_ccache ccache,
556 krb5_creds *in_creds,
557 krb5_creds **out_creds,
558 krb5_creds ***ret_tgts)
559 KRB5_DEPRECATED_FUNCTION("Use X instead")
560{
561 return krb5_get_cred_from_kdc_opt(context, ccache,
562 in_creds, out_creds, ret_tgts, 0);
563}
564
565/**
566 * Deprecated: use krb5_xfree().
567 *
568 * @ingroup krb5_deprecated
569 */
570
571KRB5_LIB_FUNCTION void KRB5_LIB_CALL
572krb5_free_unparsed_name(krb5_context context, char *str)
573 KRB5_DEPRECATED_FUNCTION("Use X instead")
574{
575 krb5_xfree(str);
576}
577
578/**
579 * Deprecated: use krb5_generate_subkey_extended()
580 *
581 * @ingroup krb5_deprecated
582 */
583
584KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
585krb5_generate_subkey(krb5_context context,
586 const krb5_keyblock *key,
587 krb5_keyblock **subkey)
588 KRB5_DEPRECATED_FUNCTION("Use X instead")
589{
590 return krb5_generate_subkey_extended(context, key, ETYPE_NULL, subkey);
591}
592
593/**
594 * Deprecated: use krb5_auth_con_getremoteseqnumber()
595 *
596 * @ingroup krb5_deprecated
597 */
598
599KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
600krb5_auth_getremoteseqnumber(krb5_context context,
601 krb5_auth_context auth_context,
602 int32_t *seqnumber)
603 KRB5_DEPRECATED_FUNCTION("Use X instead")
604{
605 *seqnumber = auth_context->remote_seqnumber;
606 return 0;
607}
608
609#endif /* HEIMDAL_SMALLER */
Note: See TracBrowser for help on using the repository browser.