aboutsummaryrefslogtreecommitdiff
path: root/src/lib/krb5/asn.1/asn1_k_decode.h
blob: ed51ab1646861a1ed3572848c1945454d906fb39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* lib/krb5/asn.1/asn1_k_decode.h */
/*
 * Copyright 1994 by the Massachusetts Institute of Technology.
 * All Rights Reserved.
 *
 * Export of this software from the United States of America may
 *   require a specific license from the United States Government.
 *   It is the responsibility of any person or organization contemplating
 *   export to obtain such a license before exporting.
 *
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
 * distribute this software and its documentation for any purpose and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of M.I.T. not be used in advertising or publicity pertaining
 * to distribution of the software without specific, written prior
 * permission.  Furthermore if you modify this software you must label
 * your software as modified software and not distribute it in such a
 * fashion that it might be confused with the original M.I.T. software.
 * M.I.T. makes no representations about the suitability of
 * this software for any purpose.  It is provided "as is" without express
 * or implied warranty.
 */

#ifndef __ASN1_DECODE_KRB5_H__
#define __ASN1_DECODE_KRB5_H__

#include "k5-int.h"
#include "krbasn1.h"
#include "asn1buf.h"

/* asn1_error_code asn1_decode_scalar_type(asn1buf *buf, krb5_scalar *val); */
/*
 * requires  *buf is allocated, *buf's current position points to the
 *            beginning of an encoding (<id> <len> <contents>),
 *            *val is allocated
 *
 * effects   Decodes the encoding in *buf, returning the result in *val.
 *
 *           Returns ASN1_BAD_ID if the encoded id does not indicate
 *           the proper type.
 *
 *           Returns ASN1_OVERRUN if the encoded length exceeds
 *           the bounds of *buf
 */


/*
 * asn1_error_code asn1_decode_structure_type(asn1buf *buf,
 *                                            krb5_structure *val);
 */
/*
 * requires  *buf is allocated, *buf's current position points to the
 *            beginning of an encoding (<id> <len> <contents>),
 *            *val is allocated
 *
 *           Assumes that *val is a freshly-allocated structure (i.e.
 *            does not attempt to clean up or free *val).
 * effects   Decodes the encoding in *buf, returning the result in *val.
 *
 *           Returns ASN1_BAD_ID if the encoded id does not indicate
 *           the proper type.
 *
 *           Returns ASN1_OVERRUN if the encoded length exceeds the
 *           bounds of *buf
 */

/* asn1_error_code asn1_decode_array_type(asn1buf *buf, krb5_scalar ***val); */
/*
 * requires  *buf is allocated, *buf's current position points to the
 *           beginning of an encoding (<id> <len> <contents>)
 *
 *           Assumes that *val is empty (i.e. does not attempt to
 *           clean up or free *val).
 *
 * effects   Decodes the encoding in *buf, returning the result in *val.
 *
 *           Returns ASN1_BAD_ID if the encoded id does not indicate
 *           the proper type.
 *
 *           Returns ASN1_OVERRUN if the encoded length exceeds the
 *           bounds of *buf
 */

/* scalars */
asn1_error_code asn1_decode_int(asn1buf *buf, int *val);
asn1_error_code asn1_decode_int32(asn1buf *buf, krb5_int32 *val);
asn1_error_code asn1_decode_kvno(asn1buf *buf, krb5_kvno *val);
asn1_error_code asn1_decode_enctype(asn1buf *buf, krb5_enctype *val);
asn1_error_code asn1_decode_msgtype(asn1buf *buf, krb5_msgtype *val);
asn1_error_code asn1_decode_cksumtype(asn1buf *buf, krb5_cksumtype *val);
asn1_error_code asn1_decode_octet(asn1buf *buf, krb5_octet *val);
asn1_error_code asn1_decode_addrtype(asn1buf *buf, krb5_addrtype *val);
asn1_error_code asn1_decode_authdatatype(asn1buf *buf, krb5_authdatatype *val);
asn1_error_code asn1_decode_ui_2(asn1buf *buf, krb5_ui_2 *val);
asn1_error_code asn1_decode_ui_4(asn1buf *buf, krb5_ui_4 *val);
asn1_error_code asn1_decode_seqnum(asn1buf *buf, krb5_ui_4 *val);
asn1_error_code asn1_decode_kerberos_time(asn1buf *buf, krb5_timestamp *val);
asn1_error_code asn1_decode_sam_flags(asn1buf *buf, krb5_flags *val);

