18
18
static void encoder_print_results(code, typestring, description)
23
char *code_string = NULL;
24
krb5_error_code retval;
23
char *code_string = NULL;
24
krb5_error_code retval;
28
printf("encode_krb5_%s%s:\n", typestring, description);
29
r = trval2(stdout, code->data, code->length, 0, &rlen);
31
if (rlen != code->length) {
32
printf("Error: length mismatch: was %d, parsed %d\n",
37
printf("Error: Return from trval2 is %d.\n", r);
40
current_appl_type = -1; /* Reset type */
42
retval = asn1_krb5_data_unparse(code,&(code_string));
44
com_err("krb5_encode_test", retval ,
45
"while unparsing %s", typestring);
48
printf("encode_krb5_%s%s: %s\n", typestring, description,
52
ktest_destroy_data(&code);
28
printf("encode_krb5_%s%s:\n", typestring, description);
29
r = trval2(stdout, code->data, code->length, 0, &rlen);
31
if (rlen < 0 || (unsigned int) rlen != code->length) {
32
printf("Error: length mismatch: was %d, parsed %d\n",
37
printf("Error: Return from trval2 is %d.\n", r);
40
current_appl_type = -1; /* Reset type */
42
retval = asn1_krb5_data_unparse(code,&(code_string));
44
com_err("krb5_encode_test", retval ,
45
"while unparsing %s", typestring);
48
printf("encode_krb5_%s%s: %s\n", typestring, description,
52
ktest_destroy_data(&code);
55
55
static void PRS(argc, argv)
61
extern int print_types, print_krb5_types, print_id_and_len,
62
print_constructed_length, print_skip_context,
63
print_skip_tagnum, print_context_shortcut;
61
extern int print_types, print_krb5_types, print_id_and_len,
62
print_constructed_length, print_skip_context,
63
print_skip_tagnum, print_context_shortcut;
65
while ((optchar = getopt(argc, argv, "tp:")) != -1) {
71
sample_principal_name = optarg;
75
fprintf(stderr, "Usage: %s [-t] [-p principal]\n",
65
while ((optchar = getopt(argc, argv, "tp:")) != -1) {
71
sample_principal_name = optarg;
75
fprintf(stderr, "Usage: %s [-t] [-p principal]\n",
83
print_constructed_length = 0;
84
print_skip_context = 1;
85
print_skip_tagnum = 1;
86
print_context_shortcut = 1;
83
print_constructed_length = 0;
84
print_skip_context = 1;
85
print_skip_tagnum = 1;
86
print_context_shortcut = 1;
95
krb5_error_code retval;
95
krb5_error_code retval;
99
retval = krb5_init_context(&test_context);
101
com_err(argv[0], retval, "while initializing krb5");
105
#define setup(value,type,typestring,constructor)\
106
retval = constructor(&(value));\
108
com_err("krb5_encode_test", retval, "while making sample %s", typestring);\
99
retval = krb5_init_context(&test_context);
101
com_err(argv[0], retval, "while initializing krb5");
104
init_access(argv[0]);
106
#define setup(value,type,typestring,constructor) \
107
retval = constructor(&(value)); \
109
com_err("krb5_encode_test", retval, "while making sample %s", typestring); \
112
#define encode_run(value,type,typestring,description,encoder)\
113
retval = encoder(&(value),&(code));\
115
com_err("krb5_encode_test", retval,"while encoding %s", typestring);\
118
encoder_print_results(code, typestring, description);
113
#define encode_run(value,type,typestring,description,encoder) \
114
retval = encoder(&(value),&(code)); \
116
com_err("krb5_encode_test", retval,"while encoding %s", typestring); \
119
encoder_print_results(code, typestring, description);
120
/****************************************************************/
121
/* encode_krb5_authenticator */
123
krb5_authenticator authent;
124
setup(authent,authenticator,"authenticator",ktest_make_sample_authenticator);
126
encode_run(authent,authenticator,"authenticator","",encode_krb5_authenticator);
128
ktest_destroy_checksum(&(authent.checksum));
129
ktest_destroy_keyblock(&(authent.subkey));
130
authent.seq_number = 0;
131
ktest_empty_authorization_data(authent.authorization_data);
132
encode_run(authent,authenticator,"authenticator","(optionals empty)",encode_krb5_authenticator);
134
ktest_destroy_authorization_data(&(authent.authorization_data));
135
encode_run(authent,authenticator,"authenticator","(optionals NULL)",encode_krb5_authenticator);
136
ktest_empty_authenticator(&authent);
139
/****************************************************************/
140
/* encode_krb5_ticket */
143
setup(tkt,ticket,"ticket",ktest_make_sample_ticket);
144
encode_run(tkt,ticket,"ticket","",encode_krb5_ticket);
145
ktest_empty_ticket(&tkt);
148
/****************************************************************/
149
/* encode_krb5_encryption_key */
151
krb5_keyblock keyblk;
152
setup(keyblk,keyblock,"keyblock",ktest_make_sample_keyblock);
153
current_appl_type = 1005;
154
encode_run(keyblk,keyblock,"keyblock","",encode_krb5_encryption_key);
155
ktest_empty_keyblock(&keyblk);
158
/****************************************************************/
159
/* encode_krb5_enc_tkt_part */
162
memset(&tkt, 0, sizeof(krb5_ticket));
163
tkt.enc_part2 = (krb5_enc_tkt_part*)calloc(1,sizeof(krb5_enc_tkt_part));
164
if(tkt.enc_part2 == NULL) com_err("allocating enc_tkt_part",errno,"");
165
setup(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part",ktest_make_sample_enc_tkt_part);
167
encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","",encode_krb5_enc_tkt_part);
169
tkt.enc_part2->times.starttime = 0;
170
tkt.enc_part2->times.renew_till = 0;
171
ktest_destroy_address(&(tkt.enc_part2->caddrs[1]));
172
ktest_destroy_address(&(tkt.enc_part2->caddrs[0]));
173
ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[1]));
174
ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[0]));
176
/* ISODE version fails on the empty caddrs field */
177
ktest_destroy_addresses(&(tkt.enc_part2->caddrs));
178
ktest_destroy_authorization_data(&(tkt.enc_part2->authorization_data));
180
encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","(optionals NULL)",encode_krb5_enc_tkt_part);
181
ktest_empty_ticket(&tkt);
184
/****************************************************************/
185
/* encode_krb5_enc_kdc_rep_part */
189
memset(&kdcr, 0, sizeof(kdcr));
121
/****************************************************************/
122
/* encode_krb5_authenticator */
124
krb5_authenticator authent;
125
setup(authent,authenticator,"authenticator",ktest_make_sample_authenticator);
127
encode_run(authent,authenticator,"authenticator","",encode_krb5_authenticator);
129
ktest_destroy_checksum(&(authent.checksum));
130
ktest_destroy_keyblock(&(authent.subkey));
131
authent.seq_number = 0;
132
ktest_empty_authorization_data(authent.authorization_data);
133
encode_run(authent,authenticator,"authenticator","(optionals empty)",encode_krb5_authenticator);
135
ktest_destroy_authorization_data(&(authent.authorization_data));
136
encode_run(authent,authenticator,"authenticator","(optionals NULL)",encode_krb5_authenticator);
137
ktest_empty_authenticator(&authent);
140
/****************************************************************/
141
/* encode_krb5_ticket */
144
setup(tkt,ticket,"ticket",ktest_make_sample_ticket);
145
encode_run(tkt,ticket,"ticket","",encode_krb5_ticket);
146
ktest_empty_ticket(&tkt);
149
/****************************************************************/
150
/* encode_krb5_encryption_key */
152
krb5_keyblock keyblk;
153
setup(keyblk,keyblock,"keyblock",ktest_make_sample_keyblock);
154
current_appl_type = 1005;
155
encode_run(keyblk,keyblock,"keyblock","",encode_krb5_encryption_key);
156
ktest_empty_keyblock(&keyblk);
159
/****************************************************************/
160
/* encode_krb5_enc_tkt_part */
163
memset(&tkt, 0, sizeof(krb5_ticket));
164
tkt.enc_part2 = (krb5_enc_tkt_part*)calloc(1,sizeof(krb5_enc_tkt_part));
165
if (tkt.enc_part2 == NULL) com_err("allocating enc_tkt_part",errno,"");
166
setup(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part",ktest_make_sample_enc_tkt_part);
168
encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","",encode_krb5_enc_tkt_part);
170
tkt.enc_part2->times.starttime = 0;
171
tkt.enc_part2->times.renew_till = 0;
172
ktest_destroy_address(&(tkt.enc_part2->caddrs[1]));
173
ktest_destroy_address(&(tkt.enc_part2->caddrs[0]));
174
ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[1]));
175
ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[0]));
177
/* ISODE version fails on the empty caddrs field */
178
ktest_destroy_addresses(&(tkt.enc_part2->caddrs));
179
ktest_destroy_authorization_data(&(tkt.enc_part2->authorization_data));
181
encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","(optionals NULL)",encode_krb5_enc_tkt_part);
182
ktest_empty_ticket(&tkt);
185
/****************************************************************/
186
/* encode_krb5_enc_kdc_rep_part */
190
memset(&kdcr, 0, sizeof(kdcr));
191
kdcr.enc_part2 = (krb5_enc_kdc_rep_part*)
192
calloc(1,sizeof(krb5_enc_kdc_rep_part));
193
if(kdcr.enc_part2 == NULL) com_err("allocating enc_kdc_rep_part",errno,"");
194
setup(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part);
196
encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","",encode_krb5_enc_kdc_rep_part);
198
kdcr.enc_part2->key_exp = 0;
199
kdcr.enc_part2->times.starttime = 0;
200
kdcr.enc_part2->flags &= ~TKT_FLG_RENEWABLE;
201
ktest_destroy_addresses(&(kdcr.enc_part2->caddrs));
203
encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","(optionals NULL)",encode_krb5_enc_kdc_rep_part);
205
ktest_empty_kdc_rep(&kdcr);
208
/****************************************************************/
209
/* encode_krb5_as_rep */
212
setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
192
kdcr.enc_part2 = (krb5_enc_kdc_rep_part*)
193
calloc(1,sizeof(krb5_enc_kdc_rep_part));
194
if (kdcr.enc_part2 == NULL) com_err("allocating enc_kdc_rep_part",errno,"");
195
setup(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part);
197
encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","",encode_krb5_enc_kdc_rep_part);
199
kdcr.enc_part2->key_exp = 0;
200
kdcr.enc_part2->times.starttime = 0;
201
kdcr.enc_part2->flags &= ~TKT_FLG_RENEWABLE;
202
ktest_destroy_addresses(&(kdcr.enc_part2->caddrs));
204
encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","(optionals NULL)",encode_krb5_enc_kdc_rep_part);
206
ktest_empty_kdc_rep(&kdcr);
209
/****************************************************************/
210
/* encode_krb5_as_rep */
213
setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
214
215
/* kdcr.msg_type = KRB5_TGS_REP;
215
test(encode_krb5_as_rep(&kdcr,&code) == KRB5_BADMSGTYPE,
216
"encode_krb5_as_rep type check\n");
217
ktest_destroy_data(&code);*/
219
kdcr.msg_type = KRB5_AS_REP;
220
encode_run(kdcr,as_rep,"as_rep","",encode_krb5_as_rep);
222
ktest_destroy_pa_data_array(&(kdcr.padata));
223
encode_run(kdcr,as_rep,"as_rep","(optionals NULL)",encode_krb5_as_rep);
225
ktest_empty_kdc_rep(&kdcr);
229
/****************************************************************/
230
/* encode_krb5_tgs_rep */
233
setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
216
test(encode_krb5_as_rep(&kdcr,&code) == KRB5_BADMSGTYPE,
217
"encode_krb5_as_rep type check\n");
218
ktest_destroy_data(&code);*/
220
kdcr.msg_type = KRB5_AS_REP;
221
encode_run(kdcr,as_rep,"as_rep","",encode_krb5_as_rep);
223
ktest_destroy_pa_data_array(&(kdcr.padata));
224
encode_run(kdcr,as_rep,"as_rep","(optionals NULL)",encode_krb5_as_rep);
226
ktest_empty_kdc_rep(&kdcr);
230
/****************************************************************/
231
/* encode_krb5_tgs_rep */
234
setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep);
235
236
/* kdcr.msg_type = KRB5_AS_REP;
236
test(encode_krb5_tgs_rep(&kdcr,&code) == KRB5_BADMSGTYPE,
237
"encode_krb5_tgs_rep type check\n");*/
239
kdcr.msg_type = KRB5_TGS_REP;
240
encode_run(kdcr,tgs_rep,"tgs_rep","",encode_krb5_tgs_rep);
242
ktest_destroy_pa_data_array(&(kdcr.padata));
243
encode_run(kdcr,tgs_rep,"tgs_rep","(optionals NULL)",encode_krb5_tgs_rep);
245
ktest_empty_kdc_rep(&kdcr);
249
/****************************************************************/
250
/* encode_krb5_ap_req */
253
setup(apreq,ap_req,"ap_req",ktest_make_sample_ap_req);
254
encode_run(apreq,ap_req,"ap_req","",encode_krb5_ap_req);
255
ktest_empty_ap_req(&apreq);
258
/****************************************************************/
259
/* encode_krb5_ap_rep */
262
setup(aprep,ap_rep,"ap_rep",ktest_make_sample_ap_rep);
263
encode_run(aprep,ap_rep,"ap_rep","",encode_krb5_ap_rep);
264
ktest_empty_ap_rep(&aprep);
267
/****************************************************************/
268
/* encode_krb5_ap_rep_enc_part */
270
krb5_ap_rep_enc_part apenc;
271
setup(apenc,ap_rep_enc_part,"ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part);
272
encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","",encode_krb5_ap_rep_enc_part);
274
ktest_destroy_keyblock(&(apenc.subkey));
275
apenc.seq_number = 0;
276
encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","(optionals NULL)",encode_krb5_ap_rep_enc_part);
277
ktest_empty_ap_rep_enc_part(&apenc);
280
/****************************************************************/
281
/* encode_krb5_as_req */
284
setup(asreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
285
asreq.msg_type = KRB5_AS_REQ;
286
asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
287
encode_run(asreq,as_req,"as_req","",encode_krb5_as_req);
289
ktest_destroy_pa_data_array(&(asreq.padata));
290
ktest_destroy_principal(&(asreq.client));
292
ktest_destroy_principal(&(asreq.server));
294
asreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
297
ktest_destroy_addresses(&(asreq.addresses));
298
ktest_destroy_enc_data(&(asreq.authorization_data));
299
encode_run(asreq,as_req,"as_req","(optionals NULL except second_ticket)",encode_krb5_as_req);
300
ktest_destroy_sequence_of_ticket(&(asreq.second_ticket));
302
ktest_make_sample_principal(&(asreq.server));
304
asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
305
encode_run(asreq,as_req,"as_req","(optionals NULL except server)",encode_krb5_as_req);
306
ktest_empty_kdc_req(&asreq);
309
/****************************************************************/
310
/* encode_krb5_tgs_req */
313
setup(tgsreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
314
tgsreq.msg_type = KRB5_TGS_REQ;
315
tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
316
encode_run(tgsreq,tgs_req,"tgs_req","",encode_krb5_tgs_req);
318
ktest_destroy_pa_data_array(&(tgsreq.padata));
319
ktest_destroy_principal(&(tgsreq.client));
321
ktest_destroy_principal(&(tgsreq.server));
323
tgsreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
326
ktest_destroy_addresses(&(tgsreq.addresses));
327
ktest_destroy_enc_data(&(tgsreq.authorization_data));
328
encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except second_ticket)",encode_krb5_tgs_req);
330
ktest_destroy_sequence_of_ticket(&(tgsreq.second_ticket));
332
ktest_make_sample_principal(&(tgsreq.server));
334
tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
335
encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except server)",encode_krb5_tgs_req);
337
ktest_empty_kdc_req(&tgsreq);
340
/****************************************************************/
341
/* encode_krb5_kdc_req_body */
344
memset(&kdcrb, 0, sizeof(kdcrb));
345
setup(kdcrb,kdc_req_body,"kdc_req_body",ktest_make_sample_kdc_req_body);
346
kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
347
current_appl_type = 1007; /* Force interpretation as kdc-req-body */
348
encode_run(kdcrb,kdc_req_body,"kdc_req_body","",encode_krb5_kdc_req_body);
350
ktest_destroy_principal(&(kdcrb.client));
352
ktest_destroy_principal(&(kdcrb.server));
354
kdcrb.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
357
ktest_destroy_addresses(&(kdcrb.addresses));
358
ktest_destroy_enc_data(&(kdcrb.authorization_data));
359
current_appl_type = 1007; /* Force interpretation as kdc-req-body */
360
encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except second_ticket)",encode_krb5_kdc_req_body);
362
ktest_destroy_sequence_of_ticket(&(kdcrb.second_ticket));
364
ktest_make_sample_principal(&(kdcrb.server));
366
kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
367
current_appl_type = 1007; /* Force interpretation as kdc-req-body */
368
encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except server)",encode_krb5_kdc_req_body);
370
ktest_empty_kdc_req(&kdcrb);
373
/****************************************************************/
374
/* encode_krb5_safe */
377
setup(s,safe,"safe",ktest_make_sample_safe);
378
encode_run(s,safe,"safe","",encode_krb5_safe);
381
/* s.usec should be opted out by the timestamp */
383
ktest_destroy_address(&(s.r_address));
384
encode_run(s,safe,"safe","(optionals NULL)",encode_krb5_safe);
386
ktest_empty_safe(&s);
389
/****************************************************************/
390
/* encode_krb5_priv */
393
setup(p,priv,"priv",ktest_make_sample_priv);
394
encode_run(p,priv,"priv","",encode_krb5_priv);
395
ktest_empty_priv(&p);
398
/****************************************************************/
399
/* encode_krb5_enc_priv_part */
401
krb5_priv_enc_part ep;
402
setup(ep,priv_enc_part,"priv_enc_part",ktest_make_sample_priv_enc_part);
403
encode_run(ep,enc_priv_part,"enc_priv_part","",encode_krb5_enc_priv_part);
406
/* ep.usec should be opted out along with timestamp */
408
ktest_destroy_address(&(ep.r_address));
409
encode_run(ep,enc_priv_part,"enc_priv_part","(optionals NULL)",encode_krb5_enc_priv_part);
411
ktest_empty_priv_enc_part(&ep);
414
/****************************************************************/
415
/* encode_krb5_cred */
418
setup(c,cred,"cred",ktest_make_sample_cred);
419
encode_run(c,cred,"cred","",encode_krb5_cred);
420
ktest_empty_cred(&c);
423
/****************************************************************/
424
/* encode_krb5_enc_cred_part */
426
krb5_cred_enc_part cep;
427
setup(cep,cred_enc_part,"cred_enc_part",ktest_make_sample_cred_enc_part);
428
encode_run(cep,enc_cred_part,"enc_cred_part","",encode_krb5_enc_cred_part);
430
ktest_destroy_principal(&(cep.ticket_info[0]->client));
431
ktest_destroy_principal(&(cep.ticket_info[0]->server));
432
cep.ticket_info[0]->flags = 0;
433
cep.ticket_info[0]->times.authtime = 0;
434
cep.ticket_info[0]->times.starttime = 0;
435
cep.ticket_info[0]->times.endtime = 0;
436
cep.ticket_info[0]->times.renew_till = 0;
437
ktest_destroy_addresses(&(cep.ticket_info[0]->caddrs));
440
ktest_destroy_address(&(cep.s_address));
441
ktest_destroy_address(&(cep.r_address));
442
encode_run(cep,enc_cred_part,"enc_cred_part","(optionals NULL)",encode_krb5_enc_cred_part);
444
ktest_empty_cred_enc_part(&cep);
447
/****************************************************************/
448
/* encode_krb5_error */
451
setup(kerr,error,"error",ktest_make_sample_error);
452
encode_run(kerr,error,"error","",encode_krb5_error);
455
ktest_destroy_principal(&(kerr.client));
456
ktest_empty_data(&(kerr.text));
457
ktest_empty_data(&(kerr.e_data));
458
encode_run(kerr,error,"error","(optionals NULL)",encode_krb5_error);
460
ktest_empty_error(&kerr);
463
/****************************************************************/
464
/* encode_krb5_authdata */
467
setup(ad,authorization_data,"authorization_data",ktest_make_sample_authorization_data);
469
retval = encode_krb5_authdata((const krb5_authdata**)ad,&(code));
471
com_err("encoding authorization_data",retval,"");
474
current_appl_type = 1004; /* Force type to be authdata */
475
encoder_print_results(code, "authorization_data", "");
477
ktest_destroy_authorization_data(&ad);
480
/****************************************************************/
481
/* encode_pwd_sequence */
483
passwd_phrase_element ppe;
484
setup(ppe,passwd_phrase_element,"PasswdSequence",ktest_make_sample_passwd_phrase_element);
485
encode_run(ppe,passwd_phrase_element,"pwd_sequence","",encode_krb5_pwd_sequence);
486
ktest_empty_passwd_phrase_element(&ppe);
489
/****************************************************************/
490
/* encode_passwd_data */
493
setup(pd,krb5_pwd_data,"PasswdData",ktest_make_sample_krb5_pwd_data);
494
encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data);
495
ktest_empty_pwd_data(&pd);
498
/****************************************************************/
499
/* encode_padata_sequence */
503
setup(pa,krb5_pa_data,"PreauthData",ktest_make_sample_pa_data_array);
504
retval = encode_krb5_padata_sequence((const krb5_pa_data**)pa,&(code));
506
com_err("encoding padata_sequence",retval,"");
509
encoder_print_results(code, "padata_sequence", "");
511
ktest_destroy_pa_data_array(&pa);
514
/****************************************************************/
515
/* encode_padata_sequence (empty) */
519
setup(pa,krb5_pa_data,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array);
520
retval = encode_krb5_padata_sequence((const krb5_pa_data**)pa,&(code));
522
com_err("encoding padata_sequence(empty)",retval,"");
525
encoder_print_results(code, "padata_sequence(empty)", "");
527
ktest_destroy_pa_data_array(&pa);
530
/****************************************************************/
531
/* encode_alt_method */
534
setup(am,krb5_alt_method,"AltMethod",ktest_make_sample_alt_method);
535
encode_run(am,krb5_alt_method,"alt_method","",encode_krb5_alt_method);
540
encode_run(am,krb5_alt_method,"alt_method (no data)","",
541
encode_krb5_alt_method);
542
ktest_empty_alt_method(&am);
545
/****************************************************************/
546
/* encode_etype_info */
548
krb5_etype_info_entry **info;
550
setup(info,krb5_etype_info_entry **,"etype_info",
551
ktest_make_sample_etype_info);
552
retval = encode_krb5_etype_info((const krb5_etype_info_entry **)info,&(code));
554
com_err("encoding etype_info",retval,"");
557
encoder_print_results(code, "etype_info", "");
558
ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
559
ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
561
retval = encode_krb5_etype_info((const krb5_etype_info_entry **)info,&(code));
563
com_err("encoding etype_info (only 1)",retval,"");
566
encoder_print_results(code, "etype_info (only 1)", "");
568
ktest_destroy_etype_info_entry(info[0]); info[0] = 0;
570
retval = encode_krb5_etype_info((const krb5_etype_info_entry **)info,&(code));
572
com_err("encoding etype_info (no info)",retval,"");
575
encoder_print_results(code, "etype_info (no info)", "");
577
ktest_destroy_etype_info(info);
580
/* encode_etype_info 2*/
582
krb5_etype_info_entry **info;
584
setup(info,krb5_etype_info_entry **,"etype_info2",
585
ktest_make_sample_etype_info2);
586
retval = encode_krb5_etype_info2((const krb5_etype_info_entry **)info,&(code));
588
com_err("encoding etype_info",retval,"");
591
encoder_print_results(code, "etype_info2", "");
592
ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
593
ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
595
retval = encode_krb5_etype_info2((const krb5_etype_info_entry **)info,&(code));
597
com_err("encoding etype_info (only 1)",retval,"");
600
encoder_print_results(code, "etype_info2 (only 1)", "");
602
ktest_destroy_etype_info(info);
237
test(encode_krb5_tgs_rep(&kdcr,&code) == KRB5_BADMSGTYPE,
238
"encode_krb5_tgs_rep type check\n");*/
240
kdcr.msg_type = KRB5_TGS_REP;
241
encode_run(kdcr,tgs_rep,"tgs_rep","",encode_krb5_tgs_rep);
243
ktest_destroy_pa_data_array(&(kdcr.padata));
244
encode_run(kdcr,tgs_rep,"tgs_rep","(optionals NULL)",encode_krb5_tgs_rep);
246
ktest_empty_kdc_rep(&kdcr);
250
/****************************************************************/
251
/* encode_krb5_ap_req */
254
setup(apreq,ap_req,"ap_req",ktest_make_sample_ap_req);
255
encode_run(apreq,ap_req,"ap_req","",encode_krb5_ap_req);
256
ktest_empty_ap_req(&apreq);
259
/****************************************************************/
260
/* encode_krb5_ap_rep */
263
setup(aprep,ap_rep,"ap_rep",ktest_make_sample_ap_rep);
264
encode_run(aprep,ap_rep,"ap_rep","",encode_krb5_ap_rep);
265
ktest_empty_ap_rep(&aprep);
268
/****************************************************************/
269
/* encode_krb5_ap_rep_enc_part */
271
krb5_ap_rep_enc_part apenc;
272
setup(apenc,ap_rep_enc_part,"ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part);
273
encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","",encode_krb5_ap_rep_enc_part);
275
ktest_destroy_keyblock(&(apenc.subkey));
276
apenc.seq_number = 0;
277
encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","(optionals NULL)",encode_krb5_ap_rep_enc_part);
278
ktest_empty_ap_rep_enc_part(&apenc);
281
/****************************************************************/
282
/* encode_krb5_as_req */
285
setup(asreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
286
asreq.msg_type = KRB5_AS_REQ;
287
asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
288
encode_run(asreq,as_req,"as_req","",encode_krb5_as_req);
290
ktest_destroy_pa_data_array(&(asreq.padata));
291
ktest_destroy_principal(&(asreq.client));
293
ktest_destroy_principal(&(asreq.server));
295
asreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
298
ktest_destroy_addresses(&(asreq.addresses));
299
ktest_destroy_enc_data(&(asreq.authorization_data));
300
encode_run(asreq,as_req,"as_req","(optionals NULL except second_ticket)",encode_krb5_as_req);
301
ktest_destroy_sequence_of_ticket(&(asreq.second_ticket));
303
ktest_make_sample_principal(&(asreq.server));
305
asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
306
encode_run(asreq,as_req,"as_req","(optionals NULL except server)",encode_krb5_as_req);
307
ktest_empty_kdc_req(&asreq);
310
/****************************************************************/
311
/* encode_krb5_tgs_req */
314
setup(tgsreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req);
315
tgsreq.msg_type = KRB5_TGS_REQ;
316
tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
317
encode_run(tgsreq,tgs_req,"tgs_req","",encode_krb5_tgs_req);
319
ktest_destroy_pa_data_array(&(tgsreq.padata));
320
ktest_destroy_principal(&(tgsreq.client));
322
ktest_destroy_principal(&(tgsreq.server));
324
tgsreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
327
ktest_destroy_addresses(&(tgsreq.addresses));
328
ktest_destroy_enc_data(&(tgsreq.authorization_data));
329
encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except second_ticket)",encode_krb5_tgs_req);
331
ktest_destroy_sequence_of_ticket(&(tgsreq.second_ticket));
333
ktest_make_sample_principal(&(tgsreq.server));
335
tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
336
encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except server)",encode_krb5_tgs_req);
338
ktest_empty_kdc_req(&tgsreq);
341
/****************************************************************/
342
/* encode_krb5_kdc_req_body */
345
memset(&kdcrb, 0, sizeof(kdcrb));
346
setup(kdcrb,kdc_req_body,"kdc_req_body",ktest_make_sample_kdc_req_body);
347
kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
348
current_appl_type = 1007; /* Force interpretation as kdc-req-body */
349
encode_run(kdcrb,kdc_req_body,"kdc_req_body","",encode_krb5_kdc_req_body);
351
ktest_destroy_principal(&(kdcrb.client));
353
ktest_destroy_principal(&(kdcrb.server));
355
kdcrb.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY;
358
ktest_destroy_addresses(&(kdcrb.addresses));
359
ktest_destroy_enc_data(&(kdcrb.authorization_data));
360
current_appl_type = 1007; /* Force interpretation as kdc-req-body */
361
encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except second_ticket)",encode_krb5_kdc_req_body);
363
ktest_destroy_sequence_of_ticket(&(kdcrb.second_ticket));
365
ktest_make_sample_principal(&(kdcrb.server));
367
kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY;
368
current_appl_type = 1007; /* Force interpretation as kdc-req-body */
369
encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except server)",encode_krb5_kdc_req_body);
371
ktest_empty_kdc_req(&kdcrb);
374
/****************************************************************/
375
/* encode_krb5_safe */
378
setup(s,safe,"safe",ktest_make_sample_safe);
379
encode_run(s,safe,"safe","",encode_krb5_safe);
382
/* s.usec should be opted out by the timestamp */
384
ktest_destroy_address(&(s.r_address));
385
encode_run(s,safe,"safe","(optionals NULL)",encode_krb5_safe);
387
ktest_empty_safe(&s);
390
/****************************************************************/
391
/* encode_krb5_priv */
394
setup(p,priv,"priv",ktest_make_sample_priv);
395
encode_run(p,priv,"priv","",encode_krb5_priv);
396
ktest_empty_priv(&p);
399
/****************************************************************/
400
/* encode_krb5_enc_priv_part */
402
krb5_priv_enc_part ep;
403
setup(ep,priv_enc_part,"priv_enc_part",ktest_make_sample_priv_enc_part);
404
encode_run(ep,enc_priv_part,"enc_priv_part","",encode_krb5_enc_priv_part);
407
/* ep.usec should be opted out along with timestamp */
409
ktest_destroy_address(&(ep.r_address));
410
encode_run(ep,enc_priv_part,"enc_priv_part","(optionals NULL)",encode_krb5_enc_priv_part);
412
ktest_empty_priv_enc_part(&ep);
415
/****************************************************************/
416
/* encode_krb5_cred */
419
setup(c,cred,"cred",ktest_make_sample_cred);
420
encode_run(c,cred,"cred","",encode_krb5_cred);
421
ktest_empty_cred(&c);
424
/****************************************************************/
425
/* encode_krb5_enc_cred_part */
427
krb5_cred_enc_part cep;
428
setup(cep,cred_enc_part,"cred_enc_part",ktest_make_sample_cred_enc_part);
429
encode_run(cep,enc_cred_part,"enc_cred_part","",encode_krb5_enc_cred_part);
431
ktest_destroy_principal(&(cep.ticket_info[0]->client));
432
ktest_destroy_principal(&(cep.ticket_info[0]->server));
433
cep.ticket_info[0]->flags = 0;
434
cep.ticket_info[0]->times.authtime = 0;
435
cep.ticket_info[0]->times.starttime = 0;
436
cep.ticket_info[0]->times.endtime = 0;
437
cep.ticket_info[0]->times.renew_till = 0;
438
ktest_destroy_addresses(&(cep.ticket_info[0]->caddrs));
441
ktest_destroy_address(&(cep.s_address));
442
ktest_destroy_address(&(cep.r_address));
443
encode_run(cep,enc_cred_part,"enc_cred_part","(optionals NULL)",encode_krb5_enc_cred_part);
445
ktest_empty_cred_enc_part(&cep);
448
/****************************************************************/
449
/* encode_krb5_error */
452
setup(kerr,error,"error",ktest_make_sample_error);
453
encode_run(kerr,error,"error","",encode_krb5_error);
456
ktest_destroy_principal(&(kerr.client));
457
ktest_empty_data(&(kerr.text));
458
ktest_empty_data(&(kerr.e_data));
459
encode_run(kerr,error,"error","(optionals NULL)",encode_krb5_error);
461
ktest_empty_error(&kerr);
464
/****************************************************************/
465
/* encode_krb5_authdata */
468
setup(ad,authorization_data,"authorization_data",ktest_make_sample_authorization_data);
470
retval = encode_krb5_authdata(ad,&(code));
472
com_err("encoding authorization_data",retval,"");
475
current_appl_type = 1004; /* Force type to be authdata */
476
encoder_print_results(code, "authorization_data", "");
478
ktest_destroy_authorization_data(&ad);
481
/****************************************************************/
482
/* encode_pwd_sequence */
484
passwd_phrase_element ppe;
485
setup(ppe,passwd_phrase_element,"PasswdSequence",ktest_make_sample_passwd_phrase_element);
486
encode_run(ppe,passwd_phrase_element,"pwd_sequence","",encode_krb5_pwd_sequence);
487
ktest_empty_passwd_phrase_element(&ppe);
490
/****************************************************************/
491
/* encode_passwd_data */
494
setup(pd,krb5_pwd_data,"PasswdData",ktest_make_sample_krb5_pwd_data);
495
encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data);
496
ktest_empty_pwd_data(&pd);
499
/****************************************************************/
500
/* encode_padata_sequence */
504
setup(pa,krb5_pa_data,"PreauthData",ktest_make_sample_pa_data_array);
505
retval = encode_krb5_padata_sequence(pa,&(code));
507
com_err("encoding padata_sequence",retval,"");
510
encoder_print_results(code, "padata_sequence", "");
512
ktest_destroy_pa_data_array(&pa);
515
/****************************************************************/
516
/* encode_padata_sequence (empty) */
520
setup(pa,krb5_pa_data,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array);
521
retval = encode_krb5_padata_sequence(pa,&(code));
523
com_err("encoding padata_sequence(empty)",retval,"");
526
encoder_print_results(code, "padata_sequence(empty)", "");
528
ktest_destroy_pa_data_array(&pa);
531
/****************************************************************/
532
/* encode_alt_method */
535
setup(am,krb5_alt_method,"AltMethod",ktest_make_sample_alt_method);
536
encode_run(am,krb5_alt_method,"alt_method","",encode_krb5_alt_method);
541
encode_run(am,krb5_alt_method,"alt_method (no data)","",
542
encode_krb5_alt_method);
543
ktest_empty_alt_method(&am);
546
/****************************************************************/
547
/* encode_etype_info */
549
krb5_etype_info_entry **info;
551
setup(info,krb5_etype_info_entry **,"etype_info",
552
ktest_make_sample_etype_info);
553
retval = encode_krb5_etype_info(info,&(code));
555
com_err("encoding etype_info",retval,"");
558
encoder_print_results(code, "etype_info", "");
559
ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
560
ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
562
retval = encode_krb5_etype_info(info,&(code));
564
com_err("encoding etype_info (only 1)",retval,"");
567
encoder_print_results(code, "etype_info (only 1)", "");
569
ktest_destroy_etype_info_entry(info[0]); info[0] = 0;
571
retval = encode_krb5_etype_info(info,&(code));
573
com_err("encoding etype_info (no info)",retval,"");
576
encoder_print_results(code, "etype_info (no info)", "");
578
ktest_destroy_etype_info(info);
581
/* encode_etype_info 2*/
583
krb5_etype_info_entry **info;
585
setup(info,krb5_etype_info_entry **,"etype_info2",
586
ktest_make_sample_etype_info2);
587
retval = encode_krb5_etype_info2(info,&(code));
589
com_err("encoding etype_info",retval,"");
592
encoder_print_results(code, "etype_info2", "");
593
ktest_destroy_etype_info_entry(info[2]); info[2] = 0;
594
ktest_destroy_etype_info_entry(info[1]); info[1] = 0;
596
retval = encode_krb5_etype_info2(info,&(code));
598
com_err("encoding etype_info (only 1)",retval,"");
601
encoder_print_results(code, "etype_info2 (only 1)", "");
603
ktest_destroy_etype_info(info);
603
604
/* ktest_destroy_etype_info_entry(info[0]); info[0] = 0;*/
607
/****************************************************************/
608
/* encode_pa_enc_ts */
610
krb5_pa_enc_ts pa_enc;
611
setup(pa_enc,krb5_pa_enc_ts,"pa_enc_ts",ktest_make_sample_pa_enc_ts);
612
encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts","",encode_krb5_pa_enc_ts);
614
encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts (no usec)","",encode_krb5_pa_enc_ts);
617
/****************************************************************/
618
/* encode_enc_data */
620
krb5_enc_data enc_data;
621
setup(enc_data,krb5_enc_data,"enc_data",ktest_make_sample_enc_data);
622
current_appl_type = 1001;
623
encode_run(enc_data,krb5_enc_data,"enc_data","",encode_krb5_enc_data);
624
ktest_destroy_enc_data(&enc_data);
626
/****************************************************************/
627
/* encode_krb5_sam_challenge */
629
krb5_sam_challenge sam_ch;
630
setup(sam_ch,krb5_sam_challenge,"sam_challenge",
631
ktest_make_sample_sam_challenge);
632
encode_run(sam_ch,krb5_sam_challenge,"sam_challenge","",
633
encode_krb5_sam_challenge);
634
ktest_empty_sam_challenge(&sam_ch);
636
/****************************************************************/
637
/* encode_krb5_sam_response */
639
krb5_sam_response sam_ch;
640
setup(sam_ch,krb5_sam_response,"sam_response",
641
ktest_make_sample_sam_response);
642
encode_run(sam_ch,krb5_sam_response,"sam_response","",
643
encode_krb5_sam_response);
644
ktest_empty_sam_response(&sam_ch);
647
/****************************************************************/
648
/* encode_krb5_sam_key */
651
setup(sam_ch,krb5_sam_key,"sam_key",
652
ktest_make_sample_sam_key);
653
encode_run(sam_ch,krb5_sam_key,"sam_key","",
654
encode_krb5_sam_key);
656
/****************************************************************/
657
/* encode_krb5_enc_sam_response_enc */
659
krb5_enc_sam_response_enc sam_ch;
660
setup(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc",
661
ktest_make_sample_enc_sam_response_enc);
662
encode_run(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc","",
663
encode_krb5_enc_sam_response_enc);
665
/****************************************************************/
666
/* encode_krb5_predicted_sam_response */
668
krb5_predicted_sam_response sam_ch;
669
setup(sam_ch,krb5_predicted_sam_response,"predicted_sam_response",
670
ktest_make_sample_predicted_sam_response);
671
encode_run(sam_ch,krb5_predicted_sam_response,"predicted_sam_response","",
672
encode_krb5_predicted_sam_response);
608
/****************************************************************/
609
/* encode_pa_enc_ts */
611
krb5_pa_enc_ts pa_enc;
612
setup(pa_enc,krb5_pa_enc_ts,"pa_enc_ts",ktest_make_sample_pa_enc_ts);
613
encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts","",encode_krb5_pa_enc_ts);
615
encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts (no usec)","",encode_krb5_pa_enc_ts);
618
/****************************************************************/
619
/* encode_enc_data */
621
krb5_enc_data enc_data;
622
setup(enc_data,krb5_enc_data,"enc_data",ktest_make_sample_enc_data);
623
current_appl_type = 1001;
624
encode_run(enc_data,krb5_enc_data,"enc_data","",encode_krb5_enc_data);
625
ktest_destroy_enc_data(&enc_data);
627
/****************************************************************/
628
/* encode_krb5_sam_challenge */
630
krb5_sam_challenge sam_ch;
631
setup(sam_ch,krb5_sam_challenge,"sam_challenge",
632
ktest_make_sample_sam_challenge);
633
encode_run(sam_ch,krb5_sam_challenge,"sam_challenge","",
634
encode_krb5_sam_challenge);
635
ktest_empty_sam_challenge(&sam_ch);
637
/****************************************************************/
638
/* encode_krb5_sam_response */
640
krb5_sam_response sam_ch;
641
setup(sam_ch,krb5_sam_response,"sam_response",
642
ktest_make_sample_sam_response);
643
encode_run(sam_ch,krb5_sam_response,"sam_response","",
644
encode_krb5_sam_response);
645
ktest_empty_sam_response(&sam_ch);
647
/****************************************************************/
648
/* encode_krb5_sam_key */
651
setup(sam_ch,krb5_sam_key,"sam_key",
652
ktest_make_sample_sam_key);
653
encode_run(sam_ch,krb5_sam_key,"sam_key","",
654
encode_krb5_sam_key);
655
ktest_empty_sam_key(&sam_ch);
657
/****************************************************************/
658
/* encode_krb5_enc_sam_response_enc */
660
krb5_enc_sam_response_enc sam_ch;
661
setup(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc",
662
ktest_make_sample_enc_sam_response_enc);
663
encode_run(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc","",
664
encode_krb5_enc_sam_response_enc);
665
ktest_empty_enc_sam_response_enc(&sam_ch);
667
/****************************************************************/
668
/* encode_krb5_predicted_sam_response */
670
krb5_predicted_sam_response sam_ch;
671
setup(sam_ch,krb5_predicted_sam_response,"predicted_sam_response",
672
ktest_make_sample_predicted_sam_response);
673
encode_run(sam_ch,krb5_predicted_sam_response,"predicted_sam_response","",
674
encode_krb5_predicted_sam_response);
675
ktest_empty_predicted_sam_response(&sam_ch);
677
/****************************************************************/
678
/* encode_krb5_sam_response_2 */
680
krb5_sam_response_2 sam_ch2;
681
setup(sam_ch2,krb5_sam_response_2,"sam_response_2",
682
ktest_make_sample_sam_response_2);
683
encode_run(sam_ch2,krb5_sam_response_2,"sam_response_2","",
684
acc.encode_krb5_sam_response_2);
685
ktest_empty_sam_response_2(&sam_ch2);
687
/****************************************************************/
688
/* encode_krb5_sam_response_enc_2 */
690
krb5_enc_sam_response_enc_2 sam_ch2;
691
setup(sam_ch2,krb5_enc_sam_response_enc_2,"enc_sam_response_enc_2",
692
ktest_make_sample_enc_sam_response_enc_2);
693
encode_run(sam_ch2,krb5_enc_sam_response_enc_2,
694
"enc_sam_response_enc_2","",
695
acc.encode_krb5_enc_sam_response_enc_2);
696
ktest_empty_enc_sam_response_enc_2(&sam_ch2);
700
ldap_seqof_key_data skd;
702
setup(skd, ldap_seqof_key_data, "ldap_seqof_key_data",
703
ktest_make_sample_ldap_seqof_key_data);
704
encode_run(skd, ldap_seqof_key_data, "ldap_seqof_key_data", "",
705
acc.asn1_ldap_encode_sequence_of_keys);
706
ktest_empty_ldap_seqof_key_data(test_context, &skd);
676
krb5_free_context(test_context);
710
krb5_free_context(test_context);