532cd38d0110d69000483cef52b43d3924d97619
[krb5.git] / src / lib / krb5 / os / accessor.c
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/krb5/os/accessor.c */
3 /*
4  * Copyright 1990, 2008 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 #include "k5-int.h"
28 #include "os-proto.h"
29
30 /* If this trick gets used elsewhere, move it to k5-platform.h.  */
31 #ifndef DESIGNATED_INITIALIZERS
32 #define DESIGNATED_INITIALIZERS                         \
33     /* ANSI/ISO C 1999 supports this...  */             \
34     (__STDC_VERSION__ >= 199901L                        \
35      /* ...as does GCC, since version 2.something.  */  \
36      || (!defined __cplusplus && __GNUC__ >= 3))
37 #endif
38
39 krb5_error_code KRB5_CALLCONV
40 krb5int_accessor(krb5int_access *internals, krb5_int32 version)
41 {
42     if (version == KRB5INT_ACCESS_VERSION) {
43 #if DESIGNATED_INITIALIZERS
44 #define S(FIELD, VAL)   .FIELD = VAL
45 #if defined __GNUC__ && __STDC_VERSION__ < 199901L
46         __extension__
47 #endif
48             static const krb5int_access internals_temp = {
49 #else
50 #define S(FIELD, VAL)   internals_temp.FIELD = VAL
51             krb5int_access internals_temp;
52 #endif
53             S (arcfour_gsscrypt, krb5int_arcfour_gsscrypt),
54             S (auth_con_get_subkey_enctype, krb5_auth_con_get_subkey_enctype),
55
56             S (clean_hostname, krb5int_clean_hostname),
57
58             S (mandatory_cksumtype, krb5int_c_mandatory_cksumtype),
59 #ifndef LEAN_CLIENT
60 #define SC(FIELD, VAL)  S(FIELD, VAL)
61 #else /* disable */
62 #define SC(FIELD, VAL)  S(FIELD, 0)
63 #endif
64             SC (ser_pack_int64, krb5_ser_pack_int64),
65             SC (ser_unpack_int64, krb5_ser_unpack_int64),
66 #undef SC
67
68 #ifdef ENABLE_LDAP
69 #define SC(FIELD, VAL)  S(FIELD, VAL)
70 #else
71 #define SC(FIELD, VAL)  S(FIELD, 0)
72 #endif
73             SC (asn1_ldap_encode_sequence_of_keys, krb5int_ldap_encode_sequence_of_keys),
74             SC (asn1_ldap_decode_sequence_of_keys, krb5int_ldap_decode_sequence_of_keys),
75 #undef SC
76
77 #ifndef DISABLE_PKINIT
78 #define SC(FIELD, VAL)  S(FIELD, VAL)
79 #else /* disable */
80 #define SC(FIELD, VAL)  S(FIELD, 0)
81 #endif
82             SC (encode_krb5_pa_pk_as_req, encode_krb5_pa_pk_as_req),
83             SC (encode_krb5_pa_pk_as_req_draft9, encode_krb5_pa_pk_as_req_draft9),
84             SC (encode_krb5_pa_pk_as_rep, encode_krb5_pa_pk_as_rep),
85             SC (encode_krb5_pa_pk_as_rep_draft9, encode_krb5_pa_pk_as_rep_draft9),
86             SC (encode_krb5_auth_pack, encode_krb5_auth_pack),
87             SC (encode_krb5_auth_pack_draft9, encode_krb5_auth_pack_draft9),
88             SC (encode_krb5_kdc_dh_key_info, encode_krb5_kdc_dh_key_info),
89             SC (encode_krb5_reply_key_pack, encode_krb5_reply_key_pack),
90             SC (encode_krb5_reply_key_pack_draft9, encode_krb5_reply_key_pack_draft9),
91             SC (encode_krb5_typed_data, encode_krb5_typed_data),
92             SC (encode_krb5_td_trusted_certifiers, encode_krb5_td_trusted_certifiers),
93             SC (encode_krb5_td_dh_parameters, encode_krb5_td_dh_parameters),
94             SC (decode_krb5_pa_pk_as_req, decode_krb5_pa_pk_as_req),
95             SC (decode_krb5_pa_pk_as_req_draft9, decode_krb5_pa_pk_as_req_draft9),
96             SC (decode_krb5_pa_pk_as_rep, decode_krb5_pa_pk_as_rep),
97             SC (decode_krb5_pa_pk_as_rep_draft9, decode_krb5_pa_pk_as_rep_draft9),
98             SC (decode_krb5_auth_pack, decode_krb5_auth_pack),
99             SC (decode_krb5_auth_pack_draft9, decode_krb5_auth_pack_draft9),
100             SC (decode_krb5_kdc_dh_key_info, decode_krb5_kdc_dh_key_info),
101             SC (decode_krb5_principal_name, decode_krb5_principal_name),
102             SC (decode_krb5_reply_key_pack, decode_krb5_reply_key_pack),
103             SC (decode_krb5_reply_key_pack_draft9, decode_krb5_reply_key_pack_draft9),
104             SC (decode_krb5_typed_data, decode_krb5_typed_data),
105             SC (decode_krb5_td_trusted_certifiers, decode_krb5_td_trusted_certifiers),
106             SC (decode_krb5_td_dh_parameters, decode_krb5_td_dh_parameters),
107             SC (decode_krb5_as_req, decode_krb5_as_req),
108             SC (encode_krb5_kdc_req_body, encode_krb5_kdc_req_body),
109             SC (free_kdc_req, krb5_free_kdc_req),
110             SC (set_prompt_types, krb5int_set_prompt_types),
111             SC (encode_krb5_authdata_elt, encode_krb5_authdata_elt),
112 #undef SC
113
114             S (encode_krb5_sam_response_2, encode_krb5_sam_response_2),
115             S (encode_krb5_enc_sam_response_enc_2, encode_krb5_enc_sam_response_enc_2),
116             S (encode_enc_ts, encode_krb5_pa_enc_ts),
117             S (decode_enc_ts, decode_krb5_pa_enc_ts),
118             S (encode_enc_data, encode_krb5_enc_data),
119             S(decode_enc_data, decode_krb5_enc_data),
120             S(free_enc_ts, krb5_free_pa_enc_ts),
121             S(free_enc_data, krb5_free_enc_data),
122             S(encrypt_helper, krb5_encrypt_helper),
123
124 #if DESIGNATED_INITIALIZERS
125         };
126 #else
127         0;
128 #endif
129         *internals = internals_temp;
130         return 0;
131     }
132     return KRB5_OBSOLETE_FN;
133 }