/* structures */
asn1_error_code asn1_decode_realm(asn1buf *buf, krb5_principal *val);
asn1_error_code asn1_decode_principal_name(asn1buf *buf, krb5_principal *val);
asn1_error_code asn1_decode_checksum(asn1buf *buf, krb5_checksum *val);
asn1_error_code asn1_decode_checksum_ptr(asn1buf *buf, krb5_checksum **valptr);
asn1_error_code asn1_decode_encryption_key(asn1buf *buf, krb5_keyblock *val);
asn1_error_code asn1_decode_encryption_key_ptr(asn1buf *buf,
                                               krb5_keyblock **valptr);
asn1_error_code asn1_decode_encrypted_data(asn1buf *buf, krb5_enc_data *val);
asn1_error_code asn1_decode_ticket_flags(asn1buf *buf, krb5_flags *val);
asn1_error_code asn1_decode_transited_encoding(asn1buf *buf,
                                               krb5_transited *val);
asn1_error_code asn1_decode_enc_kdc_rep_part(asn1buf *buf,
                                             krb5_enc_kdc_rep_part *val);
asn1_error_code asn1_decode_krb5_flags(asn1buf *buf, krb5_flags *val);
asn1_error_code asn1_decode_ap_options(asn1buf *buf, krb5_flags *val);
asn1_error_code asn1_decode_kdc_options(asn1buf *buf, krb5_flags *val);
asn1_error_code asn1_decode_ticket(asn1buf *buf, krb5_ticket *val);
asn1_error_code asn1_decode_ticket_ptr(asn1buf *buf, krb5_ticket **valptr);
asn1_error_code asn1_decode_kdc_req(asn1buf *buf, krb5_kdc_req *val);
asn1_error_code asn1_decode_kdc_req_body(asn1buf *buf, krb5_kdc_req *val);
asn1_error_code asn1_decode_krb_safe_body(asn1buf *buf, krb5_safe *val);
asn1_error_code asn1_decode_host_address(asn1buf *buf, krb5_address *val);
asn1_error_code asn1_decode_host_address_ptr(asn1buf *buf,
                                             krb5_address **valptr);
asn1_error_code asn1_decode_kdc_rep(asn1buf *buf, krb5_kdc_rep *val);
asn1_error_code asn1_decode_last_req_entry(asn1buf *buf,
                                           krb5_last_req_entry *val);
asn1_error_code asn1_decode_last_req_entry_ptr(asn1buf *buf,
                                               krb5_last_req_entry **valptr);
asn1_error_code asn1_decode_authdata_elt(asn1buf *buf, krb5_authdata *val);
asn1_error_code asn1_decode_authdata_elt_ptr(asn1buf *buf,
                                             krb5_authdata **valptr);
asn1_error_code asn1_peek_authorization_data(asn1buf *buf,
                                             unsigned int *num,
                                             krb5_authdatatype **val);
asn1_error_code asn1_decode_krb_cred_info(asn1buf *buf, krb5_cred_info *val);
asn1_error_code asn1_decode_krb_cred_info_ptr(asn1buf *buf,
                                              krb5_cred_info **valptr);
asn1_error_code asn1_decode_pa_data(asn1buf *buf, krb5_pa_data *val);
asn1_error_code asn1_decode_pa_data_ptr(asn1buf *buf, krb5_pa_data **valptr);
asn1_error_code asn1_decode_passwdsequence(asn1buf *buf,
                                           passwd_phrase_element *val);
asn1_error_code asn1_decode_passwdsequence_ptr(asn1buf *buf,
                                               passwd_phrase_element **valptr);
