Rename subsystem_DEPRECATED to subsystem_DEPRECATED_FUNCTION(X)
[heimdal.git] / lib / krb5 / deprecated.c
blob1d44d21b170683cd2b70c496482499f170a53510
1 /*
2 * Copyright (c) 1997 - 2009 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
34 #include "krb5_locl.h"
36 #undef __attribute__
37 #define __attribute__(x)
39 #ifndef HEIMDAL_SMALLER
41 /**
42 * Same as krb5_data_free(). MIT compat.
44 * Deprecated: use krb5_data_free().
46 * @param context Kerberos 5 context.
47 * @param data krb5_data to free.
49 * @ingroup krb5_deprecated
52 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
53 krb5_free_data_contents(krb5_context context, krb5_data *data)
54 KRB5_DEPRECATED_FUNCTION("Use X instead")
56 krb5_data_free(data);
59 /**
60 * Deprecated: keytypes doesn't exists, they are really enctypes.
62 * @ingroup krb5_deprecated
65 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
66 krb5_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")
72 unsigned int i, n;
73 krb5_enctype *ret;
75 if (keytype != KEYTYPE_DES || context->etypes_des == NULL)
76 return krb5_keytype_to_enctypes (context, keytype, len, val);
78 for (n = 0; context->etypes_des[n]; ++n)
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;
85 for (i = 0; i < n; ++i)
86 ret[i] = context->etypes_des[i];
87 *len = n;
88 *val = ret;
89 return 0;
93 static 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 }
106 static int num_keys = sizeof(keys) / sizeof(keys[0]);
109 * Deprecated: keytypes doesn't exists, they are really enctypes in
110 * most cases, use krb5_enctype_to_string().
112 * @ingroup krb5_deprecated
115 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
116 krb5_keytype_to_string(krb5_context context,
117 krb5_keytype keytype,
118 char **string)
119 KRB5_DEPRECATED_FUNCTION("Use X instead")
121 const char *name = NULL;
122 int i;
124 for(i = 0; i < num_keys; i++) {
125 if(keys[i].type == keytype) {
126 name = keys[i].name;
127 break;
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;
136 *string = strdup(name);
137 if(*string == NULL) {
138 krb5_set_error_message(context, ENOMEM,
139 N_("malloc: out of memory", ""));
140 return ENOMEM;
142 return 0;
146 * Deprecated: keytypes doesn't exists, they are really enctypes in
147 * most cases, use krb5_string_to_enctype().
149 * @ingroup krb5_deprecated
152 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
153 krb5_string_to_keytype(krb5_context context,
154 const char *string,
155 krb5_keytype *keytype)
156 KRB5_DEPRECATED_FUNCTION("Use X instead")
158 char *end;
159 int i;
161 for(i = 0; i < num_keys; i++)
162 if(strcasecmp(keys[i].name, string) == 0){
163 *keytype = keys[i].type;
164 return 0;
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;
174 krb5_set_error_message(context, KRB5_PROG_KEYTYPE_NOSUPP,
175 "key type %s not supported", string);
176 return KRB5_PROG_KEYTYPE_NOSUPP;
180 * Deprecated: use krb5_get_init_creds() and friends.
182 * @ingroup krb5_deprecated
185 KRB5_LIB_FUNCTION krb5_error_code KRB5_CALLCONV
186 krb5_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")
193 krb5_error_code ret;
194 const char *password = (const char *)keyseed;
195 char buf[BUFSIZ];
197 *key = malloc (sizeof (**key));
198 if (*key == NULL) {
199 krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
200 return ENOMEM;
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;
208 password = buf;
210 ret = krb5_string_to_key_salt (context, type, password, salt, *key);
211 memset (buf, 0, sizeof(buf));
212 return ret;
216 * Deprecated: use krb5_get_init_creds() and friends.
218 * @ingroup krb5_deprecated
221 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
222 krb5_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")
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);
247 static krb5_error_code KRB5_CALLCONV
248 krb5_skey_key_proc (krb5_context context,
249 krb5_enctype type,
250 krb5_salt salt,
251 krb5_const_pointer keyseed,
252 krb5_keyblock **key)
254 return krb5_copy_keyblock (context, keyseed, key);
258 * Deprecated: use krb5_get_init_creds() and friends.
260 * @ingroup krb5_deprecated
263 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
264 krb5_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")
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);
301 * Deprecated: use krb5_get_init_creds() and friends.
303 * @ingroup krb5_deprecated
306 KRB5_LIB_FUNCTION krb5_error_code KRB5_CALLCONV
307 krb5_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")
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;
321 if(keytab == NULL)
322 krb5_kt_default(context, &real_keytab);
323 else
324 real_keytab = keytab;
326 ret = krb5_kt_get_entry (context, real_keytab, principal,
327 0, enctype, &entry);
329 if (keytab == NULL)
330 krb5_kt_close (context, real_keytab);
332 if (ret)
333 return ret;
335 ret = krb5_copy_keyblock (context, &entry.keyblock, key);
336 krb5_kt_free_entry(context, &entry);
337 return ret;
341 * Deprecated: use krb5_get_init_creds() and friends.
343 * @ingroup krb5_deprecated
346 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
347 krb5_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")
358 krb5_keytab_key_proc_args a;
360 a.principal = creds->client;
361 a.keytab = keytab;
363 return krb5_get_in_tkt (context,
364 options,
365 addrs,
366 etypes,
367 pre_auth_types,
368 krb5_keytab_key_proc,
370 NULL,
371 NULL,
372 creds,
373 ccache,
374 ret_as_reply);
378 * Generate a new ccache of type `ops' in `id'.
380 * Deprecated: use krb5_cc_new_unique() instead.
382 * @return Return an error code or 0, see krb5_get_error_message().
384 * @ingroup krb5_ccache
388 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
389 krb5_cc_gen_new(krb5_context context,
390 const krb5_cc_ops *ops,
391 krb5_ccache *id)
392 KRB5_DEPRECATED_FUNCTION("Use X instead")
394 return krb5_cc_new_unique(context, ops->prefix, NULL, id);
398 * Deprecated: use krb5_principal_get_realm()
400 * @ingroup krb5_deprecated
403 KRB5_LIB_FUNCTION krb5_realm * KRB5_LIB_CALL
404 krb5_princ_realm(krb5_context context,
405 krb5_principal principal)
406 KRB5_DEPRECATED_FUNCTION("Use X instead")
408 return &principal->realm;
413 * Deprecated: use krb5_principal_set_realm()
415 * @ingroup krb5_deprecated
418 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
419 krb5_princ_set_realm(krb5_context context,
420 krb5_principal principal,
421 krb5_realm *realm)
422 KRB5_DEPRECATED_FUNCTION("Use X instead")
424 principal->realm = *realm;
428 * Deprecated: use krb5_free_cred_contents()
430 * @ingroup krb5_deprecated
433 /* keep this for compatibility with older code */
434 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
435 krb5_free_creds_contents (krb5_context context, krb5_creds *c)
436 KRB5_DEPRECATED_FUNCTION("Use X instead")
438 return krb5_free_cred_contents (context, c);
442 * Free the error message returned by krb5_get_error_string().
444 * Deprecated: use krb5_free_error_message()
446 * @param context Kerberos context
447 * @param str error message to free
449 * @ingroup krb5_deprecated
452 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
453 krb5_free_error_string(krb5_context context, char *str)
454 KRB5_DEPRECATED_FUNCTION("Use X instead")
456 krb5_free_error_message(context, str);
460 * Set the error message returned by krb5_get_error_string().
462 * Deprecated: use krb5_get_error_message()
464 * @param context Kerberos context
465 * @param fmt error message to free
467 * @return Return an error code or 0.
469 * @ingroup krb5_deprecated
472 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
473 krb5_set_error_string(krb5_context context, const char *fmt, ...)
474 __attribute__((format (printf, 2, 3)))
475 KRB5_DEPRECATED_FUNCTION("Use X instead")
477 va_list ap;
479 va_start(ap, fmt);
480 krb5_vset_error_message (context, 0, fmt, ap);
481 va_end(ap);
482 return 0;
486 * Set the error message returned by krb5_get_error_string(),
487 * deprecated, use krb5_set_error_message().
489 * Deprecated: use krb5_vset_error_message()
491 * @param context Kerberos context
492 * @param msg error message to free
494 * @return Return an error code or 0.
496 * @ingroup krb5_deprecated
499 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
500 krb5_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")
504 krb5_vset_error_message(context, 0, fmt, args);
505 return 0;
509 * Clear the error message returned by krb5_get_error_string().
511 * Deprecated: use krb5_clear_error_message()
513 * @param context Kerberos context
515 * @ingroup krb5_deprecated
518 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
519 krb5_clear_error_string(krb5_context context)
520 KRB5_DEPRECATED_FUNCTION("Use X instead")
522 krb5_clear_error_message(context);
526 * Deprecated: use krb5_get_credentials_with_flags().
528 * @ingroup krb5_deprecated
531 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
532 krb5_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")
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);
548 * Deprecated: use krb5_get_credentials_with_flags().
550 * @ingroup krb5_deprecated
553 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
554 krb5_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")
561 return krb5_get_cred_from_kdc_opt(context, ccache,
562 in_creds, out_creds, ret_tgts, 0);
566 * Deprecated: use krb5_xfree().
568 * @ingroup krb5_deprecated
571 KRB5_LIB_FUNCTION void KRB5_LIB_CALL
572 krb5_free_unparsed_name(krb5_context context, char *str)
573 KRB5_DEPRECATED_FUNCTION("Use X instead")
575 krb5_xfree(str);
579 * Deprecated: use krb5_generate_subkey_extended()
581 * @ingroup krb5_deprecated
584 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
585 krb5_generate_subkey(krb5_context context,
586 const krb5_keyblock *key,
587 krb5_keyblock **subkey)
588 KRB5_DEPRECATED_FUNCTION("Use X instead")
590 return krb5_generate_subkey_extended(context, key, ETYPE_NULL, subkey);
594 * Deprecated: use krb5_auth_con_getremoteseqnumber()
596 * @ingroup krb5_deprecated
599 KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
600 krb5_auth_getremoteseqnumber(krb5_context context,
601 krb5_auth_context auth_context,
602 int32_t *seqnumber)
603 KRB5_DEPRECATED_FUNCTION("Use X instead")
605 *seqnumber = auth_context->remote_seqnumber;
606 return 0;
609 #endif /* HEIMDAL_SMALLER */