1 /*
2 * COPYRIGHT (C) 2006,2007
3 * THE REGENTS OF THE UNIVERSITY OF MICHIGAN
4 * ALL RIGHTS RESERVED
5 *
6 * Permission is granted to use, copy, create derivative works
7 * and redistribute this software and such derivative works
8 * for any purpose, so long as the name of The University of
9 * Michigan is not used in any advertising or publicity
10 * pertaining to the use of distribution of this software
11 * without specific, written prior authorization. If the
12 * above copyright notice or any other identification of the
13 * University of Michigan is included in any copy of any
14 * portion of this software, then the disclaimer below must
15 * also be included.
16 *
17 * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION
18 * FROM THE UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY
19 * PURPOSE, AND WITHOUT WARRANTY BY THE UNIVERSITY OF
20 * MICHIGAN OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
21 * WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
23 * REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE
24 * FOR ANY DAMAGES, INCLUDING SPECIAL, INDIRECT, INCIDENTAL, OR
25 * CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM ARISING
26 * OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN
27 * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGES.
29 */
30
31 #include <k5-int.h>
32 #include "pkinit_accessor.h"
33
34 #define DEF_FUNC_PTRS(type) \
35 krb5_error_code (*k5int_encode_##type)(const type *, krb5_data **); \
36 krb5_error_code (*k5int_decode_##type)(const krb5_data *, type **)
37
38 #define DEF_FUNC_PTRS_ARRAY(type) \
39 krb5_error_code (*k5int_encode_##type)(const type **, krb5_data **); \
40 krb5_error_code (*k5int_decode_##type)(const krb5_data *, type ***)
41
42 DEF_FUNC_PTRS(krb5_auth_pack);
43 DEF_FUNC_PTRS(krb5_auth_pack_draft9);
44 DEF_FUNC_PTRS(krb5_kdc_dh_key_info);
45 DEF_FUNC_PTRS(krb5_pa_pk_as_rep);
46 DEF_FUNC_PTRS(krb5_pa_pk_as_rep_draft9);
47 DEF_FUNC_PTRS(krb5_pa_pk_as_req);
48 DEF_FUNC_PTRS(krb5_pa_pk_as_req_draft9);
49 DEF_FUNC_PTRS(krb5_reply_key_pack);
50 DEF_FUNC_PTRS(krb5_reply_key_pack_draft9);
51 DEF_FUNC_PTRS_ARRAY(krb5_typed_data);
52
53 /* special cases... */
54 krb5_error_code (*k5int_decode_krb5_principal_name)
55 (const krb5_data *, krb5_principal_data **);
56
57 krb5_error_code (*k5int_encode_krb5_td_dh_parameters)
58 (const krb5_algorithm_identifier **, krb5_data **code);
59 krb5_error_code (*k5int_decode_krb5_td_dh_parameters)
60 (const krb5_data *, krb5_algorithm_identifier ***);
61
62 krb5_error_code (*k5int_encode_krb5_td_trusted_certifiers)
63 (const krb5_external_principal_identifier **, krb5_data **code);
64 krb5_error_code (*k5int_decode_krb5_td_trusted_certifiers)
65 (const krb5_data *, krb5_external_principal_identifier ***);
66
67 krb5_error_code (*k5int_decode_krb5_as_req)
68 (const krb5_data *output, krb5_kdc_req **rep);
69 krb5_error_code (*k5int_encode_krb5_kdc_req_body)
70 (const krb5_kdc_req *rep, krb5_data **code);
71 void KRB5_CALLCONV (*k5int_krb5_free_kdc_req)
72 (krb5_context, krb5_kdc_req * );
73 void (*k5int_set_prompt_types)
74 (krb5_context, krb5_prompt_type *);
75 krb5_error_code (*k5int_encode_krb5_authdata_elt)
76 (const krb5_authdata *rep, krb5_data **code);
77
78
79
80 /*
81 * Grab internal function pointers from the krb5int_accessor
82 * structure and make them available
83 */
84 krb5_error_code
pkinit_accessor_init(void)85 pkinit_accessor_init(void)
86 {
87 krb5_error_code retval;
88 krb5int_access k5int;
89
90 retval = krb5int_accessor(&k5int, KRB5INT_ACCESS_VERSION);
91 if (retval)
92 return retval;
93 #define SET_PTRS(type) \
94 k5int_encode_##type = k5int.encode_##type; \
95 k5int_decode_##type = k5int.decode_##type;
96
97 SET_PTRS(krb5_auth_pack);
98 SET_PTRS(krb5_auth_pack_draft9);
99 SET_PTRS(krb5_kdc_dh_key_info);
100 SET_PTRS(krb5_pa_pk_as_rep);
101 SET_PTRS(krb5_pa_pk_as_rep_draft9);
102 SET_PTRS(krb5_pa_pk_as_req);
103 SET_PTRS(krb5_pa_pk_as_req_draft9);
104 SET_PTRS(krb5_reply_key_pack);
105 SET_PTRS(krb5_reply_key_pack_draft9);
106 SET_PTRS(krb5_td_dh_parameters);
107 SET_PTRS(krb5_td_trusted_certifiers);
108 SET_PTRS(krb5_typed_data);
109
110 /* special cases... */
111 k5int_decode_krb5_principal_name = k5int.decode_krb5_principal_name;
112 k5int_decode_krb5_as_req = k5int.decode_krb5_as_req;
113 k5int_encode_krb5_kdc_req_body = k5int.encode_krb5_kdc_req_body;
114 k5int_krb5_free_kdc_req = k5int.krb5_free_kdc_req;
115 k5int_set_prompt_types = k5int.krb5int_set_prompt_types;
116 k5int_encode_krb5_authdata_elt = k5int.encode_krb5_authdata_elt;
117 return 0;
118 }
119