asn1_error_code asn1_decode_sam_challenge(asn1buf *buf,
                                          krb5_sam_challenge *val);
asn1_error_code asn1_decode_sam_challenge_2(asn1buf *buf,
                                            krb5_sam_challenge_2 *val);
asn1_error_code
asn1_decode_sam_challenge_2_body(asn1buf *buf,
                                 krb5_sam_challenge_2_body *val);
asn1_error_code asn1_decode_enc_sam_key(asn1buf *buf, krb5_sam_key *val);
asn1_error_code
asn1_decode_enc_sam_response_enc(asn1buf *buf,
                                 krb5_enc_sam_response_enc *val);
asn1_error_code
asn1_decode_enc_sam_response_enc_2(asn1buf *buf,
                                   krb5_enc_sam_response_enc_2 *val);
asn1_error_code asn1_decode_sam_response(asn1buf *buf, krb5_sam_response *val);
asn1_error_code asn1_decode_sam_response_2(asn1buf *buf,
                                           krb5_sam_response_2 *val);
asn1_error_code
asn1_decode_predicted_sam_response(asn1buf *buf,
                                   krb5_predicted_sam_response *val);
asn1_error_code asn1_decode_external_principal_identifier(
    asn1buf *buf, krb5_external_principal_identifier *val);
asn1_error_code asn1_decode_external_principal_identifier_ptr(
    asn1buf *buf, krb5_external_principal_identifier **valptr);
asn1_error_code asn1_decode_pa_pk_as_req(asn1buf *buf, krb5_pa_pk_as_req *val);
asn1_error_code asn1_decode_trusted_ca(asn1buf *buf, krb5_trusted_ca *val);
asn1_error_code asn1_decode_trusted_ca_ptr(asn1buf *buf,
                                           krb5_trusted_ca **valptr);
asn1_error_code asn1_decode_pa_pk_as_req_draft9(asn1buf *buf,
                                                krb5_pa_pk_as_req_draft9 *val);
asn1_error_code asn1_decode_dh_rep_info(asn1buf *buf, krb5_dh_rep_info *val);
asn1_error_code asn1_decode_pk_authenticator(asn1buf *buf,
                                             krb5_pk_authenticator *val);
asn1_error_code
asn1_decode_pk_authenticator_draft9(asn1buf *buf,
                                    krb5_pk_authenticator_draft9 *val);
asn1_error_code asn1_decode_subject_pk_info(asn1buf *buf,
                                            krb5_subject_pk_info *val);
asn1_error_code
asn1_decode_algorithm_identifier(asn1buf *buf, krb5_algorithm_identifier *val);
asn1_error_code
asn1_decode_algorithm_identifier_ptr(asn1buf *buf,
                                     krb5_algorithm_identifier **valptr);
asn1_error_code asn1_decode_auth_pack(asn1buf *buf, krb5_auth_pack *val);
asn1_error_code asn1_decode_auth_pack_draft9(asn1buf *buf,
                                             krb5_auth_pack_draft9 *val);
asn1_error_code asn1_decode_pa_pk_as_rep(asn1buf *buf,
                                         krb5_pa_pk_as_rep *val);
asn1_error_code asn1_decode_pa_pk_as_rep_draft9(asn1buf *buf,
                                                krb5_pa_pk_as_rep_draft9 *val);
asn1_error_code asn1_decode_kdc_dh_key_info(asn1buf *buf,
                                            krb5_kdc_dh_key_info *val);
asn1_error_code asn1_decode_krb5_principal_name(asn1buf *buf,
                                                krb5_principal *val);
asn1_error_code asn1_decode_reply_key_pack(asn1buf *buf,
                                           krb5_reply_key_pack *val);
asn1_error_code
asn1_decode_reply_key_pack_draft9(asn1buf *buf,
                                  krb5_reply_key_pack_draft9 *val);
