1 /*
2  * src/lib/krb5/asn.1/asn1_k_decode.h
3  *
4  * Copyright 1994 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 #ifndef __ASN1_DECODE_KRB5_H__
28 #define __ASN1_DECODE_KRB5_H__
29 
30 #include "k5-int.h"
31 #include "krbasn1.h"
32 #include "asn1buf.h"
33 
34 /* asn1_error_code asn1_decode_scalar_type(asn1buf *buf, krb5_scalar *val); */
35 /* requires  *buf is allocated, *buf's current position points to the
36               beginning of an encoding (<id> <len> <contents>),
37 	      *val is allocated
38    effects   Decodes the encoding in *buf, returning the result in *val.
39              Returns ASN1_BAD_ID if the encoded id does not
40 	      indicate the proper type.
41              Returns ASN1_OVERRUN if the encoded length exceeds
42 	      the bounds of *buf */
43 
44 
45 /* asn1_error_code asn1_decode_structure_type(asn1buf *buf,
46                                               krb5_structure *val); */
47 /* requires  *buf is allocated, *buf's current position points to the
48               beginning of an encoding (<id> <len> <contents>),
49 	      *val is allocated
50 	     Assumes that *val is a freshly-allocated structure (i.e.
51 	      does not attempt to clean up or free *val).
52    effects   Decodes the encoding in *buf, returning the result in *val.
53              Returns ASN1_BAD_ID if the encoded id does not
54 	      indicate the proper type.
55              Returns ASN1_OVERRUN if the encoded length exceeds
56 	      the bounds of *buf */
57 
58 /* asn1_error_code asn1_decode_array_type(asn1buf *buf, krb5_scalar ***val); */
59 /* requires  *buf is allocated, *buf's current position points to the
60               beginning of an encoding (<id> <len> <contents>)
61 	     Assumes that *val is empty (i.e. does not attempt to
62 	      clean up or free *val).
63    effects   Decodes the encoding in *buf, returning the result in *val.
64              Returns ASN1_BAD_ID if the encoded id does not
65 	      indicate the proper type.
66              Returns ASN1_OVERRUN if the encoded length exceeds
67 	      the bounds of *buf */
68 
69 /* scalars */
70 asn1_error_code asn1_decode_int
71 	(asn1buf *buf, int *val);
72 asn1_error_code asn1_decode_int32
73 	(asn1buf *buf, krb5_int32 *val);
74 asn1_error_code asn1_decode_kvno
75 	(asn1buf *buf, krb5_kvno *val);
76 asn1_error_code asn1_decode_enctype
77 	(asn1buf *buf, krb5_enctype *val);
78 asn1_error_code asn1_decode_msgtype
79 	(asn1buf *buf, krb5_msgtype *val);
80 asn1_error_code asn1_decode_cksumtype
81 	(asn1buf *buf, krb5_cksumtype *val);
82 asn1_error_code asn1_decode_octet
83 	(asn1buf *buf, krb5_octet *val);
84 asn1_error_code asn1_decode_addrtype
85 	(asn1buf *buf, krb5_addrtype *val);
86 asn1_error_code asn1_decode_authdatatype
87 	(asn1buf *buf, krb5_authdatatype *val);
88 asn1_error_code asn1_decode_ui_2
89 	(asn1buf *buf, krb5_ui_2 *val);
90 asn1_error_code asn1_decode_ui_4
91 	(asn1buf *buf, krb5_ui_4 *val);
92 asn1_error_code asn1_decode_seqnum
93 	(asn1buf *buf, krb5_ui_4 *val);
94 asn1_error_code asn1_decode_kerberos_time
95 	(asn1buf *buf, krb5_timestamp *val);
96 asn1_error_code asn1_decode_sam_flags
97 	(asn1buf *buf, krb5_flags *val);
98 
99 /* structures */
100 asn1_error_code asn1_decode_realm
101 	(asn1buf *buf, krb5_principal *val);
102 asn1_error_code asn1_decode_principal_name
103 	(asn1buf *buf, krb5_principal *val);
104 asn1_error_code asn1_decode_checksum
105 	(asn1buf *buf, krb5_checksum *val);
106 asn1_error_code asn1_decode_encryption_key
107 	(asn1buf *buf, krb5_keyblock *val);
108 asn1_error_code asn1_decode_encrypted_data
109 	(asn1buf *buf, krb5_enc_data *val);
110 asn1_error_code asn1_decode_ticket_flags
111 	(asn1buf *buf, krb5_flags *val);
112 asn1_error_code asn1_decode_transited_encoding
113 	(asn1buf *buf, krb5_transited *val);
114 asn1_error_code asn1_decode_enc_kdc_rep_part
115 	(asn1buf *buf, krb5_enc_kdc_rep_part *val);
116 asn1_error_code asn1_decode_krb5_flags
117 	(asn1buf *buf, krb5_flags *val);
118 asn1_error_code asn1_decode_ap_options
119 	(asn1buf *buf, krb5_flags *val);
120 asn1_error_code asn1_decode_kdc_options
121 	(asn1buf *buf, krb5_flags *val);
122 asn1_error_code asn1_decode_ticket
123 	(asn1buf *buf, krb5_ticket *val);
124 asn1_error_code asn1_decode_kdc_req
125 	(asn1buf *buf, krb5_kdc_req *val);
126 asn1_error_code asn1_decode_kdc_req_body
127 	(asn1buf *buf, krb5_kdc_req *val);
128 asn1_error_code asn1_decode_krb_safe_body
129 	(asn1buf *buf, krb5_safe *val);
130 asn1_error_code asn1_decode_host_address
131 	(asn1buf *buf, krb5_address *val);
132 asn1_error_code asn1_decode_kdc_rep
133 	(asn1buf *buf, krb5_kdc_rep *val);
134 asn1_error_code asn1_decode_last_req_entry
135 	(asn1buf *buf, krb5_last_req_entry *val);
136 asn1_error_code asn1_decode_authdata_elt
137 	(asn1buf *buf, krb5_authdata *val);
138 asn1_error_code asn1_decode_krb_cred_info
139 	(asn1buf *buf, krb5_cred_info *val);
140 asn1_error_code asn1_decode_pa_data
141 	(asn1buf *buf, krb5_pa_data *val);
142 asn1_error_code asn1_decode_passwdsequence
143 	(asn1buf *buf, passwd_phrase_element *val);
144 asn1_error_code asn1_decode_sam_challenge
145 	(asn1buf *buf, krb5_sam_challenge *val);
146 asn1_error_code asn1_decode_sam_challenge_2
147 	(asn1buf *buf, krb5_sam_challenge_2 *val);
148 asn1_error_code asn1_decode_sam_challenge_2_body
149 	(asn1buf *buf, krb5_sam_challenge_2_body *val);
150 asn1_error_code asn1_decode_enc_sam_key
151 	(asn1buf *buf, krb5_sam_key *val);
152 asn1_error_code asn1_decode_enc_sam_response_enc
153 	(asn1buf *buf, krb5_enc_sam_response_enc *val);
154 asn1_error_code asn1_decode_enc_sam_response_enc_2
155 	(asn1buf *buf, krb5_enc_sam_response_enc_2 *val);
156 asn1_error_code asn1_decode_sam_response
157 	(asn1buf *buf, krb5_sam_response *val);
158 asn1_error_code asn1_decode_sam_response_2
159 	(asn1buf *buf, krb5_sam_response_2 *val);
160 asn1_error_code asn1_decode_predicted_sam_response
161 	(asn1buf *buf, krb5_predicted_sam_response *val);
162 asn1_error_code asn1_decode_external_principal_identifier
163 	(asn1buf *buf, krb5_external_principal_identifier *val);
164 asn1_error_code asn1_decode_pa_pk_as_req
165 	(asn1buf *buf, krb5_pa_pk_as_req *val);
166 asn1_error_code asn1_decode_trusted_ca
167 	(asn1buf *buf, krb5_trusted_ca *val);
168 asn1_error_code asn1_decode_pa_pk_as_req_draft9
169 	(asn1buf *buf, krb5_pa_pk_as_req_draft9 *val);
170 asn1_error_code asn1_decode_dh_rep_info
171 	(asn1buf *buf, krb5_dh_rep_info *val);
172 asn1_error_code asn1_decode_pk_authenticator
173 	(asn1buf *buf, krb5_pk_authenticator *val);
174 asn1_error_code asn1_decode_pk_authenticator_draft9
175 	(asn1buf *buf, krb5_pk_authenticator_draft9 *val);
176 asn1_error_code asn1_decode_subject_pk_info
177 	(asn1buf *buf, krb5_subject_pk_info *val);
178 asn1_error_code asn1_decode_algorithm_identifier
179 	(asn1buf *buf, krb5_algorithm_identifier *val);
180 asn1_error_code asn1_decode_auth_pack
181 	(asn1buf *buf, krb5_auth_pack *val);
182 asn1_error_code asn1_decode_auth_pack_draft9
183 	(asn1buf *buf, krb5_auth_pack_draft9 *val);
184 asn1_error_code asn1_decode_pa_pk_as_rep
185 	(asn1buf *buf, krb5_pa_pk_as_rep *val);
186 asn1_error_code asn1_decode_pa_pk_as_rep_draft9
187 	(asn1buf *buf, krb5_pa_pk_as_rep_draft9 *val);
188 asn1_error_code asn1_decode_kdc_dh_key_info
189         (asn1buf *buf, krb5_kdc_dh_key_info *val);
190 asn1_error_code asn1_decode_krb5_principal_name
191 	(asn1buf *buf, krb5_principal *val);
192 asn1_error_code asn1_decode_reply_key_pack
193         (asn1buf *buf, krb5_reply_key_pack *val);
194 asn1_error_code asn1_decode_reply_key_pack_draft9
195         (asn1buf *buf, krb5_reply_key_pack_draft9 *val);
196 asn1_error_code asn1_decode_sequence_of_typed_data
197         (asn1buf *buf, krb5_typed_data ***val);
198 asn1_error_code asn1_decode_typed_data
199         (asn1buf *buf, krb5_typed_data *val);
200 
201 /* arrays */
202 asn1_error_code asn1_decode_authorization_data
203 	(asn1buf *buf, krb5_authdata ***val);
204 asn1_error_code asn1_decode_host_addresses
205 	(asn1buf *buf, krb5_address ***val);
206 asn1_error_code asn1_decode_sequence_of_ticket
207 	(asn1buf *buf, krb5_ticket ***val);
208 asn1_error_code asn1_decode_sequence_of_krb_cred_info
209 	(asn1buf *buf, krb5_cred_info ***val);
210 asn1_error_code asn1_decode_sequence_of_pa_data
211 	(asn1buf *buf, krb5_pa_data ***val);
212 asn1_error_code asn1_decode_last_req
213 	(asn1buf *buf, krb5_last_req_entry ***val);
214 
215 asn1_error_code asn1_decode_sequence_of_enctype
216 	(asn1buf *buf, int *num, krb5_enctype **val);
217 
218 asn1_error_code asn1_decode_sequence_of_checksum
219 	(asn1buf *buf, krb5_checksum ***val);
220 
221 asn1_error_code asn1_decode_sequence_of_passwdsequence
222 	(asn1buf *buf, passwd_phrase_element ***val);
223 
224 asn1_error_code asn1_decode_etype_info
225 	(asn1buf *buf, krb5_etype_info_entry ***val);
226 asn1_error_code asn1_decode_etype_info2
227 	(asn1buf *buf, krb5_etype_info_entry ***val, krb5_boolean v1_3_behavior);
228 asn1_error_code asn1_decode_sequence_of_external_principal_identifier
229 	(asn1buf *buf, krb5_external_principal_identifier ***val);
230 asn1_error_code asn1_decode_sequence_of_trusted_ca
231 	(asn1buf *buf, krb5_trusted_ca ***val);
232 asn1_error_code asn1_decode_sequence_of_algorithm_identifier
233 	(asn1buf *buf, krb5_algorithm_identifier ***val);
234 
235 #endif
236