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. 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_ENCODE_KRB5_H__ 28 #define __ASN1_ENCODE_KRB5_H__ 29 30 #include "k5-int.h" 31 #include <stdio.h> 32 #include "asn1buf.h" 33 34 /* 35 Overview 36 37 Encoding routines for various ASN.1 "substructures" as defined in 38 the krb5 protocol. 39 40 Operations 41 42 asn1_encode_krb5_flags 43 asn1_encode_ap_options 44 asn1_encode_ticket_flags 45 asn1_encode_kdc_options 46 asn1_encode_kerberos_time 47 48 asn1_encode_realm 49 asn1_encode_principal_name 50 asn1_encode_encrypted_data 51 asn1_encode_authorization_data 52 asn1_encode_krb5_authdata_elt 53 asn1_encode_kdc_rep 54 asn1_encode_ticket 55 asn1_encode_encryption_key 56 asn1_encode_checksum 57 asn1_encode_host_address 58 asn1_encode_transited_encoding 59 asn1_encode_enc_kdc_rep_part 60 asn1_encode_kdc_req 61 asn1_encode_kdc_req_body 62 asn1_encode_krb_safe_body 63 asn1_encode_krb_cred_info 64 asn1_encode_last_req_entry 65 asn1_encode_pa_data 66 67 asn1_encode_host_addresses 68 asn1_encode_last_req 69 asn1_encode_sequence_of_pa_data 70 asn1_encode_sequence_of_ticket 71 asn1_encode_sequence_of_enctype 72 asn1_encode_sequence_of_checksum 73 asn1_encode_sequence_of_krb_cred_info 74 */ 75 76 /* 77 **** for simple val's **** 78 asn1_error_code asn1_encode_asn1_type(asn1buf *buf, 79 const krb5_type val, 80 int *retlen); 81 requires *buf is allocated 82 effects Inserts the encoding of val into *buf and 83 returns the length of this encoding in *retlen. 84 Returns ASN1_MISSING_FIELD if a required field is empty in val. 85 Returns ENOMEM if memory runs out. 86 87 **** for struct val's **** 88 asn1_error_code asn1_encode_asn1_type(asn1buf *buf, 89 const krb5_type *val, 90 int *retlen); 91 requires *buf is allocated 92 effects Inserts the encoding of *val into *buf and 93 returns the length of this encoding in *retlen. 94 Returns ASN1_MISSING_FIELD if a required field is empty in val. 95 Returns ENOMEM if memory runs out. 96 97 **** for array val's **** 98 asn1_error_code asn1_encode_asn1_type(asn1buf *buf, 99 const krb5_type **val, 100 int *retlen); 101 requires *buf is allocated, **val != NULL, *val[0] != NULL, 102 **val is a NULL-terminated array of pointers to krb5_type 103 effects Inserts the encoding of **val into *buf and 104 returns the length of this encoding in *retlen. 105 Returns ASN1_MISSING_FIELD if a required field is empty in val. 106 Returns ENOMEM if memory runs out. 107 */ 108 109 asn1_error_code asn1_encode_ui_4 (asn1buf *buf, 110 const krb5_ui_4 val, 111 unsigned int *retlen); 112 113 asn1_error_code asn1_encode_msgtype (asn1buf *buf, 114 const /*krb5_msgtype*/int val, 115 unsigned int *retlen); 116 117 asn1_error_code asn1_encode_realm 118 (asn1buf *buf, const krb5_principal val, unsigned int *retlen); 119 120 asn1_error_code asn1_encode_principal_name 121 (asn1buf *buf, const krb5_principal val, unsigned int *retlen); 122 123 asn1_error_code asn1_encode_encrypted_data 124 (asn1buf *buf, const krb5_enc_data *val, unsigned int *retlen); 125 126 asn1_error_code asn1_encode_krb5_flags 127 (asn1buf *buf, const krb5_flags val, unsigned int *retlen); 128 129 asn1_error_code asn1_encode_ap_options 130 (asn1buf *buf, const krb5_flags val, unsigned int *retlen); 131 132 asn1_error_code asn1_encode_ticket_flags 133 (asn1buf *buf, const krb5_flags val, unsigned int *retlen); 134 135 asn1_error_code asn1_encode_kdc_options 136 (asn1buf *buf, const krb5_flags val, unsigned int *retlen); 137 138 asn1_error_code asn1_encode_authorization_data 139 (asn1buf *buf, const krb5_authdata **val, unsigned int *retlen); 140 141 asn1_error_code asn1_encode_krb5_authdata_elt 142 (asn1buf *buf, const krb5_authdata *val, unsigned int *retlen); 143 144 asn1_error_code asn1_encode_kdc_rep 145 (int msg_type, asn1buf *buf, const krb5_kdc_rep *val, 146 unsigned int *retlen); 147 148 asn1_error_code asn1_encode_enc_kdc_rep_part 149 (asn1buf *buf, const krb5_enc_kdc_rep_part *val, 150 unsigned int *retlen); 151 152 asn1_error_code asn1_encode_ticket 153 (asn1buf *buf, const krb5_ticket *val, unsigned int *retlen); 154 155 asn1_error_code asn1_encode_encryption_key 156 (asn1buf *buf, const krb5_keyblock *val, unsigned int *retlen); 157 158 asn1_error_code asn1_encode_kerberos_time 159 (asn1buf *buf, const krb5_timestamp val, unsigned int *retlen); 160 161 asn1_error_code asn1_encode_checksum 162 (asn1buf *buf, const krb5_checksum *val, unsigned int *retlen); 163 164 asn1_error_code asn1_encode_host_address 165 (asn1buf *buf, const krb5_address *val, unsigned int *retlen); 166 167 asn1_error_code asn1_encode_host_addresses 168 (asn1buf *buf, const krb5_address **val, unsigned int *retlen); 169 170 asn1_error_code asn1_encode_transited_encoding 171 (asn1buf *buf, const krb5_transited *val, unsigned int *retlen); 172 173 asn1_error_code asn1_encode_last_req 174 (asn1buf *buf, const krb5_last_req_entry **val, 175 unsigned int *retlen); 176 177 asn1_error_code asn1_encode_sequence_of_pa_data 178 (asn1buf *buf, const krb5_pa_data **val, unsigned int *retlen); 179 180 asn1_error_code asn1_encode_sequence_of_ticket 181 (asn1buf *buf, const krb5_ticket **val, unsigned int *retlen); 182 183 asn1_error_code asn1_encode_sequence_of_enctype 184 (asn1buf *buf, 185 const int len, const krb5_enctype *val, 186 unsigned int *retlen); 187 188 asn1_error_code asn1_encode_sequence_of_checksum 189 (asn1buf *buf, const krb5_checksum **val, unsigned int *retlen); 190 191 asn1_error_code asn1_encode_kdc_req 192 (int msg_type, 193 asn1buf *buf, 194 const krb5_kdc_req *val, 195 unsigned int *retlen); 196 197 asn1_error_code asn1_encode_kdc_req_body 198 (asn1buf *buf, const krb5_kdc_req *val, unsigned int *retlen); 199 200 asn1_error_code asn1_encode_krb_safe_body 201 (asn1buf *buf, const krb5_safe *val, unsigned int *retlen); 202 203 asn1_error_code asn1_encode_sequence_of_krb_cred_info 204 (asn1buf *buf, const krb5_cred_info **val, unsigned int *retlen); 205 206 asn1_error_code asn1_encode_krb_cred_info 207 (asn1buf *buf, const krb5_cred_info *val, unsigned int *retlen); 208 209 asn1_error_code asn1_encode_last_req_entry 210 (asn1buf *buf, const krb5_last_req_entry *val, 211 unsigned int *retlen); 212 213 asn1_error_code asn1_encode_pa_data 214 (asn1buf *buf, const krb5_pa_data *val, unsigned int *retlen); 215 216 asn1_error_code asn1_encode_alt_method 217 (asn1buf *buf, const krb5_alt_method *val, 218 unsigned int *retlen); 219 220 asn1_error_code asn1_encode_etype_info_entry 221 (asn1buf *buf, const krb5_etype_info_entry *val, 222 unsigned int *retlen, int etype_info2); 223 224 asn1_error_code asn1_encode_etype_info 225 (asn1buf *buf, const krb5_etype_info_entry **val, 226 unsigned int *retlen, int etype_info2); 227 228 asn1_error_code asn1_encode_passwdsequence 229 (asn1buf *buf, const passwd_phrase_element *val, unsigned int *retlen); 230 231 asn1_error_code asn1_encode_sequence_of_passwdsequence 232 (asn1buf *buf, const passwd_phrase_element **val, 233 unsigned int *retlen); 234 235 asn1_error_code asn1_encode_sam_flags 236 (asn1buf * buf, const krb5_flags val, unsigned int *retlen); 237 238 asn1_error_code asn1_encode_sam_challenge 239 (asn1buf *buf, const krb5_sam_challenge * val, unsigned int *retlen); 240 241 asn1_error_code asn1_encode_sam_challenge_2 242 (asn1buf *buf, const krb5_sam_challenge_2 * val, unsigned int *retlen); 243 244 asn1_error_code asn1_encode_sam_challenge_2_body 245 (asn1buf *buf, const krb5_sam_challenge_2_body * val, 246 unsigned int *retlen); 247 248 asn1_error_code asn1_encode_sam_key 249 (asn1buf *buf, const krb5_sam_key *val, unsigned int *retlen); 250 251 asn1_error_code asn1_encode_enc_sam_response_enc 252 (asn1buf *buf, const krb5_enc_sam_response_enc *val, 253 unsigned int *retlen); 254 255 asn1_error_code asn1_encode_enc_sam_response_enc_2 256 (asn1buf *buf, const krb5_enc_sam_response_enc_2 *val, 257 unsigned int *retlen); 258 259 asn1_error_code asn1_encode_sam_response 260 (asn1buf *buf, const krb5_sam_response *val, unsigned int *retlen); 261 262 asn1_error_code asn1_encode_sam_response_2 263 (asn1buf *buf, const krb5_sam_response_2 *val, unsigned int *retlen); 264 265 asn1_error_code asn1_encode_predicted_sam_response 266 (asn1buf *buf, const krb5_predicted_sam_response *val, 267 unsigned int *retlen); 268 269 asn1_error_code asn1_encode_krb_saved_safe_body 270 (asn1buf *buf, const krb5_data *body, unsigned int *retlen); 271 272 /* PKINIT */ 273 274 asn1_error_code asn1_encode_pk_authenticator 275 (asn1buf *buf, const krb5_pk_authenticator *val, unsigned int *retlen); 276 277 asn1_error_code asn1_encode_pk_authenticator_draft9 278 (asn1buf *buf, const krb5_pk_authenticator_draft9 *val, unsigned int *retlen); 279 280 asn1_error_code asn1_encode_algorithm_identifier 281 (asn1buf *buf, const krb5_algorithm_identifier *val, unsigned int *retlen); 282 283 asn1_error_code asn1_encode_subject_pk_info 284 (asn1buf *buf, const krb5_subject_pk_info *val, unsigned int *retlen); 285 286 asn1_error_code asn1_encode_sequence_of_algorithm_identifier 287 (asn1buf *buf, const krb5_algorithm_identifier **val, unsigned int *retlen); 288 289 asn1_error_code asn1_encode_auth_pack 290 (asn1buf *buf, const krb5_auth_pack *val, unsigned int *retlen); 291 292 asn1_error_code asn1_encode_auth_pack_draft9 293 (asn1buf *buf, const krb5_auth_pack_draft9 *val, unsigned int *retlen); 294 295 asn1_error_code asn1_encode_external_principal_identifier 296 (asn1buf *buf, const krb5_external_principal_identifier *val, unsigned int *retlen); 297 298 asn1_error_code asn1_encode_sequence_of_external_principal_identifier 299 (asn1buf *buf, const krb5_external_principal_identifier **val, unsigned int *retlen); 300 301 asn1_error_code asn1_encode_pa_pk_as_req 302 (asn1buf *buf, const krb5_pa_pk_as_req *val, unsigned int *retlen); 303 304 asn1_error_code asn1_encode_trusted_ca 305 (asn1buf *buf, const krb5_trusted_ca *val, unsigned int *retlen); 306 307 asn1_error_code asn1_encode_sequence_of_trusted_ca 308 (asn1buf *buf, const krb5_trusted_ca **val, unsigned int *retlen); 309 310 asn1_error_code asn1_encode_pa_pk_as_req_draft9 311 (asn1buf *buf, const krb5_pa_pk_as_req_draft9 *val, unsigned int *retlen); 312 313 asn1_error_code asn1_encode_dh_rep_info 314 (asn1buf *buf, const krb5_dh_rep_info *val, unsigned int *retlen); 315 316 asn1_error_code asn1_encode_kdc_dh_key_info 317 (asn1buf *buf, const krb5_kdc_dh_key_info *val, unsigned int *retlen); 318 319 asn1_error_code asn1_encode_reply_key_pack 320 (asn1buf *buf, const krb5_reply_key_pack *val, unsigned int *retlen); 321 322 asn1_error_code asn1_encode_reply_key_pack_draft9 323 (asn1buf *buf, const krb5_reply_key_pack_draft9 *val, unsigned int *retlen); 324 325 asn1_error_code asn1_encode_pa_pk_as_rep 326 (asn1buf *buf, const krb5_pa_pk_as_rep *val, unsigned int *retlen); 327 328 asn1_error_code asn1_encode_pa_pk_as_rep_draft9 329 (asn1buf *buf, const krb5_pa_pk_as_rep_draft9 *val, unsigned int *retlen); 330 331 asn1_error_code asn1_encode_td_trusted_certifiers 332 (asn1buf *buf, const krb5_external_principal_identifier **val, unsigned int *retlen); 333 334 asn1_error_code asn1_encode_typed_data 335 (asn1buf *buf, const krb5_typed_data *val, unsigned int *retlen); 336 337 asn1_error_code asn1_encode_sequence_of_typed_data 338 (asn1buf *buf, const krb5_typed_data **val, unsigned int *retlen); 339 #endif 340