asn1_error_code
asn1_decode_sequence_of_typed_data(asn1buf *buf, krb5_typed_data ***val);
asn1_error_code asn1_decode_typed_data(asn1buf *buf, krb5_typed_data *val);
asn1_error_code asn1_decode_typed_data_ptr(asn1buf *buf,
                                           krb5_typed_data **valptr);

/* arrays */
asn1_error_code asn1_decode_authorization_data(asn1buf *buf,
                                               krb5_authdata ***val);
asn1_error_code asn1_decode_host_addresses(asn1buf *buf, krb5_address ***val);
asn1_error_code asn1_decode_sequence_of_ticket(asn1buf *buf,
                                               krb5_ticket ***val);
asn1_error_code asn1_decode_sequence_of_krb_cred_info(asn1buf *buf,
                                                      krb5_cred_info ***val);
asn1_error_code asn1_decode_sequence_of_pa_data(asn1buf *buf,
                                                krb5_pa_data ***val);
asn1_error_code asn1_decode_last_req(asn1buf *buf, krb5_last_req_entry ***val);

asn1_error_code asn1_decode_sequence_of_enctype(asn1buf *buf, int *num,
                                                krb5_enctype **val);

asn1_error_code asn1_decode_sequence_of_checksum(asn1buf *buf,
                                                 krb5_checksum ***val);

asn1_error_code asn1_decode_sequence_of_passwdsequence(asn1buf *buf,
                                                       passwd_phrase_element ***val);

asn1_error_code asn1_decode_etype_info(asn1buf *buf,
                                       krb5_etype_info_entry ***val);
asn1_error_code asn1_decode_etype_info2(asn1buf *buf,
                                        krb5_etype_info_entry ***val,
                                        krb5_boolean v1_3_behavior);
asn1_error_code asn1_decode_sequence_of_external_principal_identifier(
    asn1buf *buf, krb5_external_principal_identifier ***val);
asn1_error_code asn1_decode_sequence_of_trusted_ca(asn1buf *buf,
                                                   krb5_trusted_ca ***val);
asn1_error_code asn1_decode_sequence_of_algorithm_identifier(
    asn1buf *buf, krb5_algorithm_identifier ***val);

asn1_error_code asn1_decode_setpw_req(asn1buf *buf, krb5_data *rep,
                                      krb5_principal *principal);
asn1_error_code asn1_decode_pa_for_user(asn1buf *buf, krb5_pa_for_user *val);
asn1_error_code asn1_decode_s4u_userid(asn1buf *buf, krb5_s4u_userid *val);
asn1_error_code asn1_decode_pa_s4u_x509_user(asn1buf *buf,
                                             krb5_pa_s4u_x509_user *val);
asn1_error_code asn1_decode_pa_pac_req(asn1buf *buf, krb5_pa_pac_req *val);

asn1_error_code asn1_decode_fast_armor(asn1buf *buf, krb5_fast_armor *val);

asn1_error_code asn1_decode_fast_armor_ptr(asn1buf *buf,
                                           krb5_fast_armor **val);

asn1_error_code asn1_decode_fast_finished(asn1buf *buf,
                                          krb5_fast_finished *val);

asn1_error_code asn1_decode_fast_finished_ptr(asn1buf *buf,
                                              krb5_fast_finished **val);

asn1_error_code asn1_decode_ad_kdcissued(asn1buf *buf, krb5_ad_kdcissued *val);

asn1_error_code asn1_decode_ad_kdcissued_ptr(asn1buf *buf,
                                             krb5_ad_kdcissued **val);

asn1_error_code asn1_decode_ad_signedpath(asn1buf *buf,
                                          krb5_ad_signedpath *val);

asn1_error_code asn1_decode_iakerb_header(asn1buf *buf,
                                          krb5_iakerb_header *val);

asn1_error_code asn1_decode_iakerb_finished(asn1buf *buf,
                                            krb5_iakerb_finished *val);

asn1_error_code
asn1_decode_kdf_alg_id( asn1buf *buf, krb5_octet_data *val);

 asn1_error_code
asn1_decode_sequence_of_kdf_alg_id(asn1buf *buf,
                                   krb5_octet_data ***val);

#endif