1 /*
2  * lib/krb5/os/accessor.c
3  *
4  * Copyright 1990 by the Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  *
26 */
27 
28 #include "k5-int.h"
29 #include "os-proto.h"
30 
31 /* If this trick gets used elsewhere, move it to k5-platform.h.  */
32 #ifndef DESIGNATED_INITIALIZERS
33 /* ANSI/ISO C 1999 supports this...  */
34 #if __STDC_VERSION__ >= 199901L				\
35    /* ...as does GCC, since version 2.something.  */	\
36    || (!defined __cplusplus && __GNUC__ >= 3)
37 #define DESIGNATED_INITIALIZERS	1
38 #else
39 #define DESIGNATED_INITIALIZERS	0
40 #endif
41 #endif
42 
43 krb5_error_code KRB5_CALLCONV
krb5int_accessor(krb5int_access * internals,krb5_int32 version)44 krb5int_accessor(krb5int_access *internals, krb5_int32 version)
45 {
46     if (version == KRB5INT_ACCESS_VERSION) {
47 #if DESIGNATED_INITIALIZERS
48 #define S(FIELD, VAL)   .FIELD = VAL
49 	static const krb5int_access internals_temp = {
50 #else
51 #define S(FIELD, VAL)   internals_temp.FIELD = VAL
52 	    krb5int_access internals_temp;
53 #endif
54 	    S (free_addrlist, krb5int_free_addrlist),
55 	    S (krb5_hmac, krb5_hmac),
56 	    S (md5_hash_provider, &krb5int_hash_md5),
57 	    S (arcfour_enc_provider, &krb5int_enc_arcfour),
58 	    S (sendto_udp, &krb5int_sendto),
59 	    S (add_host_to_list, krb5int_add_host_to_list),
60 #ifdef KRB5_DNS_LOOKUP
61 	    S (make_srv_query_realm, krb5int_make_srv_query_realm),
62 	    S (free_srv_dns_data, krb5int_free_srv_dns_data),
63 	    S (use_dns_kdc, _krb5_use_dns_kdc),
64 #else
65 	    S (make_srv_query_realm, 0),
66 	    S (free_srv_dns_data, 0),
67 	    S (use_dns_kdc, 0),
68 #endif
69             S (clean_hostname, krb5int_clean_hostname),
70 
71 #ifdef KRB5_KRB4_COMPAT
72 	    S (krb_life_to_time, krb5int_krb_life_to_time),
73 	    S (krb_time_to_life, krb5int_krb_time_to_life),
74 	    S (krb524_encode_v4tkt, krb5int_encode_v4tkt),
75 #else
76 	    S (krb_life_to_time, 0),
77 	    S (krb_time_to_life, 0),
78 	    S (krb524_encode_v4tkt, 0),
79 #endif
80 	    S (krb5int_c_mandatory_cksumtype, krb5int_c_mandatory_cksumtype),
81 	    S (krb5_ser_pack_int64, krb5_ser_pack_int64),
82 	    S (krb5_ser_unpack_int64, krb5_ser_unpack_int64),
83 	    S (asn1_ldap_encode_sequence_of_keys, krb5int_ldap_encode_sequence_of_keys),
84 	    S (asn1_ldap_decode_sequence_of_keys, krb5int_ldap_decode_sequence_of_keys),
85 	    S (encode_krb5_pa_pk_as_req, encode_krb5_pa_pk_as_req),
86 	    S (encode_krb5_pa_pk_as_req_draft9, encode_krb5_pa_pk_as_req_draft9),
87             S (encode_krb5_pa_pk_as_rep, encode_krb5_pa_pk_as_rep),
88 	    S (encode_krb5_pa_pk_as_rep_draft9, encode_krb5_pa_pk_as_rep_draft9),
89 	    S (encode_krb5_auth_pack, encode_krb5_auth_pack),
90 	    S (encode_krb5_auth_pack_draft9, encode_krb5_auth_pack_draft9),
91 	    S (encode_krb5_kdc_dh_key_info, encode_krb5_kdc_dh_key_info),
92 	    S (encode_krb5_reply_key_pack, encode_krb5_reply_key_pack),
93 	    S (encode_krb5_reply_key_pack_draft9, encode_krb5_reply_key_pack_draft9),
94 	    S (encode_krb5_typed_data, encode_krb5_typed_data),
95 	    S (encode_krb5_td_trusted_certifiers, encode_krb5_td_trusted_certifiers),
96 	    S (encode_krb5_td_dh_parameters, encode_krb5_td_dh_parameters),
97 	    S (decode_krb5_pa_pk_as_req, decode_krb5_pa_pk_as_req),
98 	    S (decode_krb5_pa_pk_as_req_draft9, decode_krb5_pa_pk_as_req_draft9),
99 	    S (decode_krb5_pa_pk_as_rep, decode_krb5_pa_pk_as_rep),
100 	    S (decode_krb5_pa_pk_as_rep_draft9, decode_krb5_pa_pk_as_rep_draft9),
101 	    S (decode_krb5_auth_pack, decode_krb5_auth_pack),
102 	    S (decode_krb5_auth_pack_draft9, decode_krb5_auth_pack_draft9),
103 	    S (decode_krb5_kdc_dh_key_info, decode_krb5_kdc_dh_key_info),
104 	    S (decode_krb5_principal_name, decode_krb5_principal_name),
105 	    S (decode_krb5_reply_key_pack, decode_krb5_reply_key_pack),
106 	    S (decode_krb5_reply_key_pack_draft9, decode_krb5_reply_key_pack_draft9),
107 	    S (decode_krb5_typed_data, decode_krb5_typed_data),
108 	    S (decode_krb5_td_trusted_certifiers, decode_krb5_td_trusted_certifiers),
109 	    S (decode_krb5_td_dh_parameters, decode_krb5_td_dh_parameters),
110 	    S (decode_krb5_as_req, decode_krb5_as_req),
111 	    S (encode_krb5_kdc_req_body, encode_krb5_kdc_req_body),
112 	    S (krb5_free_kdc_req, krb5_free_kdc_req),
113 	    S (krb5int_set_prompt_types, krb5int_set_prompt_types),
114 	    S (encode_krb5_authdata_elt, encode_krb5_authdata_elt),
115 #if DESIGNATED_INITIALIZERS
116 	};
117 #else
118 	/*LINTED*/
119 	0;
120 #endif
121 	*internals = internals_temp;
122 	return 0;
123     }
124     return KRB5_OBSOLETE_FN;
125 }
126