2 * Copyright (c) 1997 - 2009 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
34 #include "krb5_locl.h"
37 #define __attribute__(x)
39 #ifndef HEIMDAL_SMALLER
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")
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
,
70 KRB5_DEPRECATED_FUNCTION("Use X instead")
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", ""));
85 for (i
= 0; i
< n
; ++i
)
86 ret
[i
] = context
->etypes_des
[i
];
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
,
119 KRB5_DEPRECATED_FUNCTION("Use X instead")
121 const char *name
= NULL
;
124 for(i
= 0; i
< num_keys
; i
++) {
125 if(keys
[i
].type
== keytype
) {
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", ""));
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
,
155 krb5_keytype
*keytype
)
156 KRB5_DEPRECATED_FUNCTION("Use X instead")
161 for(i
= 0; i
< num_keys
; i
++)
162 if(strcasecmp(keys
[i
].name
, string
) == 0){
163 *keytype
= keys
[i
].type
;
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)
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
,
189 krb5_const_pointer keyseed
,
191 KRB5_DEPRECATED_FUNCTION("Use X instead")
194 const char *password
= (const char *)keyseed
;
197 *key
= malloc (sizeof (**key
));
199 krb5_set_error_message(context
, ENOMEM
, "malloc: out of memory");
202 if (password
== NULL
) {
203 if(UI_UTIL_read_pw_string (buf
, sizeof(buf
), "Password: ", 0)) {
205 krb5_clear_error_message(context
);
206 return KRB5_LIBOS_PWDINTR
;
210 ret
= krb5_string_to_key_salt (context
, type
, password
, salt
, *key
);
211 memset (buf
, 0, sizeof(buf
));
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
,
224 krb5_addresses
*addrs
,
225 const krb5_enctype
*etypes
,
226 const krb5_preauthtype
*pre_auth_types
,
227 const char *password
,
230 krb5_kdc_rep
*ret_as_reply
)
231 KRB5_DEPRECATED_FUNCTION("Use X instead")
233 return krb5_get_in_tkt (context
,
238 krb5_password_key_proc
,
247 static krb5_error_code KRB5_CALLCONV
248 krb5_skey_key_proc (krb5_context context
,
251 krb5_const_pointer keyseed
,
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
,
266 krb5_addresses
*addrs
,
267 const krb5_enctype
*etypes
,
268 const krb5_preauthtype
*pre_auth_types
,
269 const krb5_keyblock
*key
,
272 krb5_kdc_rep
*ret_as_reply
)
273 KRB5_DEPRECATED_FUNCTION("Use X instead")
276 return krb5_get_in_tkt_with_keytab (context
,
286 return krb5_get_in_tkt (context
,
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
,
310 krb5_const_pointer keyseed
,
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
;
318 krb5_keytab real_keytab
;
319 krb5_keytab_entry entry
;
322 krb5_kt_default(context
, &real_keytab
);
324 real_keytab
= keytab
;
326 ret
= krb5_kt_get_entry (context
, real_keytab
, principal
,
330 krb5_kt_close (context
, real_keytab
);
335 ret
= krb5_copy_keyblock (context
, &entry
.keyblock
, key
);
336 krb5_kt_free_entry(context
, &entry
);
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
,
349 krb5_addresses
*addrs
,
350 const krb5_enctype
*etypes
,
351 const krb5_preauthtype
*pre_auth_types
,
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
;
363 return krb5_get_in_tkt (context
,
368 krb5_keytab_key_proc
,
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
,
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
,
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")
480 krb5_vset_error_message (context
, 0, fmt
, ap
);
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
);
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
,
534 krb5_creds
*in_creds
,
535 krb5_creds
**out_creds
,
536 krb5_creds
***ret_tgts
,
538 KRB5_DEPRECATED_FUNCTION("Use X instead")
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
,
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")
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
,
603 KRB5_DEPRECATED_FUNCTION("Use X instead")
605 *seqnumber
= auth_context
->remote_seqnumber
;
609 #endif /* HEIMDAL_SMALLER */