1*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
2*7c478bd9Sstevel@tonic-gate 
3*7c478bd9Sstevel@tonic-gate /*
4*7c478bd9Sstevel@tonic-gate  * src/lib/krb5/asn.1/asn1_k_encode.h
5*7c478bd9Sstevel@tonic-gate  *
6*7c478bd9Sstevel@tonic-gate  * Copyright 1994 by the Massachusetts Institute of Technology.
7*7c478bd9Sstevel@tonic-gate  * All Rights Reserved.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * Export of this software from the United States of America may
10*7c478bd9Sstevel@tonic-gate  *   require a specific license from the United States Government.
11*7c478bd9Sstevel@tonic-gate  *   It is the responsibility of any person or organization contemplating
12*7c478bd9Sstevel@tonic-gate  *   export to obtain such a license before exporting.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
15*7c478bd9Sstevel@tonic-gate  * distribute this software and its documentation for any purpose and
16*7c478bd9Sstevel@tonic-gate  * without fee is hereby granted, provided that the above copyright
17*7c478bd9Sstevel@tonic-gate  * notice appear in all copies and that both that copyright notice and
18*7c478bd9Sstevel@tonic-gate  * this permission notice appear in supporting documentation, and that
19*7c478bd9Sstevel@tonic-gate  * the name of M.I.T. not be used in advertising or publicity pertaining
20*7c478bd9Sstevel@tonic-gate  * to distribution of the software without specific, written prior
21*7c478bd9Sstevel@tonic-gate  * permission.  Furthermore if you modify this software you must label
22*7c478bd9Sstevel@tonic-gate  * your software as modified software and not distribute it in such a
23*7c478bd9Sstevel@tonic-gate  * fashion that it might be confused with the original M.I.T. software.
24*7c478bd9Sstevel@tonic-gate  * M.I.T. makes no representations about the suitability of
25*7c478bd9Sstevel@tonic-gate  * this software for any purpose.  It is provided "as is" without express
26*7c478bd9Sstevel@tonic-gate  * or implied warranty.
27*7c478bd9Sstevel@tonic-gate  */
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #ifndef __ASN1_ENCODE_KRB5_H__
30*7c478bd9Sstevel@tonic-gate #define __ASN1_ENCODE_KRB5_H__
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include "k5-int.h"
33*7c478bd9Sstevel@tonic-gate #include <stdio.h>
34*7c478bd9Sstevel@tonic-gate #include "asn1buf.h"
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate    Overview
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate      Encoding routines for various ASN.1 "substructures" as defined in
40*7c478bd9Sstevel@tonic-gate      the krb5 protocol.
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate    Operations
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate     asn1_encode_krb5_flags
45*7c478bd9Sstevel@tonic-gate     asn1_encode_ap_options
46*7c478bd9Sstevel@tonic-gate     asn1_encode_ticket_flags
47*7c478bd9Sstevel@tonic-gate     asn1_encode_kdc_options
48*7c478bd9Sstevel@tonic-gate     asn1_encode_kerberos_time
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate     asn1_encode_realm
51*7c478bd9Sstevel@tonic-gate     asn1_encode_principal_name
52*7c478bd9Sstevel@tonic-gate     asn1_encode_encrypted_data
53*7c478bd9Sstevel@tonic-gate     asn1_encode_authorization_data
54*7c478bd9Sstevel@tonic-gate     asn1_encode_krb5_authdata_elt
55*7c478bd9Sstevel@tonic-gate     asn1_encode_kdc_rep
56*7c478bd9Sstevel@tonic-gate     asn1_encode_ticket
57*7c478bd9Sstevel@tonic-gate     asn1_encode_encryption_key
58*7c478bd9Sstevel@tonic-gate     asn1_encode_checksum
59*7c478bd9Sstevel@tonic-gate     asn1_encode_host_address
60*7c478bd9Sstevel@tonic-gate     asn1_encode_transited_encoding
61*7c478bd9Sstevel@tonic-gate     asn1_encode_enc_kdc_rep_part
62*7c478bd9Sstevel@tonic-gate     asn1_encode_kdc_req
63*7c478bd9Sstevel@tonic-gate     asn1_encode_kdc_req_body
64*7c478bd9Sstevel@tonic-gate     asn1_encode_krb_safe_body
65*7c478bd9Sstevel@tonic-gate     asn1_encode_krb_cred_info
66*7c478bd9Sstevel@tonic-gate     asn1_encode_last_req_entry
67*7c478bd9Sstevel@tonic-gate     asn1_encode_pa_data
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate     asn1_encode_host_addresses
70*7c478bd9Sstevel@tonic-gate     asn1_encode_last_req
71*7c478bd9Sstevel@tonic-gate     asn1_encode_sequence_of_pa_data
72*7c478bd9Sstevel@tonic-gate     asn1_encode_sequence_of_ticket
73*7c478bd9Sstevel@tonic-gate     asn1_encode_sequence_of_enctype
74*7c478bd9Sstevel@tonic-gate     asn1_encode_sequence_of_checksum
75*7c478bd9Sstevel@tonic-gate     asn1_encode_sequence_of_krb_cred_info
76*7c478bd9Sstevel@tonic-gate */
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /*
79*7c478bd9Sstevel@tonic-gate **** for simple val's ****
80*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
81*7c478bd9Sstevel@tonic-gate                                       const krb5_type val,
82*7c478bd9Sstevel@tonic-gate 				      int *retlen);
83*7c478bd9Sstevel@tonic-gate    requires  *buf is allocated
84*7c478bd9Sstevel@tonic-gate    effects   Inserts the encoding of val into *buf and
85*7c478bd9Sstevel@tonic-gate               returns the length of this encoding in *retlen.
86*7c478bd9Sstevel@tonic-gate 	     Returns ASN1_MISSING_FIELD if a required field is empty in val.
87*7c478bd9Sstevel@tonic-gate 	     Returns ENOMEM if memory runs out.
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate **** for struct val's ****
90*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
91*7c478bd9Sstevel@tonic-gate                                       const krb5_type *val,
92*7c478bd9Sstevel@tonic-gate 				      int *retlen);
93*7c478bd9Sstevel@tonic-gate    requires  *buf is allocated
94*7c478bd9Sstevel@tonic-gate    effects   Inserts the encoding of *val into *buf and
95*7c478bd9Sstevel@tonic-gate               returns the length of this encoding in *retlen.
96*7c478bd9Sstevel@tonic-gate 	     Returns ASN1_MISSING_FIELD if a required field is empty in val.
97*7c478bd9Sstevel@tonic-gate 	     Returns ENOMEM if memory runs out.
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate **** for array val's ****
100*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
101*7c478bd9Sstevel@tonic-gate                                       const krb5_type **val,
102*7c478bd9Sstevel@tonic-gate 				      int *retlen);
103*7c478bd9Sstevel@tonic-gate    requires  *buf is allocated, **val != NULL, *val[0] != NULL,
104*7c478bd9Sstevel@tonic-gate               **val is a NULL-terminated array of pointers to krb5_type
105*7c478bd9Sstevel@tonic-gate    effects   Inserts the encoding of **val into *buf and
106*7c478bd9Sstevel@tonic-gate               returns the length of this encoding in *retlen.
107*7c478bd9Sstevel@tonic-gate 	     Returns ASN1_MISSING_FIELD if a required field is empty in val.
108*7c478bd9Sstevel@tonic-gate 	     Returns ENOMEM if memory runs out.
109*7c478bd9Sstevel@tonic-gate */
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_ui_4 (asn1buf *buf,
112*7c478bd9Sstevel@tonic-gate 					    const krb5_ui_4 val,
113*7c478bd9Sstevel@tonic-gate 					    unsigned int *retlen);
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_msgtype (asn1buf *buf,
116*7c478bd9Sstevel@tonic-gate 					       const /*krb5_msgtype*/int val,
117*7c478bd9Sstevel@tonic-gate 					       unsigned int *retlen);
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_realm
120*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_principal val, unsigned int *retlen);
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_principal_name
123*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_principal val, unsigned int *retlen);
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_encrypted_data
126*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_enc_data *val, unsigned int *retlen);
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_krb5_flags
129*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_flags val, unsigned int *retlen);
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_ap_options
132*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_flags val, unsigned int *retlen);
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_ticket_flags
135*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_flags val, unsigned int *retlen);
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_kdc_options
138*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_flags val, unsigned int *retlen);
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_authorization_data
141*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_authdata **val, unsigned int *retlen);
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_krb5_authdata_elt
144*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_authdata *val, unsigned int *retlen);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_kdc_rep
147*7c478bd9Sstevel@tonic-gate 	(int msg_type, asn1buf *buf, const krb5_kdc_rep *val,
148*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_enc_kdc_rep_part
151*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_enc_kdc_rep_part *val,
152*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_ticket
155*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_ticket *val, unsigned int *retlen);
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_encryption_key
158*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_keyblock *val, unsigned int *retlen);
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_kerberos_time
161*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_timestamp val, unsigned int *retlen);
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_checksum
164*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_checksum *val, unsigned int *retlen);
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_host_address
167*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_address *val, unsigned int *retlen);
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_host_addresses
170*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_address **val, unsigned int *retlen);
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_transited_encoding
173*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_transited *val, unsigned int *retlen);
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_last_req
176*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_last_req_entry **val,
177*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sequence_of_pa_data
180*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_pa_data **val, unsigned int *retlen);
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sequence_of_ticket
183*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_ticket **val, unsigned int *retlen);
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sequence_of_enctype
186*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf,
187*7c478bd9Sstevel@tonic-gate 		   const int len, const krb5_enctype *val,
188*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sequence_of_checksum
191*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_checksum **val, unsigned int *retlen);
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_kdc_req
194*7c478bd9Sstevel@tonic-gate 	(int msg_type,
195*7c478bd9Sstevel@tonic-gate 		   asn1buf *buf,
196*7c478bd9Sstevel@tonic-gate 		   const krb5_kdc_req *val,
197*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_kdc_req_body
200*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_kdc_req *val, unsigned int *retlen);
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_krb_safe_body
203*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_safe *val, unsigned int *retlen);
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sequence_of_krb_cred_info
206*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_cred_info **val, unsigned int *retlen);
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_krb_cred_info
209*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_cred_info *val, unsigned int *retlen);
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_last_req_entry
212*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_last_req_entry *val,
213*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_pa_data
216*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_pa_data *val, unsigned int *retlen);
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_alt_method
219*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_alt_method *val,
220*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_etype_info_entry
223*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_etype_info_entry *val,
224*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen, int etype_info2);
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_etype_info
227*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_etype_info_entry **val,
228*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen, int etype_info2);
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_passwdsequence
231*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const passwd_phrase_element *val, unsigned int *retlen);
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sequence_of_passwdsequence
234*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const passwd_phrase_element **val,
235*7c478bd9Sstevel@tonic-gate 	unsigned int *retlen);
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_flags
238*7c478bd9Sstevel@tonic-gate 	(asn1buf * buf, const krb5_flags val, unsigned int *retlen);
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_challenge
241*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_sam_challenge * val, unsigned int *retlen);
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_challenge_2
244*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_sam_challenge_2 * val, unsigned int *retlen);
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_challenge_2_body
247*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_sam_challenge_2_body * val,
248*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_key
251*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_sam_key *val, unsigned int *retlen);
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_enc_sam_response_enc
254*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_enc_sam_response_enc *val,
255*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_enc_sam_response_enc_2
258*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_enc_sam_response_enc_2 *val,
259*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_response
262*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_sam_response *val, unsigned int *retlen);
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_sam_response_2
265*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_sam_response_2 *val, unsigned int *retlen);
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_predicted_sam_response
268*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_predicted_sam_response *val,
269*7c478bd9Sstevel@tonic-gate 		   unsigned int *retlen);
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate asn1_error_code asn1_encode_krb_saved_safe_body
272*7c478bd9Sstevel@tonic-gate 	(asn1buf *buf, const krb5_data *body, unsigned int *retlen);
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate #endif
275