93be05da3dc228b0ae7eb9c1562d2bdc4ad70273
[krb5.git] / src / lib / krb5 / asn.1 / asn1_k_encode.h
1 /*
2  * src/lib/krb5/asn.1/asn1_k_encode.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.  M.I.T. makes no representations about the suitability of
20  * this software for any purpose.  It is provided "as is" without express
21  * or implied warranty.
22  */
23
24 #ifndef __ASN1_ENCODE_KRB5_H__
25 #define __ASN1_ENCODE_KRB5_H__
26
27 #include "k5-int.h"
28 #include <stdio.h>
29 #include "asn1buf.h"
30
31 /*
32    Overview
33
34      Encoding routines for various ASN.1 "substructures" as defined in
35      the krb5 protocol.
36
37    Operations
38
39     asn1_encode_krb5_flags
40     asn1_encode_ap_options
41     asn1_encode_ticket_flags
42     asn1_encode_kdc_options
43     asn1_encode_kerberos_time
44
45     asn1_encode_realm
46     asn1_encode_principal_name
47     asn1_encode_encrypted_data
48     asn1_encode_authorization_data
49     asn1_encode_krb5_authdata_elt
50     asn1_encode_kdc_rep
51     asn1_encode_ticket
52     asn1_encode_encryption_key
53     asn1_encode_checksum
54     asn1_encode_host_address
55     asn1_encode_transited_encoding
56     asn1_encode_enc_kdc_rep_part
57     asn1_encode_kdc_req
58     asn1_encode_kdc_req_body
59     asn1_encode_krb_safe_body
60     asn1_encode_krb_cred_info
61     asn1_encode_last_req_entry
62     asn1_encode_pa_data
63
64     asn1_encode_host_addresses
65     asn1_encode_last_req
66     asn1_encode_sequence_of_pa_data
67     asn1_encode_sequence_of_ticket
68     asn1_encode_sequence_of_enctype
69     asn1_encode_sequence_of_krb_cred_info
70 */
71
72 /*
73 **** for simple val's ****
74 asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
75                                       const krb5_type val,
76                                       int *retlen);
77    requires  *buf is allocated
78    effects   Inserts the encoding of val into *buf and
79               returns the length of this encoding in *retlen.
80              Returns ASN1_MISSING_FIELD if a required field is empty in val.
81              Returns ENOMEM if memory runs out.
82
83 **** for struct val's ****
84 asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
85                                       const krb5_type *val,
86                                       int *retlen);
87    requires  *buf is allocated
88    effects   Inserts the encoding of *val into *buf and
89               returns the length of this encoding in *retlen.
90              Returns ASN1_MISSING_FIELD if a required field is empty in val.
91              Returns ENOMEM if memory runs out.
92
93 **** for array val's ****
94 asn1_error_code asn1_encode_asn1_type(asn1buf *buf,
95                                       const krb5_type **val,
96                                       int *retlen);
97    requires  *buf is allocated, **val != NULL, *val[0] != NULL,
98               **val is a NULL-terminated array of pointers to krb5_type
99    effects   Inserts the encoding of **val into *buf and
100               returns the length of this encoding in *retlen.
101              Returns ASN1_MISSING_FIELD if a required field is empty in val.
102              Returns ENOMEM if memory runs out.
103 */
104
105 asn1_error_code INTERFACE asn1_encode_ui_4 PROTOTYPE((asn1buf *buf,
106                                             const krb5_ui_4 val,
107                                             int *retlen));
108
109 asn1_error_code INTERFACE asn1_encode_msgtype PROTOTYPE((asn1buf *buf,
110                                                const /*krb5_msgtype*/int val,
111                                                int *retlen));
112
113 asn1_error_code INTERFACE asn1_encode_realm
114         PROTOTYPE((asn1buf *buf, const krb5_principal val, int *retlen));
115
116 asn1_error_code INTERFACE asn1_encode_principal_name
117         PROTOTYPE((asn1buf *buf, const krb5_principal val, int *retlen));
118
119 asn1_error_code INTERFACE asn1_encode_encrypted_data
120         PROTOTYPE((asn1buf *buf, const krb5_enc_data *val, int *retlen));
121
122 asn1_error_code INTERFACE asn1_encode_krb5_flags
123         PROTOTYPE((asn1buf *buf, const krb5_flags val, int *retlen));
124
125 asn1_error_code INTERFACE asn1_encode_ap_options
126         PROTOTYPE((asn1buf *buf, const krb5_flags val, int *retlen));
127
128 asn1_error_code INTERFACE asn1_encode_ticket_flags
129         PROTOTYPE((asn1buf *buf, const krb5_flags val, int *retlen));
130
131 asn1_error_code INTERFACE asn1_encode_kdc_options
132         PROTOTYPE((asn1buf *buf, const krb5_flags val, int *retlen));
133
134 asn1_error_code INTERFACE asn1_encode_authorization_data
135         PROTOTYPE((asn1buf *buf, const krb5_authdata **val, int *retlen));
136
137 asn1_error_code INTERFACE asn1_encode_krb5_authdata_elt
138         PROTOTYPE((asn1buf *buf, const krb5_authdata *val, int *retlen));
139
140 asn1_error_code INTERFACE asn1_encode_kdc_rep
141         PROTOTYPE((int msg_type, asn1buf *buf, const krb5_kdc_rep *val,
142                    int *retlen));
143
144 asn1_error_code INTERFACE asn1_encode_enc_kdc_rep_part
145         PROTOTYPE((asn1buf *buf, const krb5_enc_kdc_rep_part *val,
146                    int *retlen));
147
148 asn1_error_code INTERFACE asn1_encode_ticket
149         PROTOTYPE((asn1buf *buf, const krb5_ticket *val, int *retlen));
150
151 asn1_error_code INTERFACE asn1_encode_encryption_key
152         PROTOTYPE((asn1buf *buf, const krb5_keyblock *val, int *retlen));
153
154 asn1_error_code INTERFACE asn1_encode_kerberos_time
155         PROTOTYPE((asn1buf *buf, const krb5_timestamp val, int *retlen));
156
157 asn1_error_code INTERFACE asn1_encode_checksum
158         PROTOTYPE((asn1buf *buf, const krb5_checksum *val, int *retlen));
159
160 asn1_error_code INTERFACE asn1_encode_host_address
161         PROTOTYPE((asn1buf *buf, const krb5_address *val, int *retlen));
162
163 asn1_error_code INTERFACE asn1_encode_host_addresses
164         PROTOTYPE((asn1buf *buf, const krb5_address **val, int *retlen));
165
166 asn1_error_code INTERFACE asn1_encode_transited_encoding
167         PROTOTYPE((asn1buf *buf, const krb5_transited *val, int *retlen));
168
169 asn1_error_code INTERFACE asn1_encode_last_req
170         PROTOTYPE((asn1buf *buf, const krb5_last_req_entry **val,
171                    int *retlen));
172
173 asn1_error_code INTERFACE asn1_encode_sequence_of_pa_data
174         PROTOTYPE((asn1buf *buf, const krb5_pa_data **val, int *retlen));
175
176 asn1_error_code INTERFACE asn1_encode_sequence_of_ticket
177         PROTOTYPE((asn1buf *buf, const krb5_ticket **val, int *retlen));
178
179 asn1_error_code INTERFACE asn1_encode_sequence_of_enctype
180         PROTOTYPE((asn1buf *buf,
181                    const int len, const krb5_enctype *val,
182                    int *retlen));
183
184 asn1_error_code INTERFACE asn1_encode_kdc_req
185         PROTOTYPE((int msg_type,
186                    asn1buf *buf,
187                    const krb5_kdc_req *val,
188                    int *retlen));
189
190 asn1_error_code INTERFACE asn1_encode_kdc_req_body
191         PROTOTYPE((asn1buf *buf, const krb5_kdc_req *val, int *retlen));
192
193 asn1_error_code INTERFACE asn1_encode_krb_safe_body
194         PROTOTYPE((asn1buf *buf, const krb5_safe *val, int *retlen));
195
196 asn1_error_code INTERFACE asn1_encode_sequence_of_krb_cred_info
197         PROTOTYPE((asn1buf *buf, const krb5_cred_info **val, int *retlen));
198
199 asn1_error_code INTERFACE asn1_encode_krb_cred_info
200         PROTOTYPE((asn1buf *buf, const krb5_cred_info *val, int *retlen));
201
202 asn1_error_code INTERFACE asn1_encode_last_req_entry
203         PROTOTYPE((asn1buf *buf, const krb5_last_req_entry *val,
204                    int *retlen));
205
206 asn1_error_code INTERFACE asn1_encode_pa_data
207         PROTOTYPE((asn1buf *buf, const krb5_pa_data *val, int *retlen));
208
209 asn1_error_code INTERFACE asn1_encode_passwdsequence
210         PROTOTYPE((asn1buf *buf, const passwd_phrase_element *val, int *retlen));
211
212 asn1_error_code INTERFACE asn1_encode_sequence_of_passwdsequence
213         PROTOTYPE((asn1buf *buf, const passwd_phrase_element **val, int *retlen));
214
215 #endif