diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-01-06 20:51:57 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-01-06 20:51:57 +0000 |
commit | e0e94b5f8d392be83be3f55cf83141126d27fd01 (patch) | |
tree | e22c5c1b9464580a0aa499d3e5c1249f1f1470fe /src | |
parent | 255e1dd08f2398ef23a4ff83f69bb0806c6b76c7 (diff) | |
download | krb5-e0e94b5f8d392be83be3f55cf83141126d27fd01.tar.gz krb5-e0e94b5f8d392be83be3f55cf83141126d27fd01.tar.xz krb5-e0e94b5f8d392be83be3f55cf83141126d27fd01.zip |
Simplify and reformat ASN.1 test code
Use abort-on-error memory allocation to reduce failure handling.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25608 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/asn.1/krb5_decode_leak.c | 109 | ||||
-rw-r--r-- | src/tests/asn.1/krb5_decode_test.c | 104 | ||||
-rw-r--r-- | src/tests/asn.1/krb5_encode_test.c | 132 | ||||
-rw-r--r-- | src/tests/asn.1/ktest.c | 1353 | ||||
-rw-r--r-- | src/tests/asn.1/ktest.h | 298 | ||||
-rw-r--r-- | src/tests/asn.1/ktest_equal.c | 764 | ||||
-rw-r--r-- | src/tests/asn.1/ktest_equal.h | 86 | ||||
-rw-r--r-- | src/tests/asn.1/utility.c | 68 | ||||
-rw-r--r-- | src/tests/asn.1/utility.h | 31 |
9 files changed, 1191 insertions, 1754 deletions
diff --git a/src/tests/asn.1/krb5_decode_leak.c b/src/tests/asn.1/krb5_decode_leak.c index a9cd55d2c2..a8c144fdfb 100644 --- a/src/tests/asn.1/krb5_decode_leak.c +++ b/src/tests/asn.1/krb5_decode_leak.c @@ -75,14 +75,6 @@ main(int argc, char **argv) } init_access(argv[0]); -#define setup(value, typestring, constructor) \ - retval = constructor(&(value)); \ - if (retval) { \ - com_err("krb5_decode_leak", retval, "while making sample %s", \ - typestring); \ - exit(1); \ - } - #define encode_run(value,type,typestring,description,encoder) /* @@ -114,7 +106,7 @@ main(int argc, char **argv) { krb5_authenticator authent, *tmp; - setup(authent, "authenticator", ktest_make_sample_authenticator); + ktest_make_sample_authenticator(&authent); leak_test(authent, encode_krb5_authenticator, decode_krb5_authenticator, krb5_free_authenticator); @@ -136,7 +128,7 @@ main(int argc, char **argv) { krb5_ticket tkt, *tmp; - setup(tkt, "ticket", ktest_make_sample_ticket); + ktest_make_sample_ticket(&tkt); leak_test(tkt, encode_krb5_ticket, decode_krb5_ticket, krb5_free_ticket); ktest_empty_ticket(&tkt); @@ -147,7 +139,7 @@ main(int argc, char **argv) { krb5_keyblock keyblk, *tmp; - setup(keyblk, "keyblock", ktest_make_sample_keyblock); + ktest_make_sample_keyblock(&keyblk); leak_test(keyblk, encode_krb5_encryption_key, decode_krb5_encryption_key, krb5_free_keyblock); ktest_empty_keyblock(&keyblk); @@ -160,11 +152,8 @@ main(int argc, char **argv) krb5_enc_tkt_part *tmp; memset(&tkt, 0, sizeof(krb5_ticket)); - tkt.enc_part2 = calloc(1, sizeof(krb5_enc_tkt_part)); - if (tkt.enc_part2 == NULL) - com_err("allocating enc_tkt_part", errno, ""); - setup(*(tkt.enc_part2), "enc_tkt_part", - ktest_make_sample_enc_tkt_part); + tkt.enc_part2 = ealloc(sizeof(krb5_enc_tkt_part)); + ktest_make_sample_enc_tkt_part(tkt.enc_part2); leak_test(*(tkt.enc_part2), encode_krb5_enc_tkt_part, decode_krb5_enc_tkt_part, krb5_free_enc_tkt_part); @@ -193,11 +182,8 @@ main(int argc, char **argv) memset(&kdcr, 0, sizeof(kdcr)); - kdcr.enc_part2 = calloc(1, sizeof(krb5_enc_kdc_rep_part)); - if (kdcr.enc_part2 == NULL) - com_err("allocating enc_kdc_rep_part", errno, ""); - setup(*(kdcr.enc_part2), "enc_kdc_rep_part", - ktest_make_sample_enc_kdc_rep_part); + kdcr.enc_part2 = ealloc(sizeof(krb5_enc_kdc_rep_part)); + ktest_make_sample_enc_kdc_rep_part(kdcr.enc_part2); leak_test(*(kdcr.enc_part2), encode_krb5_enc_kdc_rep_part, decode_krb5_enc_kdc_rep_part, krb5_free_enc_kdc_rep_part); @@ -218,7 +204,7 @@ main(int argc, char **argv) { krb5_kdc_rep kdcr, *tmp; - setup(kdcr, "kdc_rep", ktest_make_sample_kdc_rep); + ktest_make_sample_kdc_rep(&kdcr); kdcr.msg_type = KRB5_AS_REP; leak_test(kdcr, encode_krb5_as_rep, decode_krb5_as_rep, krb5_free_kdc_rep); @@ -236,7 +222,7 @@ main(int argc, char **argv) { krb5_kdc_rep kdcr, *tmp; - setup(kdcr, "kdc_rep", ktest_make_sample_kdc_rep); + ktest_make_sample_kdc_rep(&kdcr); kdcr.msg_type = KRB5_TGS_REP; leak_test(kdcr, encode_krb5_tgs_rep, decode_krb5_tgs_rep, krb5_free_kdc_rep); @@ -254,7 +240,7 @@ main(int argc, char **argv) { krb5_ap_req apreq, *tmp; - setup(apreq, "ap_req", ktest_make_sample_ap_req); + ktest_make_sample_ap_req(&apreq); leak_test(apreq, encode_krb5_ap_req, decode_krb5_ap_req, krb5_free_ap_req); ktest_empty_ap_req(&apreq); @@ -265,7 +251,7 @@ main(int argc, char **argv) { krb5_ap_rep aprep, *tmp; - setup(aprep, "ap_rep", ktest_make_sample_ap_rep); + ktest_make_sample_ap_rep(&aprep); leak_test(aprep, encode_krb5_ap_rep, decode_krb5_ap_rep, krb5_free_ap_rep); ktest_empty_ap_rep(&aprep); @@ -276,7 +262,7 @@ main(int argc, char **argv) { krb5_ap_rep_enc_part apenc, *tmp; - setup(apenc, "ap_rep_enc_part", ktest_make_sample_ap_rep_enc_part); + ktest_make_sample_ap_rep_enc_part(&apenc); leak_test(apenc, encode_krb5_ap_rep_enc_part, decode_krb5_ap_rep_enc_part, krb5_free_ap_rep_enc_part); @@ -292,7 +278,7 @@ main(int argc, char **argv) { krb5_kdc_req asreq, *tmp; - setup(asreq, "kdc_req", ktest_make_sample_kdc_req); + ktest_make_sample_kdc_req(&asreq); asreq.msg_type = KRB5_AS_REQ; asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; leak_test(asreq, encode_krb5_as_req, decode_krb5_as_req, @@ -326,7 +312,7 @@ main(int argc, char **argv) { krb5_kdc_req tgsreq, *tmp; - setup(tgsreq, "kdc_req", ktest_make_sample_kdc_req); + ktest_make_sample_kdc_req(&tgsreq); tgsreq.msg_type = KRB5_TGS_REQ; tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; leak_test(tgsreq, encode_krb5_tgs_req, decode_krb5_tgs_req, @@ -361,7 +347,7 @@ main(int argc, char **argv) krb5_kdc_req kdcrb, *tmp; memset(&kdcrb, 0, sizeof(kdcrb)); - setup(kdcrb, "kdc_req_body", ktest_make_sample_kdc_req_body); + ktest_make_sample_kdc_req_body(&kdcrb); kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; leak_test(kdcrb, encode_krb5_kdc_req_body, decode_krb5_kdc_req_body, krb5_free_kdc_req); @@ -393,7 +379,7 @@ main(int argc, char **argv) { krb5_safe s, *tmp; - setup(s, "safe", ktest_make_sample_safe); + ktest_make_sample_safe(&s); leak_test(s, encode_krb5_safe, decode_krb5_safe, krb5_free_safe); s.timestamp = 0; @@ -409,7 +395,7 @@ main(int argc, char **argv) { krb5_priv p, *tmp; - setup(p, "priv", ktest_make_sample_priv); + ktest_make_sample_priv(&p); leak_test(p, encode_krb5_priv, decode_krb5_priv, krb5_free_priv); ktest_empty_priv(&p); } @@ -419,7 +405,7 @@ main(int argc, char **argv) { krb5_priv_enc_part ep, *tmp; - setup(ep, "priv_enc_part", ktest_make_sample_priv_enc_part); + ktest_make_sample_priv_enc_part(&ep); leak_test(ep, encode_krb5_enc_priv_part, decode_krb5_enc_priv_part, krb5_free_priv_enc_part); @@ -437,7 +423,7 @@ main(int argc, char **argv) { krb5_cred c, *tmp; - setup(c, "cred", ktest_make_sample_cred); + ktest_make_sample_cred(&c); leak_test(c, encode_krb5_cred, decode_krb5_cred, krb5_free_cred); ktest_empty_cred(&c); } @@ -447,7 +433,7 @@ main(int argc, char **argv) { krb5_cred_enc_part cep, *tmp; - setup(cep, "cred_enc_part", ktest_make_sample_cred_enc_part); + ktest_make_sample_cred_enc_part(&cep); leak_test(cep, encode_krb5_enc_cred_part, decode_krb5_enc_cred_part, free_cred_enc_part_whole); @@ -473,7 +459,7 @@ main(int argc, char **argv) { krb5_error kerr, *tmp; - setup(kerr, "error", ktest_make_sample_error); + ktest_make_sample_error(&kerr); leak_test(kerr, encode_krb5_error, decode_krb5_error, krb5_free_error); kerr.ctime = 0; @@ -490,7 +476,7 @@ main(int argc, char **argv) { krb5_authdata **ad, **tmp; - setup(ad, "authorization_data", ktest_make_sample_authorization_data); + ktest_make_sample_authorization_data(&ad); leak_test(*ad, encode_krb5_authdata, decode_krb5_authdata, krb5_free_authdata); ktest_destroy_authorization_data(&ad); @@ -501,7 +487,7 @@ main(int argc, char **argv) { passwd_phrase_element ppe, *tmp; - setup(ppe, "PasswdSequence", ktest_make_sample_passwd_phrase_element); + ktest_make_sample_passwd_phrase_element(&ppe); leak_test(ppe, encode_krb5_pwd_sequence, decode_krb5_pwd_sequence, krb5_free_passwd_phrase_element); ktest_empty_passwd_phrase_element(&ppe); @@ -512,7 +498,7 @@ main(int argc, char **argv) { krb5_pwd_data pd, *tmp; - setup(pd, "PasswdData", ktest_make_sample_krb5_pwd_data); + ktest_make_sample_krb5_pwd_data(&pd); leak_test(pd, encode_krb5_pwd_data, decode_krb5_pwd_data, krb5_free_pwd_data); ktest_empty_pwd_data(&pd); @@ -523,7 +509,7 @@ main(int argc, char **argv) { krb5_pa_data **pa, **tmp; - setup(pa, "PreauthData", ktest_make_sample_pa_data_array); + ktest_make_sample_pa_data_array(&pa); leak_test(*pa, encode_krb5_padata_sequence, decode_krb5_padata_sequence, krb5_free_pa_data); ktest_destroy_pa_data_array(&pa); @@ -534,7 +520,7 @@ main(int argc, char **argv) { krb5_pa_data **pa, **tmp; - setup(pa,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array); + ktest_make_sample_empty_pa_data_array(&pa); leak_test(*pa, encode_krb5_padata_sequence, decode_krb5_padata_sequence, krb5_free_pa_data); ktest_destroy_pa_data_array(&pa); @@ -545,7 +531,7 @@ main(int argc, char **argv) { krb5_alt_method am, *tmp; - setup(am, "AltMethod", ktest_make_sample_alt_method); + ktest_make_sample_alt_method(&am); leak_test(am, encode_krb5_alt_method, decode_krb5_alt_method, krb5_free_alt_method); am.length = 0; @@ -562,7 +548,7 @@ main(int argc, char **argv) { krb5_etype_info_entry **info, **tmp; - setup(info, "etype_info", ktest_make_sample_etype_info); + ktest_make_sample_etype_info(&info); leak_test(*info, encode_krb5_etype_info, decode_krb5_etype_info, krb5_free_etype_info); @@ -582,7 +568,7 @@ main(int argc, char **argv) { krb5_etype_info_entry **info, **tmp; - setup(info, "etype_info2", ktest_make_sample_etype_info2); + ktest_make_sample_etype_info2(&info); leak_test(*info, encode_krb5_etype_info2, decode_krb5_etype_info2, krb5_free_etype_info); @@ -599,7 +585,7 @@ main(int argc, char **argv) { krb5_pa_enc_ts pa_enc, *tmp; - setup(pa_enc, "pa_enc_ts", ktest_make_sample_pa_enc_ts); + ktest_make_sample_pa_enc_ts(&pa_enc); leak_test(pa_enc, encode_krb5_pa_enc_ts, decode_krb5_pa_enc_ts, krb5_free_pa_enc_ts); pa_enc.pausec = 0; @@ -612,7 +598,7 @@ main(int argc, char **argv) { krb5_enc_data enc_data, *tmp; - setup(enc_data, "enc_data", ktest_make_sample_enc_data); + ktest_make_sample_enc_data(&enc_data); leak_test(enc_data, encode_krb5_enc_data, decode_krb5_enc_data, krb5_free_enc_data); ktest_destroy_enc_data(&enc_data); @@ -622,7 +608,7 @@ main(int argc, char **argv) { krb5_sam_challenge sam_ch, *tmp; - setup(sam_ch, "sam_challenge", ktest_make_sample_sam_challenge); + ktest_make_sample_sam_challenge(&sam_ch); leak_test(sam_ch, encode_krb5_sam_challenge, decode_krb5_sam_challenge, krb5_free_sam_challenge); ktest_empty_sam_challenge(&sam_ch); @@ -632,7 +618,7 @@ main(int argc, char **argv) { krb5_sam_response sam_ch, *tmp; - setup(sam_ch, "sam_response", ktest_make_sample_sam_response); + ktest_make_sample_sam_response(&sam_ch); leak_test(sam_ch, encode_krb5_sam_response, decode_krb5_sam_response, krb5_free_sam_response); ktest_empty_sam_response(&sam_ch); @@ -642,8 +628,7 @@ main(int argc, char **argv) { krb5_enc_sam_response_enc sam_ch, *tmp; - setup(sam_ch, "enc_sam_response_enc", - ktest_make_sample_enc_sam_response_enc); + ktest_make_sample_enc_sam_response_enc(&sam_ch); leak_test(sam_ch, encode_krb5_enc_sam_response_enc, decode_krb5_enc_sam_response_enc, krb5_free_enc_sam_response_enc); @@ -654,8 +639,7 @@ main(int argc, char **argv) { krb5_predicted_sam_response sam_ch, *tmp; - setup(sam_ch, "predicted_sam_response", - ktest_make_sample_predicted_sam_response); + ktest_make_sample_predicted_sam_response(&sam_ch); leak_test(sam_ch, encode_krb5_predicted_sam_response, decode_krb5_predicted_sam_response, krb5_free_predicted_sam_response); @@ -666,7 +650,7 @@ main(int argc, char **argv) { krb5_sam_response_2 sam_ch2, *tmp; - setup(sam_ch2, "sam_response_2", ktest_make_sample_sam_response_2); + ktest_make_sample_sam_response_2(&sam_ch2); leak_test(sam_ch2, encode_krb5_sam_response_2, decode_krb5_sam_response_2, krb5_free_sam_response_2); ktest_empty_sam_response_2(&sam_ch2); @@ -676,8 +660,7 @@ main(int argc, char **argv) { krb5_enc_sam_response_enc_2 sam_ch2, *tmp; - setup(sam_ch2, "enc_sam_response_enc_2", - ktest_make_sample_enc_sam_response_enc_2); + ktest_make_sample_enc_sam_response_enc_2(&sam_ch2); leak_test(sam_ch2, encode_krb5_enc_sam_response_enc_2, decode_krb5_enc_sam_response_enc_2, krb5_free_enc_sam_response_enc_2); @@ -687,8 +670,7 @@ main(int argc, char **argv) /* encode_krb5_pa_s4u_x509_user */ { krb5_pa_s4u_x509_user s4u, *tmp; - setup(s4u, "pa_s4u_x509_user", - ktest_make_sample_pa_s4u_x509_user); + ktest_make_sample_pa_s4u_x509_user(&s4u); leak_test(s4u, encode_krb5_pa_s4u_x509_user, decode_krb5_pa_s4u_x509_user, krb5_free_pa_s4u_x509_user); @@ -698,8 +680,7 @@ main(int argc, char **argv) /* encode_krb5_ad_kdcissued */ { krb5_ad_kdcissued kdci, *tmp; - setup(kdci, "ad_kdcissued", - ktest_make_sample_ad_kdcissued); + ktest_make_sample_ad_kdcissued(&kdci); leak_test(kdci, encode_krb5_ad_kdcissued, decode_krb5_ad_kdcissued, krb5_free_ad_kdcissued); @@ -710,8 +691,7 @@ main(int argc, char **argv) /* encode_krb5_ad_signedpath_data */ { krb5_ad_signedpath_data spd, *tmp; - setup(spd, "ad_signedpath_data", - ktest_make_sample_ad_signedpath_data); + ktest_make_sample_ad_signedpath_data(&spd); leak_test(spd, encode_krb5_ad_signedpath_data, decode_krb5_ad_signedpath_data, NULL); @@ -722,8 +702,7 @@ main(int argc, char **argv) /* encode_krb5_ad_signedpath */ { krb5_ad_signedpath sp, *tmp; - setup(sp, "ad_signedpath", - ktest_make_sample_ad_signedpath); + ktest_make_sample_ad_signedpath(&sp); leak_test(sp, encode_krb5_ad_signedpath, decode_krb5_ad_signedpath, krb5_free_ad_signedpath); @@ -733,8 +712,7 @@ main(int argc, char **argv) /* encode_krb5_iakerb_header */ { krb5_iakerb_header ih, *tmp; - setup(ih, "iakerb_header", - ktest_make_sample_iakerb_header); + ktest_make_sample_iakerb_header(&ih); leak_test(ih, encode_krb5_iakerb_header, decode_krb5_iakerb_header, krb5_free_iakerb_header); @@ -744,8 +722,7 @@ main(int argc, char **argv) /* encode_krb5_iakerb_finished */ { krb5_iakerb_finished ih, *tmp; - setup(ih, "iakerb_finished", - ktest_make_sample_iakerb_finished); + ktest_make_sample_iakerb_finished(&ih); leak_test(ih, encode_krb5_iakerb_finished, decode_krb5_iakerb_finished, krb5_free_iakerb_finished); diff --git a/src/tests/asn.1/krb5_decode_test.c b/src/tests/asn.1/krb5_decode_test.c index 32de38e164..b9de342a69 100644 --- a/src/tests/asn.1/krb5_decode_test.c +++ b/src/tests/asn.1/krb5_decode_test.c @@ -56,13 +56,9 @@ int main(argc, argv) init_access(argv[0]); -#define setup(type,typestring,constructor) \ +#define setup(type,constructor) \ type ref, *var; \ - retval = constructor(&ref); \ - if (retval) { \ - com_err("krb5_decode_test", retval, "while making sample %s", typestring); \ - exit(1); \ - } + constructor(&ref); \ #define decode_run(typestring,description,encoding,decoder,comparator,cleanup) \ retval = krb5_data_hex_parse(&code,encoding); \ @@ -83,7 +79,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_authenticator */ { - setup(krb5_authenticator,"krb5_authenticator",ktest_make_sample_authenticator); + setup(krb5_authenticator,ktest_make_sample_authenticator); decode_run("authenticator","","62 81 A1 30 81 9E A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A4 05 02 03 01 E2 40 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A7 03 02 01 11 A8 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_authenticator,ktest_equal_authenticator,krb5_free_authenticator); @@ -271,7 +267,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_ticket */ { - setup(krb5_ticket,"krb5_ticket",ktest_make_sample_ticket); + setup(krb5_ticket,ktest_make_sample_ticket); decode_run("ticket","","61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket); decode_run("ticket","(+ trailing [4] INTEGER","61 61 30 5F A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A4 03 02 01 01",decode_krb5_ticket,ktest_equal_ticket,krb5_free_ticket); @@ -324,7 +320,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_encryption_key */ { - setup(krb5_keyblock,"krb5_keyblock",ktest_make_sample_keyblock); + setup(krb5_keyblock,ktest_make_sample_keyblock); decode_run("encryption_key","","30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38",decode_krb5_encryption_key,ktest_equal_encryption_key,krb5_free_keyblock); @@ -351,7 +347,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_enc_tkt_part */ { - setup(krb5_enc_tkt_part,"krb5_enc_tkt_part",ktest_make_sample_enc_tkt_part); + setup(krb5_enc_tkt_part,ktest_make_sample_enc_tkt_part); decode_run("enc_tkt_part","","63 82 01 14 30 82 01 10 A0 07 03 05 00 FE DC BA 98 A1 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 2E 30 2C A0 03 02 01 01 A1 25 04 23 45 44 55 2C 4D 49 54 2E 2C 41 54 48 45 4E 41 2E 2C 57 41 53 48 49 4E 47 54 4F 4E 2E 45 44 55 2C 43 53 2E A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part,krb5_free_enc_tkt_part); /* ref.times.starttime = 0; */ @@ -383,7 +379,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_enc_kdc_rep_part */ { - setup(krb5_enc_kdc_rep_part,"krb5_enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part); + setup(krb5_enc_kdc_rep_part,ktest_make_sample_enc_kdc_rep_part); #ifdef KRB5_GENEROUS_LR_TYPE decode_run("enc_kdc_rep_part","(compat_lr_type)","7A 82 01 10 30 82 01 0C A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 38 30 36 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A 30 19 A0 04 02 02 00 FB A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 03 02 01 2A A3 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A4 07 03 05 00 FE DC BA 98 A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part,krb5_free_enc_kdc_rep_part); @@ -410,7 +406,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_as_rep */ { - setup(krb5_kdc_rep,"krb5_kdc_rep",ktest_make_sample_kdc_rep); + setup(krb5_kdc_rep,ktest_make_sample_kdc_rep); ref.msg_type = KRB5_AS_REP; decode_run("as_rep","","6B 81 EA 30 81 E7 A0 03 02 01 05 A1 03 02 01 0B A2 26 30 24 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_as_rep,ktest_equal_as_rep,krb5_free_kdc_rep); @@ -474,7 +470,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_tgs_rep */ { - setup(krb5_kdc_rep,"krb5_kdc_rep",ktest_make_sample_kdc_rep); + setup(krb5_kdc_rep,ktest_make_sample_kdc_rep); ref.msg_type = KRB5_TGS_REP; decode_run("tgs_rep","","6D 81 EA 30 81 E7 A0 03 02 01 05 A1 03 02 01 0D A2 26 30 24 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 A3 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A4 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A5 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A6 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_tgs_rep,ktest_equal_tgs_rep,krb5_free_kdc_rep); @@ -488,7 +484,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_ap_req */ { - setup(krb5_ap_req,"krb5_ap_req",ktest_make_sample_ap_req); + setup(krb5_ap_req,ktest_make_sample_ap_req); decode_run("ap_req","","6E 81 9D 30 81 9A A0 03 02 01 05 A1 03 02 01 0E A2 07 03 05 00 FE DC BA 98 A3 5E 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A4 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ap_req,ktest_equal_ap_req,krb5_free_ap_req); ktest_empty_ap_req(&ref); @@ -497,7 +493,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_ap_rep */ { - setup(krb5_ap_rep,"krb5_ap_rep",ktest_make_sample_ap_rep); + setup(krb5_ap_rep,ktest_make_sample_ap_rep); decode_run("ap_rep","","6F 33 30 31 A0 03 02 01 05 A1 03 02 01 0F A2 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_ap_rep,ktest_equal_ap_rep,krb5_free_ap_rep); ktest_empty_ap_rep(&ref); } @@ -505,7 +501,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_ap_rep_enc_part */ { - setup(krb5_ap_rep_enc_part,"krb5_ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part); + setup(krb5_ap_rep_enc_part,ktest_make_sample_ap_rep_enc_part); decode_run("ap_rep_enc_part","","7B 36 30 34 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40 A2 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A3 03 02 01 11",decode_krb5_ap_rep_enc_part,ktest_equal_ap_rep_enc_part,krb5_free_ap_rep_enc_part); @@ -534,7 +530,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_as_req */ { - setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req); + setup(krb5_kdc_req,ktest_make_sample_kdc_req); ref.msg_type = KRB5_AS_REQ; ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; @@ -566,7 +562,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_tgs_req */ { - setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req); + setup(krb5_kdc_req,ktest_make_sample_kdc_req); ref.msg_type = KRB5_TGS_REQ; ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; @@ -599,11 +595,7 @@ int main(argc, argv) { krb5_kdc_req ref, *var; memset(&ref, 0, sizeof(krb5_kdc_req)); - retval = ktest_make_sample_kdc_req_body(&ref); - if (retval) { - com_err("making sample kdc_req_body",retval,""); - exit(1); - } + ktest_make_sample_kdc_req_body(&ref); ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; decode_run("kdc_req_body","","30 82 01 A6 A0 07 03 05 00 FE DC BA 90 A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 03 02 01 2A A8 08 30 06 02 01 00 02 01 01 A9 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 AA 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 AB 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body,krb5_free_kdc_req); @@ -636,7 +628,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_safe */ { - setup(krb5_safe,"krb5_safe",ktest_make_sample_safe); + setup(krb5_safe,ktest_make_sample_safe); decode_run("safe","","74 6E 30 6C A0 03 02 01 05 A1 03 02 01 14 A2 4F 30 4D A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 05 02 03 01 E2 40 A3 03 02 01 11 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A3 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_safe,ktest_equal_safe,krb5_free_safe); ref.timestamp = 0; @@ -651,7 +643,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_priv */ { - setup(krb5_priv,"krb5_priv",ktest_make_sample_priv); + setup(krb5_priv,ktest_make_sample_priv); decode_run("priv","","75 33 30 31 A0 03 02 01 05 A1 03 02 01 15 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_priv,ktest_equal_priv,krb5_free_priv); ktest_empty_priv(&ref); } @@ -659,7 +651,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_enc_priv_part */ { - setup(krb5_priv_enc_part,"krb5_priv_enc_part",ktest_make_sample_priv_enc_part); + setup(krb5_priv_enc_part,ktest_make_sample_priv_enc_part); decode_run("enc_priv_part","","7C 4F 30 4D A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A2 05 02 03 01 E2 40 A3 03 02 01 11 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_priv_part,ktest_equal_enc_priv_part,krb5_free_priv_enc_part); ref.timestamp = 0; @@ -673,7 +665,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_cred */ { - setup(krb5_cred,"krb5_cred",ktest_make_sample_cred); + setup(krb5_cred,ktest_make_sample_cred); decode_run("cred","","76 81 F6 30 81 F3 A0 03 02 01 05 A1 03 02 01 16 A2 81 BF 30 81 BC 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 61 5C 30 5A A0 03 02 01 05 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 A3 25 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_cred,ktest_equal_cred,krb5_free_cred); ktest_empty_cred(&ref); } @@ -681,7 +673,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_enc_cred_part */ { - setup(krb5_cred_enc_part,"krb5_cred_enc_part",ktest_make_sample_cred_enc_part); + setup(krb5_cred_enc_part,ktest_make_sample_cred_enc_part); decode_run("enc_cred_part","","7D 82 02 23 30 82 02 1F A0 82 01 DA 30 82 01 D6 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 81 E8 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 07 03 05 00 FE DC BA 98 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A8 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A9 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AA 20 30 1E 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A1 03 02 01 2A A2 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A3 05 02 03 01 E2 40 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 A5 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23",decode_krb5_enc_cred_part,ktest_equal_enc_cred_part,krb5_free_cred_enc_part); /* free_cred_enc_part does not free the pointer */ free(var); @@ -708,7 +700,7 @@ int main(argc, argv) /****************************************************************/ /* decode_krb5_error */ { - setup(krb5_error,"krb5_error",ktest_make_sample_error); + setup(krb5_error,ktest_make_sample_error); decode_run("error","","7E 81 BA 30 81 B7 A0 03 02 01 05 A1 03 02 01 1E A2 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A3 05 02 03 01 E2 40 A4 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A5 05 02 03 01 E2 40 A6 03 02 01 3C A7 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A8 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A9 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 AA 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 AB 0A 1B 08 6B 72 62 35 64 61 74 61 AC 0A 04 08 6B 72 62 35 64 61 74 61",decode_krb5_error,ktest_equal_error,krb5_free_error); ref.ctime = 0; @@ -724,11 +716,7 @@ int main(argc, argv) /* decode_krb5_authdata */ { krb5_authdata **ref, **var; - retval = ktest_make_sample_authorization_data(&ref); - if (retval) { - com_err("making sample authorization_data",retval,""); - exit(1); - } + ktest_make_sample_authorization_data(&ref); retval = krb5_data_hex_parse(&code,"30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72"); if (retval) { com_err("parsing authorization_data",retval,""); @@ -745,7 +733,7 @@ int main(argc, argv) /****************************************************************/ /* decode_pwd_sequence */ { - setup(passwd_phrase_element,"passwd_phrase_element",ktest_make_sample_passwd_phrase_element); + setup(passwd_phrase_element,ktest_make_sample_passwd_phrase_element); decode_run("PasswdSequence","","30 18 A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 0A 04 08 6B 72 62 35 64 61 74 61",decode_krb5_pwd_sequence,ktest_equal_passwd_phrase_element,krb5_ktest_free_pwd_sequence); ktest_empty_passwd_phrase_element(&ref); } @@ -753,7 +741,7 @@ int main(argc, argv) /****************************************************************/ /* decode_passwd_data */ { - setup(krb5_pwd_data,"krb5_pwd_data",ktest_make_sample_krb5_pwd_data); + setup(krb5_pwd_data,ktest_make_sample_krb5_pwd_data); decode_run("PasswdData","","30 3D A0 03 02 01 02 A1 36 30 34 30 18 A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 0A 04 08 6B 72 62 35 64 61 74 61 30 18 A0 0A 04 08 6B 72 62 35 64 61 74 61 A1 0A 04 08 6B 72 62 35 64 61 74 61",decode_krb5_pwd_data,ktest_equal_krb5_pwd_data,krb5_free_pwd_data); ktest_empty_pwd_data(&ref); } @@ -762,11 +750,7 @@ int main(argc, argv) /* decode_krb5_padata_sequence */ { krb5_pa_data **ref, **var; - retval = ktest_make_sample_pa_data_array(&ref); - if (retval) { - com_err("making sample pa_data array",retval,""); - exit(1); - } + ktest_make_sample_pa_data_array(&ref); retval = krb5_data_hex_parse(&code,"30 24 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61"); if (retval) { com_err("parsing padata_sequence",retval,""); @@ -784,11 +768,7 @@ int main(argc, argv) /* decode_krb5_padata_sequence (empty) */ { krb5_pa_data **ref, **var; - retval = ktest_make_sample_empty_pa_data_array(&ref); - if (retval) { - com_err("making sample empty pa_data array",retval,""); - exit(1); - } + ktest_make_sample_empty_pa_data_array(&ref); retval = krb5_data_hex_parse(&code,"30 00"); if (retval) { com_err("parsing padata_sequence (empty)",retval,""); @@ -805,7 +785,7 @@ int main(argc, argv) /****************************************************************/ /* decode_pwd_sequence */ { - setup(krb5_alt_method,"krb5_alt_method",ktest_make_sample_alt_method); + setup(krb5_alt_method,ktest_make_sample_alt_method); decode_run("alt_method","","30 0F A0 03 02 01 2A A1 08 04 06 73 65 63 72 65 74",decode_krb5_alt_method,ktest_equal_krb5_alt_method,krb5_ktest_free_alt_method); ref.length = 0; decode_run("alt_method (no data)","","30 05 A0 03 02 01 2A",decode_krb5_alt_method,ktest_equal_krb5_alt_method,krb5_ktest_free_alt_method); @@ -817,12 +797,7 @@ int main(argc, argv) { krb5_etype_info ref, var; - retval = ktest_make_sample_etype_info(&ref); - if (retval) { - com_err("krb5_decode_test", retval, - "while making sample etype info"); - exit(1); - } + ktest_make_sample_etype_info(&ref); retval = krb5_data_hex_parse(&code,"30 33 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 30 05 A0 03 02 01 01 30 14 A0 03 02 01 02 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 32"); if (retval) { com_err("krb5_decode_test", retval, "while parsing etype_info"); @@ -877,7 +852,7 @@ int main(argc, argv) /****************************************************************/ /* decode_pa_enc_ts */ { - setup(krb5_pa_enc_ts,"krb5_pa_enc_ts",ktest_make_sample_pa_enc_ts); + setup(krb5_pa_enc_ts,ktest_make_sample_pa_enc_ts); decode_run("pa_enc_ts","","30 1A A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40",decode_krb5_pa_enc_ts,ktest_equal_krb5_pa_enc_ts,krb5_free_pa_enc_ts); ref.pausec = 0; decode_run("pa_enc_ts (no usec)","","30 13 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_pa_enc_ts,ktest_equal_krb5_pa_enc_ts,krb5_free_pa_enc_ts); @@ -886,7 +861,7 @@ int main(argc, argv) /****************************************************************/ /* decode_enc_data */ { - setup(krb5_enc_data,"krb5_enc_data",ktest_make_sample_enc_data); + setup(krb5_enc_data,ktest_make_sample_enc_data); decode_run("enc_data","","30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65",decode_krb5_enc_data,ktest_equal_enc_data,krb5_ktest_free_enc_data); ktest_destroy_enc_data(&ref); } @@ -894,7 +869,7 @@ int main(argc, argv) /****************************************************************/ /* decode_sam_challenge */ { - setup(krb5_sam_challenge,"krb5_sam_challenge",ktest_make_sample_sam_challenge); + setup(krb5_sam_challenge,ktest_make_sample_sam_challenge); decode_run("sam_challenge","","30 78 A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0B 04 09 74 79 70 65 20 6E 61 6D 65 A3 02 04 00 A4 11 04 0F 63 68 61 6C 6C 65 6E 67 65 20 6C 61 62 65 6C A5 10 04 0E 63 68 61 6C 6C 65 6E 67 65 20 69 70 73 65 A6 16 04 14 72 65 73 70 6F 6E 73 65 5F 70 72 6F 6D 70 74 20 69 70 73 65 A7 02 04 00 A8 05 02 03 54 32 10 A9 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_sam_challenge,ktest_equal_sam_challenge,krb5_free_sam_challenge); ktest_empty_sam_challenge(&ref); @@ -903,7 +878,7 @@ int main(argc, argv) /****************************************************************/ /* decode_sam_challenge */ { - setup(krb5_sam_challenge,"krb5_sam_challenge - no optionals",ktest_make_sample_sam_challenge); + setup(krb5_sam_challenge,ktest_make_sample_sam_challenge); decode_run("sam_challenge","","30 70 A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0B 04 09 74 79 70 65 20 6E 61 6D 65 A4 11 04 0F 63 68 61 6C 6C 65 6E 67 65 20 6C 61 62 65 6C A5 10 04 0E 63 68 61 6C 6C 65 6E 67 65 20 69 70 73 65 A6 16 04 14 72 65 73 70 6F 6E 73 65 5F 70 72 6F 6D 70 74 20 69 70 73 65 A8 05 02 03 54 32 10 A9 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_sam_challenge,ktest_equal_sam_challenge,krb5_free_sam_challenge); ktest_empty_sam_challenge(&ref); } @@ -911,7 +886,7 @@ int main(argc, argv) /****************************************************************/ /* decode_sam_response */ { - setup(krb5_sam_response,"krb5_sam_response",ktest_make_sample_sam_response); + setup(krb5_sam_response,ktest_make_sample_sam_response); decode_run("sam_response","","30 6A A0 03 02 01 2A A1 07 03 05 00 80 00 00 00 A2 0C 04 0A 74 72 61 63 6B 20 64 61 74 61 A3 14 30 12 A0 03 02 01 01 A1 04 02 02 07 96 A2 05 04 03 6B 65 79 A4 1C 30 1A A0 03 02 01 01 A1 04 02 02 0D 36 A2 0D 04 0B 6E 6F 6E 63 65 20 6F 72 20 74 73 A5 05 02 03 54 32 10 A6 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_sam_response,ktest_equal_sam_response,krb5_free_sam_response); ktest_empty_sam_response(&ref); @@ -920,7 +895,7 @@ int main(argc, argv) /****************************************************************/ /* decode_pa_s4u_x509_user */ { - setup(krb5_pa_s4u_x509_user,"krb5_pa_s4u_x509_user",ktest_make_sample_pa_s4u_x509_user); + setup(krb5_pa_s4u_x509_user,ktest_make_sample_pa_s4u_x509_user); decode_run("pa_s4u_x509_user","","30 68 A0 55 30 53 A0 06 02 04 00 CA 14 9A A1 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A3 12 04 10 70 61 5F 73 34 75 5F 78 35 30 39 5F 75 73 65 72 A4 07 03 05 00 80 00 00 00 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_pa_s4u_x509_user,ktest_equal_pa_s4u_x509_user,krb5_free_pa_s4u_x509_user); ktest_empty_pa_s4u_x509_user(&ref); } @@ -928,7 +903,7 @@ int main(argc, argv) /****************************************************************/ /* decode_ad_kdcissued */ { - setup(krb5_ad_kdcissued,"krb5_ad_kdcissued",ktest_make_sample_ad_kdcissued); + setup(krb5_ad_kdcissued,ktest_make_sample_ad_kdcissued); decode_run("ad_kdcissued","","30 65 A0 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A1 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A2 1A 30 18 A0 03 02 01 01 A1 11 30 0F 1B 06 68 66 74 73 61 69 1B 05 65 78 74 72 61 A3 24 30 22 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72 30 0F A0 03 02 01 01 A1 08 04 06 66 6F 6F 62 61 72",decode_krb5_ad_kdcissued,ktest_equal_ad_kdcissued,krb5_free_ad_kdcissued); ktest_empty_ad_kdcissued(&ref); } @@ -936,7 +911,7 @@ int main(argc, argv) /****************************************************************/ /* decode_ad_signedpath */ { - setup(krb5_ad_signedpath,"krb5_ad_signedpath",ktest_make_sample_ad_signedpath); + setup(krb5_ad_signedpath,ktest_make_sample_ad_signedpath); decode_run("ad_signedpath","","30 3E A0 03 02 01 01 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34 A3 26 30 24 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 61 74 61",decode_krb5_ad_signedpath,ktest_equal_ad_signedpath,krb5_free_ad_signedpath); ktest_empty_ad_signedpath(&ref); } @@ -944,7 +919,7 @@ int main(argc, argv) /****************************************************************/ /* decode_iakerb_header */ { - setup(krb5_iakerb_header,"krb5_iakerb_header",ktest_make_sample_iakerb_header); + setup(krb5_iakerb_header,ktest_make_sample_iakerb_header); decode_run("iakerb_header","","30 18 A1 0A 04 08 6B 72 62 35 64 61 74 61 A2 0A 04 08 6B 72 62 35 64 61 74 61",decode_krb5_iakerb_header,ktest_equal_iakerb_header,krb5_free_iakerb_header); ktest_empty_iakerb_header(&ref); } @@ -952,7 +927,7 @@ int main(argc, argv) /****************************************************************/ /* decode_iakerb_finished */ { - setup(krb5_iakerb_finished,"krb5_iakerb_finished",ktest_make_sample_iakerb_finished); + setup(krb5_iakerb_finished,ktest_make_sample_iakerb_finished); decode_run("iakerb_finished","","30 11 A1 0F 30 0D A0 03 02 01 01 A1 06 04 04 31 32 33 34",decode_krb5_iakerb_finished,ktest_equal_iakerb_finished,krb5_free_iakerb_finished); ktest_empty_iakerb_finished(&ref); } @@ -960,8 +935,7 @@ int main(argc, argv) #ifdef ENABLE_LDAP /* ldap sequence_of_keys */ { - setup(ldap_seqof_key_data,"ldap_seqof_key_data", - ktest_make_sample_ldap_seqof_key_data); + setup(ldap_seqof_key_data,ktest_make_sample_ldap_seqof_key_data); decode_run("ldap_seqof_key_data","","30 81 87 A0 03 02 01 01 A1 03 02 01 01 A2 03 02 01 2A A3 03 02 01 0E A4 71 30 6F 30 23 A0 10 30 0E A0 03 02 01 00 A1 07 04 05 73 61 6C 74 30 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 30 30 23 A0 10 30 0E A0 03 02 01 01 A1 07 04 05 73 61 6C 74 31 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 31 30 23 A0 10 30 0E A0 03 02 01 02 A1 07 04 05 73 61 6C 74 32 A1 0F 30 0D A0 03 02 01 02 A1 06 04 04 6B 65 79 32",acc.asn1_ldap_decode_sequence_of_keys,ktest_equal_ldap_sequence_of_keys,ktest_empty_ldap_seqof_key_data); ktest_empty_ldap_seqof_key_data(test_context, &ref); } diff --git a/src/tests/asn.1/krb5_encode_test.c b/src/tests/asn.1/krb5_encode_test.c index ef505833b0..8e76d17fd5 100644 --- a/src/tests/asn.1/krb5_encode_test.c +++ b/src/tests/asn.1/krb5_encode_test.c @@ -30,8 +30,6 @@ #include "utility.h" #include "ktest.h" -#include <string.h> - #include "debug.h" extern int current_appl_type; @@ -41,13 +39,10 @@ int error_count = 0; int do_trval = 0; int trval2(); -static void encoder_print_results(code, typestring, description) - krb5_data *code; - char *typestring; - char *description; +static void +encoder_print_results(krb5_data *code, char *typestring, char *description) { char *code_string = NULL; - krb5_error_code retval; int r, rlen; if (do_trval) { @@ -65,12 +60,7 @@ static void encoder_print_results(code, typestring, description) } current_appl_type = -1; /* Reset type */ } else { - retval = asn1_krb5_data_unparse(code,&(code_string)); - if (retval) { - com_err("krb5_encode_test", retval , - "while unparsing %s", typestring); - exit(1); - } + asn1_krb5_data_unparse(code,&(code_string)); printf("encode_krb5_%s%s: %s\n", typestring, description, code_string); free(code_string); @@ -129,13 +119,6 @@ main(argc, argv) } init_access(argv[0]); -#define setup(value,type,typestring,constructor) \ - retval = constructor(&(value)); \ - if (retval) { \ - com_err("krb5_encode_test", retval, "while making sample %s", typestring); \ - exit(1); \ - } - #define encode_run(value,type,typestring,description,encoder) \ retval = encoder(&(value),&(code)); \ if (retval) { \ @@ -148,7 +131,7 @@ main(argc, argv) /* encode_krb5_authenticator */ { krb5_authenticator authent; - setup(authent,authenticator,"authenticator",ktest_make_sample_authenticator); + ktest_make_sample_authenticator(&authent); encode_run(authent,authenticator,"authenticator","",encode_krb5_authenticator); @@ -167,7 +150,7 @@ main(argc, argv) /* encode_krb5_ticket */ { krb5_ticket tkt; - setup(tkt,ticket,"ticket",ktest_make_sample_ticket); + ktest_make_sample_ticket(&tkt); encode_run(tkt,ticket,"ticket","",encode_krb5_ticket); ktest_empty_ticket(&tkt); } @@ -176,7 +159,7 @@ main(argc, argv) /* encode_krb5_encryption_key */ { krb5_keyblock keyblk; - setup(keyblk,keyblock,"keyblock",ktest_make_sample_keyblock); + ktest_make_sample_keyblock(&keyblk); current_appl_type = 1005; encode_run(keyblk,keyblock,"keyblock","",encode_krb5_encryption_key); ktest_empty_keyblock(&keyblk); @@ -187,9 +170,8 @@ main(argc, argv) { krb5_ticket tkt; memset(&tkt, 0, sizeof(krb5_ticket)); - tkt.enc_part2 = (krb5_enc_tkt_part*)calloc(1,sizeof(krb5_enc_tkt_part)); - if (tkt.enc_part2 == NULL) com_err("allocating enc_tkt_part",errno,""); - setup(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part",ktest_make_sample_enc_tkt_part); + tkt.enc_part2 = ealloc(sizeof(krb5_enc_tkt_part)); + ktest_make_sample_enc_tkt_part(tkt.enc_part2); encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","",encode_krb5_enc_tkt_part); @@ -215,10 +197,8 @@ main(argc, argv) memset(&kdcr, 0, sizeof(kdcr)); - kdcr.enc_part2 = (krb5_enc_kdc_rep_part*) - calloc(1,sizeof(krb5_enc_kdc_rep_part)); - if (kdcr.enc_part2 == NULL) com_err("allocating enc_kdc_rep_part",errno,""); - setup(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part); + kdcr.enc_part2 = ealloc(sizeof(krb5_enc_kdc_rep_part)); + ktest_make_sample_enc_kdc_rep_part(kdcr.enc_part2); encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","",encode_krb5_enc_kdc_rep_part); @@ -236,7 +216,7 @@ main(argc, argv) /* encode_krb5_as_rep */ { krb5_kdc_rep kdcr; - setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep); + ktest_make_sample_kdc_rep(&kdcr); /* kdcr.msg_type = KRB5_TGS_REP; test(encode_krb5_as_rep(&kdcr,&code) == KRB5_BADMSGTYPE, @@ -257,7 +237,7 @@ main(argc, argv) /* encode_krb5_tgs_rep */ { krb5_kdc_rep kdcr; - setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep); + ktest_make_sample_kdc_rep(&kdcr); /* kdcr.msg_type = KRB5_AS_REP; test(encode_krb5_tgs_rep(&kdcr,&code) == KRB5_BADMSGTYPE, @@ -277,7 +257,7 @@ main(argc, argv) /* encode_krb5_ap_req */ { krb5_ap_req apreq; - setup(apreq,ap_req,"ap_req",ktest_make_sample_ap_req); + ktest_make_sample_ap_req(&apreq); encode_run(apreq,ap_req,"ap_req","",encode_krb5_ap_req); ktest_empty_ap_req(&apreq); } @@ -286,7 +266,7 @@ main(argc, argv) /* encode_krb5_ap_rep */ { krb5_ap_rep aprep; - setup(aprep,ap_rep,"ap_rep",ktest_make_sample_ap_rep); + ktest_make_sample_ap_rep(&aprep); encode_run(aprep,ap_rep,"ap_rep","",encode_krb5_ap_rep); ktest_empty_ap_rep(&aprep); } @@ -295,7 +275,7 @@ main(argc, argv) /* encode_krb5_ap_rep_enc_part */ { krb5_ap_rep_enc_part apenc; - setup(apenc,ap_rep_enc_part,"ap_rep_enc_part",ktest_make_sample_ap_rep_enc_part); + ktest_make_sample_ap_rep_enc_part(&apenc); encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","",encode_krb5_ap_rep_enc_part); ktest_destroy_keyblock(&(apenc.subkey)); @@ -308,7 +288,7 @@ main(argc, argv) /* encode_krb5_as_req */ { krb5_kdc_req asreq; - setup(asreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req); + ktest_make_sample_kdc_req(&asreq); asreq.msg_type = KRB5_AS_REQ; asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; encode_run(asreq,as_req,"as_req","",encode_krb5_as_req); @@ -337,7 +317,7 @@ main(argc, argv) /* encode_krb5_tgs_req */ { krb5_kdc_req tgsreq; - setup(tgsreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req); + ktest_make_sample_kdc_req(&tgsreq); tgsreq.msg_type = KRB5_TGS_REQ; tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; encode_run(tgsreq,tgs_req,"tgs_req","",encode_krb5_tgs_req); @@ -369,7 +349,7 @@ main(argc, argv) { krb5_kdc_req kdcrb; memset(&kdcrb, 0, sizeof(kdcrb)); - setup(kdcrb,kdc_req_body,"kdc_req_body",ktest_make_sample_kdc_req_body); + ktest_make_sample_kdc_req_body(&kdcrb); kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; current_appl_type = 1007; /* Force interpretation as kdc-req-body */ encode_run(kdcrb,kdc_req_body,"kdc_req_body","",encode_krb5_kdc_req_body); @@ -401,7 +381,7 @@ main(argc, argv) /* encode_krb5_safe */ { krb5_safe s; - setup(s,safe,"safe",ktest_make_sample_safe); + ktest_make_sample_safe(&s); encode_run(s,safe,"safe","",encode_krb5_safe); s.timestamp = 0; @@ -417,7 +397,7 @@ main(argc, argv) /* encode_krb5_priv */ { krb5_priv p; - setup(p,priv,"priv",ktest_make_sample_priv); + ktest_make_sample_priv(&p); encode_run(p,priv,"priv","",encode_krb5_priv); ktest_empty_priv(&p); } @@ -426,7 +406,7 @@ main(argc, argv) /* encode_krb5_enc_priv_part */ { krb5_priv_enc_part ep; - setup(ep,priv_enc_part,"priv_enc_part",ktest_make_sample_priv_enc_part); + ktest_make_sample_priv_enc_part(&ep); encode_run(ep,enc_priv_part,"enc_priv_part","",encode_krb5_enc_priv_part); ep.timestamp = 0; @@ -442,7 +422,7 @@ main(argc, argv) /* encode_krb5_cred */ { krb5_cred c; - setup(c,cred,"cred",ktest_make_sample_cred); + ktest_make_sample_cred(&c); encode_run(c,cred,"cred","",encode_krb5_cred); ktest_empty_cred(&c); } @@ -451,7 +431,7 @@ main(argc, argv) /* encode_krb5_enc_cred_part */ { krb5_cred_enc_part cep; - setup(cep,cred_enc_part,"cred_enc_part",ktest_make_sample_cred_enc_part); + ktest_make_sample_cred_enc_part(&cep); encode_run(cep,enc_cred_part,"enc_cred_part","",encode_krb5_enc_cred_part); ktest_destroy_principal(&(cep.ticket_info[0]->client)); @@ -475,7 +455,7 @@ main(argc, argv) /* encode_krb5_error */ { krb5_error kerr; - setup(kerr,error,"error",ktest_make_sample_error); + ktest_make_sample_error(&kerr); encode_run(kerr,error,"error","",encode_krb5_error); kerr.ctime = 0; @@ -491,7 +471,7 @@ main(argc, argv) /* encode_krb5_authdata */ { krb5_authdata **ad; - setup(ad,authorization_data,"authorization_data",ktest_make_sample_authorization_data); + ktest_make_sample_authorization_data(&ad); retval = encode_krb5_authdata(ad,&(code)); if (retval) { @@ -508,7 +488,7 @@ main(argc, argv) /* encode_pwd_sequence */ { passwd_phrase_element ppe; - setup(ppe,passwd_phrase_element,"PasswdSequence",ktest_make_sample_passwd_phrase_element); + ktest_make_sample_passwd_phrase_element(&ppe); encode_run(ppe,passwd_phrase_element,"pwd_sequence","",encode_krb5_pwd_sequence); ktest_empty_passwd_phrase_element(&ppe); } @@ -517,7 +497,7 @@ main(argc, argv) /* encode_passwd_data */ { krb5_pwd_data pd; - setup(pd,krb5_pwd_data,"PasswdData",ktest_make_sample_krb5_pwd_data); + ktest_make_sample_krb5_pwd_data(&pd); encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data); ktest_empty_pwd_data(&pd); } @@ -527,7 +507,7 @@ main(argc, argv) { krb5_pa_data **pa; - setup(pa,krb5_pa_data,"PreauthData",ktest_make_sample_pa_data_array); + ktest_make_sample_pa_data_array(&pa); retval = encode_krb5_padata_sequence(pa,&(code)); if (retval) { com_err("encoding padata_sequence",retval,""); @@ -543,7 +523,7 @@ main(argc, argv) { krb5_pa_data **pa; - setup(pa,krb5_pa_data,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array); + ktest_make_sample_empty_pa_data_array(&pa); retval = encode_krb5_padata_sequence(pa,&(code)); if (retval) { com_err("encoding padata_sequence(empty)",retval,""); @@ -558,7 +538,7 @@ main(argc, argv) /* encode_alt_method */ { krb5_alt_method am; - setup(am,krb5_alt_method,"AltMethod",ktest_make_sample_alt_method); + ktest_make_sample_alt_method(&am); encode_run(am,krb5_alt_method,"alt_method","",encode_krb5_alt_method); am.length = 0; if (am.data) @@ -574,8 +554,7 @@ main(argc, argv) { krb5_etype_info_entry **info; - setup(info,krb5_etype_info_entry **,"etype_info", - ktest_make_sample_etype_info); + ktest_make_sample_etype_info(&info); retval = encode_krb5_etype_info(info,&(code)); if (retval) { com_err("encoding etype_info",retval,""); @@ -608,8 +587,7 @@ main(argc, argv) { krb5_etype_info_entry **info; - setup(info,krb5_etype_info_entry **,"etype_info2", - ktest_make_sample_etype_info2); + ktest_make_sample_etype_info2(&info); retval = encode_krb5_etype_info2(info,&(code)); if (retval) { com_err("encoding etype_info",retval,""); @@ -635,7 +613,7 @@ main(argc, argv) /* encode_pa_enc_ts */ { krb5_pa_enc_ts pa_enc; - setup(pa_enc,krb5_pa_enc_ts,"pa_enc_ts",ktest_make_sample_pa_enc_ts); + ktest_make_sample_pa_enc_ts(&pa_enc); encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts","",encode_krb5_pa_enc_ts); pa_enc.pausec = 0; encode_run(pa_enc,krb5_pa_enc_ts,"pa_enc_ts (no usec)","",encode_krb5_pa_enc_ts); @@ -645,7 +623,7 @@ main(argc, argv) /* encode_enc_data */ { krb5_enc_data enc_data; - setup(enc_data,krb5_enc_data,"enc_data",ktest_make_sample_enc_data); + ktest_make_sample_enc_data(&enc_data); current_appl_type = 1001; encode_run(enc_data,krb5_enc_data,"enc_data","",encode_krb5_enc_data); ktest_destroy_enc_data(&enc_data); @@ -654,8 +632,7 @@ main(argc, argv) /* encode_krb5_sam_challenge */ { krb5_sam_challenge sam_ch; - setup(sam_ch,krb5_sam_challenge,"sam_challenge", - ktest_make_sample_sam_challenge); + ktest_make_sample_sam_challenge(&sam_ch); encode_run(sam_ch,krb5_sam_challenge,"sam_challenge","", encode_krb5_sam_challenge); ktest_empty_sam_challenge(&sam_ch); @@ -664,8 +641,7 @@ main(argc, argv) /* encode_krb5_sam_response */ { krb5_sam_response sam_ch; - setup(sam_ch,krb5_sam_response,"sam_response", - ktest_make_sample_sam_response); + ktest_make_sample_sam_response(&sam_ch); encode_run(sam_ch,krb5_sam_response,"sam_response","", encode_krb5_sam_response); ktest_empty_sam_response(&sam_ch); @@ -674,8 +650,7 @@ main(argc, argv) /* encode_krb5_sam_key */ { krb5_sam_key sam_ch; - setup(sam_ch,krb5_sam_key,"sam_key", - ktest_make_sample_sam_key); + ktest_make_sample_sam_key(&sam_ch); encode_run(sam_ch,krb5_sam_key,"sam_key","", encode_krb5_sam_key); ktest_empty_sam_key(&sam_ch); @@ -684,8 +659,7 @@ main(argc, argv) /* encode_krb5_enc_sam_response_enc */ { krb5_enc_sam_response_enc sam_ch; - setup(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc", - ktest_make_sample_enc_sam_response_enc); + ktest_make_sample_enc_sam_response_enc(&sam_ch); encode_run(sam_ch,krb5_enc_sam_response_enc,"enc_sam_response_enc","", encode_krb5_enc_sam_response_enc); ktest_empty_enc_sam_response_enc(&sam_ch); @@ -694,8 +668,7 @@ main(argc, argv) /* encode_krb5_predicted_sam_response */ { krb5_predicted_sam_response sam_ch; - setup(sam_ch,krb5_predicted_sam_response,"predicted_sam_response", - ktest_make_sample_predicted_sam_response); + ktest_make_sample_predicted_sam_response(&sam_ch); encode_run(sam_ch,krb5_predicted_sam_response,"predicted_sam_response","", encode_krb5_predicted_sam_response); ktest_empty_predicted_sam_response(&sam_ch); @@ -704,8 +677,7 @@ main(argc, argv) /* encode_krb5_sam_response_2 */ { krb5_sam_response_2 sam_ch2; - setup(sam_ch2,krb5_sam_response_2,"sam_response_2", - ktest_make_sample_sam_response_2); + ktest_make_sample_sam_response_2(&sam_ch2); encode_run(sam_ch2,krb5_sam_response_2,"sam_response_2","", acc.encode_krb5_sam_response_2); ktest_empty_sam_response_2(&sam_ch2); @@ -714,8 +686,7 @@ main(argc, argv) /* encode_krb5_sam_response_enc_2 */ { krb5_enc_sam_response_enc_2 sam_ch2; - setup(sam_ch2,krb5_enc_sam_response_enc_2,"enc_sam_response_enc_2", - ktest_make_sample_enc_sam_response_enc_2); + ktest_make_sample_enc_sam_response_enc_2(&sam_ch2); encode_run(sam_ch2,krb5_enc_sam_response_enc_2, "enc_sam_response_enc_2","", acc.encode_krb5_enc_sam_response_enc_2); @@ -725,8 +696,7 @@ main(argc, argv) /* encode_krb5_pa_s4u_x509_user */ { krb5_pa_s4u_x509_user s4u; - setup(s4u,krb5_pa_s4u_x509_user,"pa_s4u_x509_user", - ktest_make_sample_pa_s4u_x509_user); + ktest_make_sample_pa_s4u_x509_user(&s4u); encode_run(s4u,krb5_pa_s4u_x509_user, "pa_s4u_x509_user","", encode_krb5_pa_s4u_x509_user); @@ -736,8 +706,7 @@ main(argc, argv) /* encode_krb5_ad_kdcissued */ { krb5_ad_kdcissued kdci; - setup(kdci,krb5_ad_kdcissued,"ad_kdcissued", - ktest_make_sample_ad_kdcissued); + ktest_make_sample_ad_kdcissued(&kdci); encode_run(kdci,krb5_ad_kdcissued, "ad_kdcissued","", encode_krb5_ad_kdcissued); @@ -747,8 +716,7 @@ main(argc, argv) /* encode_krb5_ad_signedpath_data */ { krb5_ad_signedpath_data spd; - setup(spd,krb5_ad_signedpath_data,"ad_signedpath_data", - ktest_make_sample_ad_signedpath_data); + ktest_make_sample_ad_signedpath_data(&spd); encode_run(spd,krb5_ad_signedpath_data, "ad_signedpath_data","", encode_krb5_ad_signedpath_data); @@ -758,8 +726,7 @@ main(argc, argv) /* encode_krb5_ad_signedpath */ { krb5_ad_signedpath sp; - setup(sp,krb5_ad_signedpath,"ad_signedpath", - ktest_make_sample_ad_signedpath); + ktest_make_sample_ad_signedpath(&sp); encode_run(sp,krb5_ad_signedpath, "ad_signedpath","", encode_krb5_ad_signedpath); @@ -769,8 +736,7 @@ main(argc, argv) /* encode_krb5_iakerb_header */ { krb5_iakerb_header ih; - setup(ih,krb5_ad_signedpath,"iakerb_header", - ktest_make_sample_iakerb_header); + ktest_make_sample_iakerb_header(&ih); encode_run(ih,krb5_iakerb_header, "iakerb_header","", encode_krb5_iakerb_header); @@ -780,8 +746,7 @@ main(argc, argv) /* encode_krb5_iakerb_finished */ { krb5_iakerb_finished ih; - setup(ih,krb5_ad_signedpath,"iakerb_finished", - ktest_make_sample_iakerb_finished); + ktest_make_sample_iakerb_finished(&ih); encode_run(ih,krb5_iakerb_finished, "iakerb_finished","", encode_krb5_iakerb_finished); @@ -791,8 +756,7 @@ main(argc, argv) { ldap_seqof_key_data skd; - setup(skd, ldap_seqof_key_data, "ldap_seqof_key_data", - ktest_make_sample_ldap_seqof_key_data); + ktest_make_sample_ldap_seqof_key_data(&skd); encode_run(skd, ldap_seqof_key_data, "ldap_seqof_key_data", "", acc.asn1_ldap_encode_sequence_of_keys); ktest_empty_ldap_seqof_key_data(test_context, &skd); diff --git a/src/tests/asn.1/ktest.c b/src/tests/asn.1/ktest.c index 90a7c1c4d9..1580e22775 100644 --- a/src/tests/asn.1/ktest.c +++ b/src/tests/asn.1/ktest.c @@ -30,207 +30,144 @@ char *sample_principal_name = "hftsai/extra@ATHENA.MIT.EDU"; -krb5_error_code ktest_make_sample_authenticator(a) - krb5_authenticator * a; +void +ktest_make_sample_authenticator(krb5_authenticator *a) { - krb5_error_code retval; - - retval = ktest_make_sample_principal(&(a->client)); - if (retval) return retval; - a->checksum = (krb5_checksum*)calloc(1,sizeof(krb5_checksum)); - if (a->checksum == NULL) return ENOMEM; - retval = ktest_make_sample_checksum(a->checksum); - if (retval) return retval; + ktest_make_sample_principal(&a->client); + a->checksum = ealloc(sizeof(krb5_checksum)); + ktest_make_sample_checksum(a->checksum); a->cusec = SAMPLE_USEC; a->ctime = SAMPLE_TIME; - a->subkey = (krb5_keyblock*)calloc(1,sizeof(krb5_keyblock)); - if (a->subkey == NULL) return ENOMEM; - retval = ktest_make_sample_keyblock(a->subkey); - if (retval) return retval; + a->subkey = ealloc(sizeof(krb5_keyblock)); + ktest_make_sample_keyblock(a->subkey); a->seq_number = SAMPLE_SEQ_NUMBER; - retval = ktest_make_sample_authorization_data(&(a->authorization_data)); - if (retval) return retval; - - return 0; + ktest_make_sample_authorization_data(&a->authorization_data); } -krb5_error_code ktest_make_sample_principal(p) - krb5_principal * p; +void +ktest_make_sample_principal(krb5_principal *p) { - krb5_error_code retval; - - retval = krb5_parse_name(test_context, sample_principal_name, p); - return retval; + if (krb5_parse_name(test_context, sample_principal_name, p)) + abort(); } -krb5_error_code ktest_make_sample_checksum(cs) - krb5_checksum * cs; +void +ktest_make_sample_checksum(krb5_checksum *cs) { cs->checksum_type = 1; cs->length = 4; - cs->contents = (krb5_octet*)calloc(4,sizeof(krb5_octet)); - if (cs->contents == NULL) return ENOMEM; + cs->contents = ealloc(4); memcpy(cs->contents,"1234",4); - - return 0; } -krb5_error_code ktest_make_sample_keyblock(kb) - krb5_keyblock * kb; +void +ktest_make_sample_keyblock(krb5_keyblock *kb) { kb->magic = KV5M_KEYBLOCK; kb->enctype = 1; kb->length = 8; - kb->contents = (krb5_octet*)calloc(8,sizeof(krb5_octet)); - if (kb->contents == NULL) return ENOMEM; + kb->contents = ealloc(8); memcpy(kb->contents,"12345678",8); - - return 0; } -krb5_error_code ktest_make_sample_ticket(tkt) - krb5_ticket * tkt; +void +ktest_make_sample_ticket(krb5_ticket *tkt) { - krb5_error_code retval; - - retval = ktest_make_sample_principal(&(tkt->server)); - if (retval) return retval; - retval = ktest_make_sample_enc_data(&(tkt->enc_part)); - if (retval) return retval; + ktest_make_sample_principal(&tkt->server); + ktest_make_sample_enc_data(&tkt->enc_part); tkt->enc_part2 = NULL; - - return 0; } -krb5_error_code ktest_make_sample_enc_data(ed) - krb5_enc_data * ed; +void +ktest_make_sample_enc_data(krb5_enc_data *ed) { - krb5_error_code retval; - ed->kvno = 5; ed->enctype = 0; - retval = krb5_data_parse(&(ed->ciphertext),"krbASN.1 test message"); - if (retval) return retval; - - return 0; + krb5_data_parse(&ed->ciphertext, "krbASN.1 test message"); } -krb5_error_code ktest_make_sample_enc_tkt_part(etp) - krb5_enc_tkt_part * etp; +void +ktest_make_sample_enc_tkt_part(krb5_enc_tkt_part *etp) { - krb5_error_code retval; - etp->flags = SAMPLE_FLAGS; - etp->session = (krb5_keyblock*)calloc(1,sizeof(krb5_keyblock)); - if (etp->session == NULL) return ENOMEM; - retval = ktest_make_sample_keyblock(etp->session); - if (retval) return retval; - retval = ktest_make_sample_principal(&(etp->client)); - if (retval) return retval; - retval = ktest_make_sample_transited(&(etp->transited)); - if (retval) return retval; - retval = ktest_make_sample_ticket_times(&(etp->times)); - if (retval) return retval; - retval = ktest_make_sample_addresses(&(etp->caddrs)); - if (retval) return retval; - retval = ktest_make_sample_authorization_data(&(etp->authorization_data)); - if (retval) return retval; - return 0; -} - -krb5_error_code ktest_make_sample_addresses(caddrs) - krb5_address *** caddrs; -{ - asn1_error_code retval; + etp->session = ealloc(sizeof(krb5_keyblock)); + ktest_make_sample_keyblock(etp->session); + ktest_make_sample_principal(&etp->client); + ktest_make_sample_transited(&etp->transited); + ktest_make_sample_ticket_times(&etp->times); + ktest_make_sample_addresses(&etp->caddrs); + ktest_make_sample_authorization_data(&etp->authorization_data); +} + +void +ktest_make_sample_addresses(krb5_address ***caddrs) +{ int i; - *caddrs = (krb5_address**)calloc(3,sizeof(krb5_address*)); - if (*caddrs == NULL) return ENOMEM; - for (i=0; i<2; i++) { - (*caddrs)[i] = (krb5_address*)calloc(1,sizeof(krb5_address)); - if ((*caddrs)[i] == NULL) return ENOMEM; - retval = ktest_make_sample_address((*caddrs)[i]); - if (retval) return retval; + *caddrs = ealloc(3 * sizeof(krb5_address *)); + for (i = 0; i < 2; i++) { + (*caddrs)[i] = ealloc(sizeof(krb5_address)); + ktest_make_sample_address((*caddrs)[i]); } (*caddrs)[2] = NULL; - return 0; } -krb5_error_code ktest_make_sample_authorization_data(ad) - krb5_authdata *** ad; +void +ktest_make_sample_authorization_data(krb5_authdata ***ad) { - krb5_error_code retval; int i; - *ad = (krb5_authdata**)calloc(3,sizeof(krb5_authdata*)); - if (*ad == NULL) return ENOMEM; - - for (i=0; i<=1; i++) { - (*ad)[i] = (krb5_authdata*)calloc(1,sizeof(krb5_authdata)); - if ((*ad)[i] == NULL) return ENOMEM; - retval = ktest_make_sample_authdata((*ad)[i]); - if (retval) return retval; + *ad = ealloc(3 * sizeof(krb5_authdata *)); + for (i = 0; i <= 1; i++) { + (*ad)[i] = ealloc(sizeof(krb5_authdata)); + ktest_make_sample_authdata((*ad)[i]); } (*ad)[2] = NULL; - - return 0; } -krb5_error_code ktest_make_sample_transited(t) - krb5_transited * t; +void +ktest_make_sample_transited(krb5_transited *t) { t->tr_type = 1; - return krb5_data_parse(&(t->tr_contents), - "EDU,MIT.,ATHENA.,WASHINGTON.EDU,CS."); + krb5_data_parse(&t->tr_contents, "EDU,MIT.,ATHENA.,WASHINGTON.EDU,CS."); } -krb5_error_code ktest_make_sample_ticket_times(tt) - krb5_ticket_times * tt; +void +ktest_make_sample_ticket_times(krb5_ticket_times *tt) { tt->authtime = SAMPLE_TIME; tt->starttime = SAMPLE_TIME; tt->endtime = SAMPLE_TIME; tt->renew_till = SAMPLE_TIME; - return 0; } -krb5_error_code ktest_make_sample_address(a) - krb5_address * a; +void +ktest_make_sample_address(krb5_address *a) { a->addrtype = ADDRTYPE_INET; a->length = 4; - a->contents = (krb5_octet*)calloc(4,sizeof(krb5_octet)); - if (a->contents == NULL) return ENOMEM; + a->contents = ealloc(4 * sizeof(krb5_octet)); a->contents[0] = 18; a->contents[1] = 208; a->contents[2] = 0; a->contents[3] = 35; - - return 0; } -krb5_error_code ktest_make_sample_authdata(ad) - krb5_authdata * ad; +void +ktest_make_sample_authdata(krb5_authdata *ad) { ad->ad_type = 1; ad->length = 6; - ad->contents = (krb5_octet*)calloc(6,sizeof(krb5_octet)); - if (ad->contents == NULL) return ENOMEM; - memcpy(ad->contents,"foobar",6); - return 0; + ad->contents = ealloc(6 * sizeof(krb5_octet)); + memcpy(ad->contents, "foobar", 6); } -krb5_error_code ktest_make_sample_enc_kdc_rep_part(ekr) - krb5_enc_kdc_rep_part * ekr; +void +ktest_make_sample_enc_kdc_rep_part(krb5_enc_kdc_rep_part *ekr) { - krb5_error_code retval; - - ekr->session = (krb5_keyblock*)calloc(1,sizeof(krb5_keyblock)); - if (ekr->session == NULL) return ENOMEM; - retval = ktest_make_sample_keyblock(ekr->session); - if (retval) return retval; - retval = ktest_make_sample_last_req(&(ekr->last_req)); - if (retval) return retval; + ekr->session = ealloc(sizeof(krb5_keyblock)); + ktest_make_sample_keyblock(ekr->session); + ktest_make_sample_last_req(&ekr->last_req); ekr->nonce = SAMPLE_NONCE; ekr->key_exp = SAMPLE_TIME; ekr->flags = SAMPLE_FLAGS; @@ -238,180 +175,122 @@ krb5_error_code ktest_make_sample_enc_kdc_rep_part(ekr) ekr->times.starttime = SAMPLE_TIME; ekr->times.endtime = SAMPLE_TIME; ekr->times.renew_till = SAMPLE_TIME; - retval = ktest_make_sample_principal(&(ekr->server)); - if (retval) return retval; - retval = ktest_make_sample_addresses(&(ekr->caddrs)); - if (retval) return retval; - - return 0; + ktest_make_sample_principal(&ekr->server); + ktest_make_sample_addresses(&ekr->caddrs); } -krb5_error_code ktest_make_sample_last_req(lr) - krb5_last_req_entry *** lr; +void +ktest_make_sample_last_req(krb5_last_req_entry ***lr) { - krb5_error_code retval; int i; - *lr = (krb5_last_req_entry**)calloc(3,sizeof(krb5_last_req_entry*)); - if (*lr == NULL) return ENOMEM; - for (i=0; i<=1; i++) { - retval = ktest_make_sample_last_req_entry(&((*lr)[i])); - if (retval) return retval; - } + *lr = ealloc(3 * sizeof(krb5_last_req_entry *)); + for (i = 0; i <= 1; i++) + ktest_make_sample_last_req_entry(&(*lr)[i]); (*lr)[2] = NULL; - return 0; } -krb5_error_code ktest_make_sample_last_req_entry(lre) - krb5_last_req_entry ** lre; +void +ktest_make_sample_last_req_entry(krb5_last_req_entry **lre) { - *lre = (krb5_last_req_entry*)calloc(1,sizeof(krb5_last_req_entry)); - if (*lre == NULL) return ENOMEM; + *lre = ealloc(sizeof(krb5_last_req_entry)); (*lre)->lr_type = -5; (*lre)->value = SAMPLE_TIME; - return 0; } -krb5_error_code ktest_make_sample_kdc_rep(kdcr) - krb5_kdc_rep * kdcr; +void +ktest_make_sample_kdc_rep(krb5_kdc_rep *kdcr) { - krb5_error_code retval; - - retval = ktest_make_sample_pa_data_array(&(kdcr->padata)); - if (retval) return retval; - retval = ktest_make_sample_principal(&(kdcr->client)); - if (retval) return retval; - kdcr->ticket = (krb5_ticket*)calloc(1,sizeof(krb5_ticket)); - if (kdcr->ticket == NULL) return ENOMEM; - retval = ktest_make_sample_ticket(kdcr->ticket); - if (retval) return retval; - retval = ktest_make_sample_enc_data(&(kdcr->enc_part)); - if (retval) return retval; + ktest_make_sample_pa_data_array(&kdcr->padata); + ktest_make_sample_principal(&kdcr->client); + kdcr->ticket = ealloc(sizeof(krb5_ticket)); + ktest_make_sample_ticket(kdcr->ticket); + ktest_make_sample_enc_data(&kdcr->enc_part); kdcr->enc_part2 = NULL; - - return 0; } -krb5_error_code ktest_make_sample_pa_data_array(pad) - krb5_pa_data *** pad; +void +ktest_make_sample_pa_data_array(krb5_pa_data ***pad) { - krb5_error_code retval; int i; - *pad = (krb5_pa_data**)calloc(3,sizeof(krb5_pa_data*)); - if (*pad == NULL) return ENOMEM; - - for (i=0; i<=1; i++) { - (*pad)[i] = (krb5_pa_data*)calloc(1,sizeof(krb5_pa_data)); - if ((*pad)[i] == NULL) return ENOMEM; - retval = ktest_make_sample_pa_data((*pad)[i]); - if (retval) return retval; + *pad = ealloc(3 * sizeof(krb5_pa_data *)); + for (i = 0; i <= 1; i++) { + (*pad)[i] = ealloc(sizeof(krb5_pa_data)); + ktest_make_sample_pa_data((*pad)[i]); } (*pad)[2] = NULL; - - return 0; } -krb5_error_code ktest_make_sample_empty_pa_data_array(pad) - krb5_pa_data *** pad; +void +ktest_make_sample_empty_pa_data_array(krb5_pa_data ***pad) { - *pad = (krb5_pa_data**)calloc(1,sizeof(krb5_pa_data*)); - if (*pad == NULL) return ENOMEM; - + *pad = ealloc(sizeof(krb5_pa_data *)); (*pad)[0] = NULL; - - return 0; } -krb5_error_code ktest_make_sample_pa_data(pad) - krb5_pa_data * pad; +void +ktest_make_sample_pa_data(krb5_pa_data *pad) { pad->pa_type = 13; pad->length = 7; - pad->contents = (krb5_octet*)calloc(7,sizeof(krb5_octet)); - if (pad->contents == NULL) return ENOMEM; - memcpy(pad->contents,"pa-data",7); - return 0; + pad->contents = ealloc(7); + memcpy(pad->contents, "pa-data", 7); } -krb5_error_code ktest_make_sample_ap_req(ar) - krb5_ap_req * ar; +void +ktest_make_sample_ap_req(krb5_ap_req *ar) { - krb5_error_code retval; ar->ap_options = SAMPLE_FLAGS; - ar->ticket = (krb5_ticket*)calloc(1,sizeof(krb5_ticket)); - if (ar->ticket == NULL) return ENOMEM; - retval = ktest_make_sample_ticket(ar->ticket); - if (retval) return retval; - retval = ktest_make_sample_enc_data(&(ar->authenticator)); - if (retval) return retval; - return 0; + ar->ticket = ealloc(sizeof(krb5_ticket)); + ktest_make_sample_ticket(ar->ticket); + ktest_make_sample_enc_data(&(ar->authenticator)); } -krb5_error_code ktest_make_sample_ap_rep(ar) - krb5_ap_rep * ar; +void +ktest_make_sample_ap_rep(krb5_ap_rep *ar) { - return ktest_make_sample_enc_data(&(ar->enc_part)); + ktest_make_sample_enc_data(&ar->enc_part); } -krb5_error_code ktest_make_sample_ap_rep_enc_part(arep) - krb5_ap_rep_enc_part * arep; +void +ktest_make_sample_ap_rep_enc_part(krb5_ap_rep_enc_part *arep) { - krb5_error_code retval; - arep->ctime = SAMPLE_TIME; arep->cusec = SAMPLE_USEC; - arep->subkey = (krb5_keyblock*)calloc(1,sizeof(krb5_keyblock)); - if (arep->subkey == NULL) return ENOMEM; - retval = ktest_make_sample_keyblock(arep->subkey); - if (retval) return retval; + arep->subkey = ealloc(sizeof(krb5_keyblock)); + ktest_make_sample_keyblock(arep->subkey); arep->seq_number = SAMPLE_SEQ_NUMBER; - - return 0; } -krb5_error_code ktest_make_sample_kdc_req(kr) - krb5_kdc_req * kr; +void +ktest_make_sample_kdc_req(krb5_kdc_req *kr) { - krb5_error_code retval; - /* msg_type is left up to the calling procedure */ - retval = ktest_make_sample_pa_data_array(&(kr->padata)); - if (retval) return retval; + ktest_make_sample_pa_data_array(&kr->padata); kr->kdc_options = SAMPLE_FLAGS; - retval = ktest_make_sample_principal(&(kr->client)); - if (retval) return retval; - retval = ktest_make_sample_principal(&(kr->server)); - if (retval) return retval; + ktest_make_sample_principal(&(kr->client)); + ktest_make_sample_principal(&(kr->server)); kr->from = SAMPLE_TIME; kr->till = SAMPLE_TIME; kr->rtime = SAMPLE_TIME; kr->nonce = SAMPLE_NONCE; kr->nktypes = 2; - kr->ktype = (krb5_enctype*)calloc(2,sizeof(krb5_enctype)); + kr->ktype = ealloc(2 * sizeof(krb5_enctype)); kr->ktype[0] = 0; kr->ktype[1] = 1; - retval = ktest_make_sample_addresses(&(kr->addresses)); - if (retval) return retval; - retval = ktest_make_sample_enc_data(&(kr->authorization_data)); - if (retval) return retval; - retval = ktest_make_sample_authorization_data(&(kr->unenc_authdata)); - if (retval) return retval; - retval = ktest_make_sample_sequence_of_ticket(&(kr->second_ticket)); - if (retval) return retval; - return 0; + ktest_make_sample_addresses(&kr->addresses); + ktest_make_sample_enc_data(&kr->authorization_data); + ktest_make_sample_authorization_data(&kr->unenc_authdata); + ktest_make_sample_sequence_of_ticket(&kr->second_ticket); } -krb5_error_code ktest_make_sample_kdc_req_body(krb) - krb5_kdc_req * krb; +void +ktest_make_sample_kdc_req_body(krb5_kdc_req *krb) { - krb5_error_code retval; - krb->kdc_options = SAMPLE_FLAGS; - retval = ktest_make_sample_principal(&(krb->client)); - if (retval) return retval; - retval = ktest_make_sample_principal(&(krb->server)); - if (retval) return retval; + ktest_make_sample_principal(&krb->client); + ktest_make_sample_principal(&krb->server); krb->from = SAMPLE_TIME; krb->till = SAMPLE_TIME; krb->rtime = SAMPLE_TIME; @@ -420,266 +299,173 @@ krb5_error_code ktest_make_sample_kdc_req_body(krb) krb->ktype = (krb5_enctype*)calloc(2,sizeof(krb5_enctype)); krb->ktype[0] = 0; krb->ktype[1] = 1; - retval = ktest_make_sample_addresses(&(krb->addresses)); - if (retval) return retval; - retval = ktest_make_sample_enc_data(&(krb->authorization_data)); - if (retval) return retval; - retval = ktest_make_sample_authorization_data(&(krb->unenc_authdata)); - if (retval) return retval; - retval = ktest_make_sample_sequence_of_ticket(&(krb->second_ticket)); - if (retval) return retval; - return 0; + ktest_make_sample_addresses(&krb->addresses); + ktest_make_sample_enc_data(&krb->authorization_data); + ktest_make_sample_authorization_data(&krb->unenc_authdata); + ktest_make_sample_sequence_of_ticket(&krb->second_ticket); } -krb5_error_code ktest_make_sample_safe(s) - krb5_safe * s; +void +ktest_make_sample_safe(krb5_safe *s) { - krb5_error_code retval; - - retval = ktest_make_sample_data(&(s->user_data)); - if (retval) return retval; + ktest_make_sample_data(&s->user_data); s->timestamp = SAMPLE_TIME; s->usec = SAMPLE_USEC; s->seq_number = SAMPLE_SEQ_NUMBER; - s->s_address = (krb5_address*)calloc(1,sizeof(krb5_address)); - if (s->s_address == NULL) return ENOMEM; - retval = ktest_make_sample_address(s->s_address); - if (retval) return retval; - s->r_address = (krb5_address*)calloc(1,sizeof(krb5_address)); - if (s->r_address == NULL) return ENOMEM; - retval = ktest_make_sample_address(s->r_address); - if (retval) return retval; - s->checksum = (krb5_checksum*)calloc(1,sizeof(krb5_checksum)); - if (s->checksum == NULL) return ENOMEM; - retval = ktest_make_sample_checksum(s->checksum); - if (retval) return retval; - - return 0; + s->s_address = ealloc(sizeof(krb5_address)); + ktest_make_sample_address(s->s_address); + s->r_address = ealloc(sizeof(krb5_address)); + ktest_make_sample_address(s->r_address); + s->checksum = ealloc(sizeof(krb5_checksum)); + ktest_make_sample_checksum(s->checksum); } -krb5_error_code ktest_make_sample_priv(p) - krb5_priv * p; +void +ktest_make_sample_priv(krb5_priv *p) { - return ktest_make_sample_enc_data(&(p->enc_part)); + ktest_make_sample_enc_data(&p->enc_part); } -krb5_error_code ktest_make_sample_priv_enc_part(pep) - krb5_priv_enc_part * pep; +void +ktest_make_sample_priv_enc_part(krb5_priv_enc_part *pep) { - krb5_error_code retval; - retval = ktest_make_sample_data(&(pep->user_data)); - if (retval) return retval; + ktest_make_sample_data(&(pep->user_data)); pep->timestamp = SAMPLE_TIME; pep->usec = SAMPLE_USEC; pep->seq_number = SAMPLE_SEQ_NUMBER; - pep->s_address = (krb5_address*)calloc(1,sizeof(krb5_address)); - if (pep->s_address == NULL) return ENOMEM; - retval = ktest_make_sample_address(pep->s_address); - if (retval) return retval; - pep->r_address = (krb5_address*)calloc(1,sizeof(krb5_address)); - if (pep->r_address == NULL) return ENOMEM; - retval = ktest_make_sample_address(pep->r_address); - if (retval) return retval; - return 0; + pep->s_address = ealloc(sizeof(krb5_address)); + ktest_make_sample_address(pep->s_address); + pep->r_address = ealloc(sizeof(krb5_address)); + ktest_make_sample_address(pep->r_address); } -krb5_error_code ktest_make_sample_cred(c) - krb5_cred * c; +void +ktest_make_sample_cred(krb5_cred *c) { - krb5_error_code retval; - retval = ktest_make_sample_sequence_of_ticket(&(c->tickets)); - if (retval) return retval; - retval = ktest_make_sample_enc_data(&(c->enc_part)); - if (retval) return retval; - return 0; + ktest_make_sample_sequence_of_ticket(&c->tickets); + ktest_make_sample_enc_data(&c->enc_part); } -krb5_error_code ktest_make_sample_sequence_of_ticket(sot) - krb5_ticket *** sot; +void +ktest_make_sample_sequence_of_ticket(krb5_ticket ***sot) { - krb5_error_code retval; int i; - *sot = (krb5_ticket**)calloc(3,sizeof(krb5_ticket*)); - if (*sot == NULL) return ENOMEM; - for (i=0; i<2; i++) { - (*sot)[i] = (krb5_ticket*)calloc(1,sizeof(krb5_ticket)); - if ((*sot)[i] == NULL) return ENOMEM; - retval = ktest_make_sample_ticket((*sot)[i]); - if (retval) return retval; + *sot = ealloc(3 * sizeof(krb5_ticket *)); + for (i = 0; i < 2; i++) { + (*sot)[i] = ealloc(sizeof(krb5_ticket)); + ktest_make_sample_ticket((*sot)[i]); } (*sot)[2] = NULL; - - return 0; } -krb5_error_code ktest_make_sample_cred_enc_part(cep) - krb5_cred_enc_part * cep; +void +ktest_make_sample_cred_enc_part(krb5_cred_enc_part *cep) { - krb5_error_code retval; - cep->nonce = SAMPLE_NONCE; cep->timestamp = SAMPLE_TIME; cep->usec = SAMPLE_USEC; - cep->s_address = (krb5_address*)calloc(1,sizeof(krb5_address)); - if (cep->s_address == NULL) return ENOMEM; - retval = ktest_make_sample_address(cep->s_address); - if (retval) return retval; - cep->r_address = (krb5_address*)calloc(1,sizeof(krb5_address)); - if (cep->r_address == NULL) return ENOMEM; - retval = ktest_make_sample_address(cep->r_address); - if (retval) return retval; - retval = ktest_make_sequence_of_cred_info(&(cep->ticket_info)); - if (retval) return retval; - - return 0; + cep->s_address = ealloc(sizeof(krb5_address)); + ktest_make_sample_address(cep->s_address); + cep->r_address = ealloc(sizeof(krb5_address)); + ktest_make_sample_address(cep->r_address); + ktest_make_sequence_of_cred_info(&cep->ticket_info); } -krb5_error_code ktest_make_sequence_of_cred_info(soci) - krb5_cred_info *** soci; +void +ktest_make_sequence_of_cred_info(krb5_cred_info ***soci) { - krb5_error_code retval; int i; - *soci = (krb5_cred_info**)calloc(3,sizeof(krb5_cred_info*)); - if (*soci == NULL) return ENOMEM; - for (i=0; i<2; i++) { - (*soci)[i] = (krb5_cred_info*)calloc(1,sizeof(krb5_cred_info)); - if ((*soci)[i] == NULL) return ENOMEM; - retval = ktest_make_sample_cred_info((*soci)[i]); - if (retval) return retval; + *soci = ealloc(3 * sizeof(krb5_cred_info *)); + for (i = 0; i < 2; i++) { + (*soci)[i] = ealloc(sizeof(krb5_cred_info)); + ktest_make_sample_cred_info((*soci)[i]); } (*soci)[2] = NULL; - - return 0; } -krb5_error_code ktest_make_sample_cred_info(ci) - krb5_cred_info * ci; +void +ktest_make_sample_cred_info(krb5_cred_info *ci) { - krb5_error_code retval; - - ci->session = (krb5_keyblock*)calloc(1,sizeof(krb5_keyblock)); - if (ci->session == NULL) return ENOMEM; - retval = ktest_make_sample_keyblock(ci->session); - if (retval) return retval; - retval = ktest_make_sample_principal(&(ci->client)); - if (retval) return retval; - retval = ktest_make_sample_principal(&(ci->server)); - if (retval) return retval; + ci->session = ealloc(sizeof(krb5_keyblock)); + ktest_make_sample_keyblock(ci->session); + ktest_make_sample_principal(&ci->client); + ktest_make_sample_principal(&ci->server); ci->flags = SAMPLE_FLAGS; ci->times.authtime = SAMPLE_TIME; ci->times.starttime = SAMPLE_TIME; ci->times.endtime = SAMPLE_TIME; ci->times.renew_till = SAMPLE_TIME; - retval = ktest_make_sample_addresses(&(ci->caddrs)); - if (retval) return retval; - - return 0; + ktest_make_sample_addresses(&ci->caddrs); } -krb5_error_code ktest_make_sample_error(kerr) - krb5_error * kerr; +void +ktest_make_sample_error(krb5_error *kerr) { - krb5_error_code retval; - kerr->ctime = SAMPLE_TIME; kerr->cusec = SAMPLE_USEC; kerr->susec = SAMPLE_USEC; kerr->stime = SAMPLE_TIME; kerr->error = SAMPLE_ERROR; - retval = ktest_make_sample_principal(&(kerr->client)); - if (retval) return retval; - retval = ktest_make_sample_principal(&(kerr->server)); - if (retval) return retval; - retval = ktest_make_sample_data(&(kerr->text)); - if (retval) return retval; - retval = ktest_make_sample_data(&(kerr->e_data)); - if (retval) return retval; - - return 0; + ktest_make_sample_principal(&kerr->client); + ktest_make_sample_principal(&kerr->server); + ktest_make_sample_data(&kerr->text); + ktest_make_sample_data(&kerr->e_data); } -krb5_error_code ktest_make_sample_data(d) - krb5_data * d; +void +ktest_make_sample_data(krb5_data *d) { - d->data = (char*)calloc(8,sizeof(char)); - if (d->data == NULL) return ENOMEM; - d->length = 8; - memcpy(d->data,"krb5data",8); - - return 0; + krb5_data_parse(d, "krb5data"); } -krb5_error_code ktest_make_sample_passwd_phrase_element(ppe) - passwd_phrase_element * ppe; +void +ktest_make_sample_passwd_phrase_element(passwd_phrase_element *ppe) { - krb5_error_code retval; - - ppe->passwd = (krb5_data*)calloc(1,sizeof(krb5_data)); - if (ppe->passwd == NULL) return ENOMEM; - retval = ktest_make_sample_data(ppe->passwd); - if (retval) return retval; - ppe->phrase = (krb5_data*)calloc(1,sizeof(krb5_data)); - if (ppe->phrase == NULL) return ENOMEM; - retval = ktest_make_sample_data(ppe->phrase); - if (retval) return retval; - return 0; + ppe->passwd = ealloc(sizeof(krb5_data)); + ktest_make_sample_data(ppe->passwd); + ppe->phrase = ealloc(sizeof(krb5_data)); + ktest_make_sample_data(ppe->phrase); } -krb5_error_code ktest_make_sample_krb5_pwd_data(pd) - krb5_pwd_data * pd; +void +ktest_make_sample_krb5_pwd_data(krb5_pwd_data *pd) { - krb5_error_code retval; int i; pd->sequence_count = 2; - - pd->element = (passwd_phrase_element**)calloc(3,sizeof(passwd_phrase_element*)); - if (pd->element == NULL) return ENOMEM; - - for (i=0; i<=1; i++) { - pd->element[i] = (passwd_phrase_element*)calloc(1,sizeof(passwd_phrase_element)); - if (pd->element[i] == NULL) return ENOMEM; - retval = ktest_make_sample_passwd_phrase_element(pd->element[i]); - if (retval) return retval; + pd->element = ealloc(3 * sizeof(passwd_phrase_element *)); + for (i = 0; i <= 1; i++) { + pd->element[i] = ealloc(sizeof(passwd_phrase_element)); + ktest_make_sample_passwd_phrase_element(pd->element[i]); } pd->element[2] = NULL; - - return 0; } -krb5_error_code ktest_make_sample_alt_method(p) - krb5_alt_method * p; +void +ktest_make_sample_alt_method(krb5_alt_method *p) { p->method = 42; - p->data = (krb5_octet *) strdup("secret"); - if (p->data == NULL) return ENOMEM; - p->length = strlen((char *) p->data); - return 0; + p->data = (unsigned char *)estrdup("secret"); + p->length = strlen((char *)p->data); } -krb5_error_code ktest_make_sample_etype_info(p) - krb5_etype_info_entry *** p; +void +ktest_make_sample_etype_info(krb5_etype_info_entry ***p) { krb5_etype_info_entry **info; int i, len; char *str; - info = malloc(sizeof(krb5_etype_info_entry *) * 4); - if (!info) - return ENOMEM; - memset(info, 0, sizeof(krb5_etype_info_entry *) * 4); - - for (i=0; i < 3; i++) { - info[i] = malloc(sizeof(krb5_etype_info_entry)); - if (info[i] == 0) - goto memfail; + info = ealloc(4 * sizeof(krb5_etype_info_entry *)); + for (i = 0; i < 3; i++) { + info[i] = ealloc(sizeof(krb5_etype_info_entry)); info[i]->etype = i; len = asprintf(&str, "Morton's #%d", i); if (len < 0) - goto memfail; - info[i]->salt = (krb5_octet *) str; + abort(); + info[i]->salt = (krb5_octet *)str; info[i]->length = len; info[i]->s2kparams.data = NULL; info[i]->s2kparams.length = 0; @@ -689,38 +475,28 @@ krb5_error_code ktest_make_sample_etype_info(p) info[1]->length = KRB5_ETYPE_NO_SALT; info[1]->salt = 0; *p = info; - return 0; -memfail: - ktest_destroy_etype_info(info); - return ENOMEM; } -krb5_error_code ktest_make_sample_etype_info2(p) - krb5_etype_info_entry *** p; +void +ktest_make_sample_etype_info2(krb5_etype_info_entry ***p) { krb5_etype_info_entry **info; int i, len; char *str; - info = malloc(sizeof(krb5_etype_info_entry *) * 4); - if (!info) - return ENOMEM; - memset(info, 0, sizeof(krb5_etype_info_entry *) * 4); - - for (i=0; i < 3; i++) { - info[i] = malloc(sizeof(krb5_etype_info_entry)); - if (info[i] == 0) - goto memfail; + info = ealloc(4 * sizeof(krb5_etype_info_entry *)); + for (i = 0; i < 3; i++) { + info[i] = ealloc(sizeof(krb5_etype_info_entry)); info[i]->etype = i; len = asprintf(&str, "Morton's #%d", i); if (len < 0) - goto memfail; - info[i]->salt = (krb5_octet *) str; - info[i]->length = (unsigned int) len; + abort(); + info[i]->salt = (krb5_octet *)str; + info[i]->length = (unsigned int)len; len = asprintf(&info[i]->s2kparams.data, "s2k: %d", i); if (len < 0) - goto memfail; + abort(); info[i]->s2kparams.length = (unsigned int) len; info[i]->magic = KV5M_ETYPE_INFO_ENTRY; } @@ -728,285 +504,207 @@ krb5_error_code ktest_make_sample_etype_info2(p) info[1]->length = KRB5_ETYPE_NO_SALT; info[1]->salt = 0; *p = info; - return 0; -memfail: - ktest_destroy_etype_info(info); - return ENOMEM; } -krb5_error_code ktest_make_sample_pa_enc_ts(pa_enc) - krb5_pa_enc_ts * pa_enc; +void +ktest_make_sample_pa_enc_ts(krb5_pa_enc_ts *pa_enc) { pa_enc->patimestamp = SAMPLE_TIME; pa_enc->pausec = SAMPLE_USEC; - - return 0; } -krb5_error_code ktest_make_sample_sam_challenge(p) - krb5_sam_challenge * p; +void +ktest_make_sample_sam_challenge(krb5_sam_challenge *p) { - krb5_error_code retval; - p->magic = KV5M_SAM_CHALLENGE; p->sam_type = 42; /* information */ p->sam_flags = KRB5_SAM_USE_SAD_AS_KEY; /* KRB5_SAM_* values */ - p->sam_type_name.data = strdup("type name"); - if (p->sam_type_name.data == NULL) return ENOMEM; - p->sam_type_name.length = strlen(p->sam_type_name.data); - p->sam_track_id.data = 0; - p->sam_track_id.length = 0; - p->sam_challenge_label.data = strdup("challenge label"); - if (p->sam_challenge_label.data == NULL) return ENOMEM; - p->sam_challenge_label.length = strlen(p->sam_challenge_label.data); - p->sam_challenge.data = strdup("challenge ipse"); - if (p->sam_challenge.data == NULL) return ENOMEM; - p->sam_challenge.length = strlen(p->sam_challenge.data); - p->sam_response_prompt.data = strdup("response_prompt ipse"); - if (p->sam_response_prompt.data == NULL) return ENOMEM; - p->sam_response_prompt.length = strlen(p->sam_response_prompt.data); - p->sam_pk_for_sad.data = 0; - p->sam_pk_for_sad.length = 0; + krb5_data_parse(&p->sam_type_name, "type name"); + p->sam_track_id = empty_data(); + krb5_data_parse(&p->sam_challenge_label, "challenge label"); + krb5_data_parse(&p->sam_challenge, "challenge ipse"); + krb5_data_parse(&p->sam_response_prompt, "response_prompt ipse"); + p->sam_pk_for_sad = empty_data(); p->sam_nonce = 0x543210; - retval = ktest_make_sample_checksum(&p->sam_cksum); - if (retval) return retval; - - return 0; + ktest_make_sample_checksum(&p->sam_cksum); } -krb5_error_code ktest_make_sample_sam_response(p) - krb5_sam_response * p; +void +ktest_make_sample_sam_response(krb5_sam_response *p) { p->magic = KV5M_SAM_RESPONSE; p->sam_type = 42; /* information */ p->sam_flags = KRB5_SAM_USE_SAD_AS_KEY; /* KRB5_SAM_* values */ - p->sam_track_id.data = strdup("track data"); - if (p->sam_track_id.data == NULL) return ENOMEM; - p->sam_track_id.length = strlen(p->sam_track_id.data); - p->sam_enc_key.ciphertext.data = strdup("key"); - if (p->sam_enc_key.ciphertext.data == NULL) return ENOMEM; - p->sam_enc_key.ciphertext.length = strlen(p->sam_enc_key.ciphertext.data); + krb5_data_parse(&p->sam_track_id, "track data"); + krb5_data_parse(&p->sam_enc_key.ciphertext, "key"); p->sam_enc_key.enctype = ENCTYPE_DES_CBC_CRC; p->sam_enc_key.kvno = 1942; - p->sam_enc_nonce_or_ts.ciphertext.data = strdup("nonce or ts"); - if (p->sam_enc_nonce_or_ts.ciphertext.data == NULL) return ENOMEM; - p->sam_enc_nonce_or_ts.ciphertext.length = - strlen(p->sam_enc_nonce_or_ts.ciphertext.data); + krb5_data_parse(&p->sam_enc_nonce_or_ts.ciphertext, "nonce or ts"); p->sam_enc_nonce_or_ts.enctype = ENCTYPE_DES_CBC_CRC; p->sam_enc_nonce_or_ts.kvno = 3382; p->sam_nonce = 0x543210; p->sam_patimestamp = SAMPLE_TIME; - - return 0; } -krb5_error_code ktest_make_sample_sam_response_2(p) - krb5_sam_response_2 * p; + +void +ktest_make_sample_sam_response_2(krb5_sam_response_2 *p) { p->magic = KV5M_SAM_RESPONSE; p->sam_type = 43; /* information */ p->sam_flags = KRB5_SAM_USE_SAD_AS_KEY; /* KRB5_SAM_* values */ - p->sam_track_id.data = strdup("track data"); - if (p->sam_track_id.data == NULL) return ENOMEM; - p->sam_track_id.length = strlen(p->sam_track_id.data); - p->sam_enc_nonce_or_sad.ciphertext.data = strdup("nonce or sad"); - if (p->sam_enc_nonce_or_sad.ciphertext.data == NULL) return ENOMEM; - p->sam_enc_nonce_or_sad.ciphertext.length = - strlen(p->sam_enc_nonce_or_sad.ciphertext.data); + krb5_data_parse(&p->sam_track_id, "track data"); + krb5_data_parse(&p->sam_enc_nonce_or_sad.ciphertext, "nonce or sad"); p->sam_enc_nonce_or_sad.enctype = ENCTYPE_DES_CBC_CRC; p->sam_enc_nonce_or_sad.kvno = 3382; p->sam_nonce = 0x543210; - - return 0; } -krb5_error_code ktest_make_sample_sam_key(p) - krb5_sam_key *p; +void +ktest_make_sample_sam_key(krb5_sam_key *p) { p->magic = 99; - return ktest_make_sample_keyblock(&p->sam_key); + ktest_make_sample_keyblock(&p->sam_key); } -krb5_error_code ktest_make_sample_enc_sam_response_enc(p) - krb5_enc_sam_response_enc *p; +void +ktest_make_sample_enc_sam_response_enc(krb5_enc_sam_response_enc *p) { p->magic = 78; p->sam_nonce = 78634; p->sam_timestamp = 99999; p->sam_usec = 399; - p->sam_sad.data = strdup("enc_sam_response_enc"); - if (p->sam_sad.data == NULL) return ENOMEM; - p->sam_sad.length = strlen(p->sam_sad.data); - return 0; + krb5_data_parse(&p->sam_sad, "enc_sam_response_enc"); } -krb5_error_code ktest_make_sample_enc_sam_response_enc_2(p) - krb5_enc_sam_response_enc_2 *p; +void +ktest_make_sample_enc_sam_response_enc_2(krb5_enc_sam_response_enc_2 *p) { p->magic = 83; p->sam_nonce = 88; - p->sam_sad.data = strdup("enc_sam_response_enc_2"); - if (p->sam_sad.data == NULL) return ENOMEM; - p->sam_sad.length = strlen(p->sam_sad.data); - return 0; + krb5_data_parse(&p->sam_sad, "enc_sam_response_enc_2"); } -krb5_error_code ktest_make_sample_pa_s4u_x509_user(p) - krb5_pa_s4u_x509_user *p; +void +ktest_make_sample_pa_s4u_x509_user(krb5_pa_s4u_x509_user *p) { - krb5_error_code retval; krb5_s4u_userid *u = &p->user_id; + u->nonce = 13243546; - retval = ktest_make_sample_principal(&u->user); - if (retval) return retval; - u->subject_cert.data = strdup("pa_s4u_x509_user"); - if (u->subject_cert.data == NULL) return ENOMEM; - u->subject_cert.length = strlen(u->subject_cert.data); + ktest_make_sample_principal(&u->user); + krb5_data_parse(&u->subject_cert, "pa_s4u_x509_user"); u->options = 0x80000000; - retval = ktest_make_sample_checksum(&p->cksum); - if (retval) return retval; - return 0; + ktest_make_sample_checksum(&p->cksum); } -krb5_error_code ktest_make_sample_ad_kdcissued(p) - krb5_ad_kdcissued *p; +void +ktest_make_sample_ad_kdcissued(krb5_ad_kdcissued *p) { - krb5_error_code retval; - retval = ktest_make_sample_checksum(&p->ad_checksum); - if (retval) return retval; - retval = ktest_make_sample_principal(&p->i_principal); - if (retval) return retval; - retval = ktest_make_sample_authorization_data(&p->elements); - if (retval) return retval; - return retval; + ktest_make_sample_checksum(&p->ad_checksum); + ktest_make_sample_principal(&p->i_principal); + ktest_make_sample_authorization_data(&p->elements); } -krb5_error_code ktest_make_sample_ad_signedpath_data(p) - krb5_ad_signedpath_data *p; +void +ktest_make_sample_ad_signedpath_data(krb5_ad_signedpath_data *p) { - krb5_error_code retval; - retval = ktest_make_sample_principal(&p->client); - if (retval) return retval; + ktest_make_sample_principal(&p->client); p->authtime = SAMPLE_TIME; - p->delegated = k5alloc((2 * sizeof(krb5_principal)), &retval); - if (retval) return retval; - retval = ktest_make_sample_principal(&p->delegated[0]); - if (retval) return retval; + p->delegated = ealloc(2 * sizeof(krb5_principal)); + ktest_make_sample_principal(&p->delegated[0]); p->delegated[1] = NULL; - retval = ktest_make_sample_authorization_data(&p->authorization_data); - if (retval) return retval; - retval = ktest_make_sample_pa_data_array(&p->method_data); - if (retval) return retval; - return retval; + ktest_make_sample_authorization_data(&p->authorization_data); + ktest_make_sample_pa_data_array(&p->method_data); } -krb5_error_code ktest_make_sample_ad_signedpath(p) - krb5_ad_signedpath*p; +void +ktest_make_sample_ad_signedpath(krb5_ad_signedpath *p) { - krb5_error_code retval; p->enctype = 1; - retval = ktest_make_sample_checksum(&p->checksum); - if (retval) return retval; - p->delegated = k5alloc((2 * sizeof(krb5_principal)), &retval); - if (retval) return retval; + ktest_make_sample_checksum(&p->checksum); + p->delegated = ealloc(2 * sizeof(krb5_principal)); p->delegated[1] = NULL; - retval = ktest_make_sample_pa_data_array(&p->method_data); - if (retval) return retval; - return retval; + ktest_make_sample_pa_data_array(&p->method_data); } -krb5_error_code ktest_make_sample_iakerb_header(ih) - krb5_iakerb_header *ih; +void +ktest_make_sample_iakerb_header(krb5_iakerb_header *ih) { - krb5_error_code retval; - retval = ktest_make_sample_data(&(ih->target_realm)); - if (retval) return retval; - ih->cookie = k5alloc(sizeof(krb5_data), &retval); - if (retval) return retval; - retval = ktest_make_sample_data(ih->cookie); - if (retval) return retval; - return retval; + ktest_make_sample_data(&(ih->target_realm)); + ih->cookie = ealloc(sizeof(krb5_data)); + ktest_make_sample_data(ih->cookie); } -krb5_error_code ktest_make_sample_iakerb_finished(ih) - krb5_iakerb_finished *ih; +void +ktest_make_sample_iakerb_finished(krb5_iakerb_finished *ih) { - krb5_error_code retval; - retval = ktest_make_sample_checksum(&ih->checksum); - if (retval) return retval; - return retval; + ktest_make_sample_checksum(&ih->checksum); } #ifdef ENABLE_LDAP -static krb5_error_code ktest_make_sample_key_data(krb5_key_data *p, int i) +static void +ktest_make_sample_key_data(krb5_key_data *p, int i) { char *str; int len; + p->key_data_ver = 2; p->key_data_kvno = 42; len = asprintf(&str, "key%d", i); + if (len < 0) + abort(); p->key_data_type[0] = 2; p->key_data_length[0] = (unsigned int) len; - p->key_data_contents[0] = (krb5_octet *) str; + p->key_data_contents[0] = (krb5_octet *)str; len = asprintf(&str, "salt%d", i); + if (len < 0) + abort(); p->key_data_type[1] = i; p->key_data_length[1] = (unsigned int) len; - p->key_data_contents[1] = (krb5_octet *) str; - if (p->key_data_contents[0] == NULL || p->key_data_contents[1] == NULL) - return ENOMEM; - return 0; + p->key_data_contents[1] = (krb5_octet *)str; } -krb5_error_code ktest_make_sample_ldap_seqof_key_data(p) - ldap_seqof_key_data *p; +void +ktest_make_sample_ldap_seqof_key_data(ldap_seqof_key_data *p) { int i; + p->mkvno = 14; p->n_key_data = 3; p->key_data = calloc(3,sizeof(krb5_key_data)); - for (i = 0; i < 3; i++) { - krb5_error_code ret; - ret = ktest_make_sample_key_data(&p->key_data[i], i); - if (ret) return ret; - } - return 0; + for (i = 0; i < 3; i++) + ktest_make_sample_key_data(&p->key_data[i], i); } #endif -krb5_error_code ktest_make_sample_predicted_sam_response(p) - krb5_predicted_sam_response *p; +void +ktest_make_sample_predicted_sam_response(krb5_predicted_sam_response *p) { - krb5_error_code retval; - p->magic = 79; - retval = ktest_make_sample_keyblock(&p->sam_key); - if (retval) return retval; + ktest_make_sample_keyblock(&p->sam_key); p->sam_flags = 9; p->stime = 17; p->susec = 18; - retval = ktest_make_sample_principal(&p->client); - if (retval) return retval; - retval = krb5_data_parse(&p->msd, "hello"); - if (retval) return retval; - return 0; + ktest_make_sample_principal(&p->client); + krb5_data_parse(&p->msd, "hello"); } /****************************************************************/ /* destructors */ -void ktest_destroy_data(d) - krb5_data ** d; +void +ktest_destroy_data(krb5_data **d) { if (*d != NULL) { - if ((*d)->data != NULL) free((*d)->data); + free((*d)->data); free(*d); *d = NULL; } } -void ktest_empty_data(d) - krb5_data * d; +void +ktest_empty_data(krb5_data *d) { if (d->data != NULL) { free(d->data); @@ -1015,243 +713,230 @@ void ktest_empty_data(d) } } -void ktest_destroy_checksum(cs) - krb5_checksum ** cs; +void +ktest_destroy_checksum(krb5_checksum **cs) { if (*cs != NULL) { - if ((*cs)->contents != NULL) free((*cs)->contents); + free((*cs)->contents); free(*cs); *cs = NULL; } } -void ktest_empty_keyblock(kb) - krb5_keyblock * kb; +void +ktest_empty_keyblock(krb5_keyblock *kb) { if (kb != NULL) { if (kb->contents) { - free (kb->contents); + free(kb->contents); kb->contents = NULL; } } } -void ktest_destroy_keyblock(kb) - krb5_keyblock ** kb; +void +ktest_destroy_keyblock(krb5_keyblock **kb) { if (*kb != NULL) { - if ((*kb)->contents != NULL) free((*kb)->contents); + free((*kb)->contents); free(*kb); *kb = NULL; } } -void ktest_empty_authorization_data(ad) - krb5_authdata ** ad; +void +ktest_empty_authorization_data(krb5_authdata **ad) { int i; if (*ad != NULL) { for (i=0; ad[i] != NULL; i++) - ktest_destroy_authdata(&(ad[i])); + ktest_destroy_authdata(&ad[i]); } } -void ktest_destroy_authorization_data(ad) - krb5_authdata *** ad; +void +ktest_destroy_authorization_data(krb5_authdata ***ad) { ktest_empty_authorization_data(*ad); free(*ad); *ad = NULL; } -void ktest_destroy_authdata(ad) - krb5_authdata ** ad; +void +ktest_destroy_authdata(krb5_authdata **ad) { if (*ad != NULL) { - if ((*ad)->contents != NULL) free((*ad)->contents); + free((*ad)->contents); free(*ad); *ad = NULL; } } -void ktest_empty_pa_data_array(pad) - krb5_pa_data ** pad; +void +ktest_empty_pa_data_array(krb5_pa_data **pad) { int i; for (i=0; pad[i] != NULL; i++) - ktest_destroy_pa_data(&(pad[i])); + ktest_destroy_pa_data(&pad[i]); } -void ktest_destroy_pa_data_array(pad) - krb5_pa_data *** pad; +void +ktest_destroy_pa_data_array(krb5_pa_data ***pad) { ktest_empty_pa_data_array(*pad); free(*pad); *pad = NULL; } -void ktest_destroy_pa_data(pad) - krb5_pa_data ** pad; +void +ktest_destroy_pa_data(krb5_pa_data **pad) { if (*pad != NULL) { - if ((*pad)->contents != NULL) free((*pad)->contents); + free((*pad)->contents); free(*pad); *pad = NULL; } } - -void ktest_destroy_address(a) - krb5_address ** a; +void +ktest_destroy_address(krb5_address **a) { if (*a != NULL) { - if ((*a)->contents != NULL) free((*a)->contents); + free((*a)->contents); free(*a); *a = NULL; } } -void ktest_empty_addresses(a) - krb5_address ** a; +void +ktest_empty_addresses(krb5_address **a) { int i; for (i=0; a[i] != NULL; i++) - ktest_destroy_address(&(a[i])); + ktest_destroy_address(&a[i]); } -void ktest_destroy_addresses(a) - krb5_address *** a; +void +ktest_destroy_addresses(krb5_address ***a) { ktest_empty_addresses(*a); free(*a); *a = NULL; } -void ktest_destroy_principal(p) - krb5_principal * p; +void +ktest_destroy_principal(krb5_principal *p) { int i; for (i=0; i<(*p)->length; i++) - ktest_empty_data(&(((*p)->data)[i])); - ktest_empty_data(&((*p)->realm)); + ktest_empty_data(&(*p)->data[i]); + ktest_empty_data(&(*p)->realm); free((*p)->data); free(*p); *p = NULL; } -void ktest_destroy_sequence_of_integer(soi) - long ** soi; +void +ktest_destroy_sequence_of_integer(long **soi) { free(*soi); *soi = NULL; } -#if 0 -void ktest_destroy_sequence_of_enctype(soi) - krb5_enctype ** soi; -{ - free(*soi); - *soi = NULL; -} -#endif - -void ktest_destroy_sequence_of_ticket(sot) - krb5_ticket *** sot; +void +ktest_destroy_sequence_of_ticket(krb5_ticket ***sot) { int i; for (i=0; (*sot)[i] != NULL; i++) - ktest_destroy_ticket(&((*sot)[i])); + ktest_destroy_ticket(&(*sot)[i]); free(*sot); *sot = NULL; } -void ktest_destroy_ticket(tkt) - krb5_ticket ** tkt; +void +ktest_destroy_ticket(krb5_ticket **tkt) { - ktest_destroy_principal(&((*tkt)->server)); - ktest_destroy_enc_data(&((*tkt)->enc_part)); + ktest_destroy_principal(&(*tkt)->server); + ktest_destroy_enc_data(&(*tkt)->enc_part); /* ktest_empty_enc_tkt_part(((*tkt)->enc_part2));*/ free(*tkt); *tkt = NULL; } -void ktest_empty_ticket(tkt) - krb5_ticket * tkt; +void +ktest_empty_ticket(krb5_ticket *tkt) { if (tkt->server) - ktest_destroy_principal(&((tkt)->server)); - ktest_destroy_enc_data(&((tkt)->enc_part)); - if (tkt->enc_part2) { - ktest_destroy_enc_tkt_part(&(tkt->enc_part2)); - } + ktest_destroy_principal(&tkt->server); + ktest_destroy_enc_data(&tkt->enc_part); + if (tkt->enc_part2) + ktest_destroy_enc_tkt_part(&tkt->enc_part2); } -void ktest_destroy_enc_data(ed) - krb5_enc_data * ed; +void +ktest_destroy_enc_data(krb5_enc_data *ed) { - ktest_empty_data(&(ed->ciphertext)); + ktest_empty_data(&ed->ciphertext); ed->kvno = 0; } -void ktest_destroy_etype_info_entry(i) - krb5_etype_info_entry *i; +void +ktest_destroy_etype_info_entry(krb5_etype_info_entry *i) { if (i->salt) free(i->salt); - ktest_empty_data(&(i->s2kparams)); + ktest_empty_data(&i->s2kparams); free(i); } -void ktest_destroy_etype_info(info) - krb5_etype_info_entry **info; +void +ktest_destroy_etype_info(krb5_etype_info_entry **info) { int i; - for (i=0; info[i] != NULL; i++) + for (i = 0; info[i] != NULL; i++) ktest_destroy_etype_info_entry(info[i]); free(info); } - -void ktest_empty_kdc_req(kr) - krb5_kdc_req *kr; +void +ktest_empty_kdc_req(krb5_kdc_req *kr) { if (kr->padata) - ktest_destroy_pa_data_array(&(kr->padata)); + ktest_destroy_pa_data_array(&kr->padata); if (kr->client) - ktest_destroy_principal(&(kr->client)); + ktest_destroy_principal(&kr->client); if (kr->server) - ktest_destroy_principal(&(kr->server)); - if (kr->ktype) - free(kr->ktype); + ktest_destroy_principal(&kr->server); + free(kr->ktype); if (kr->addresses) - ktest_destroy_addresses(&(kr->addresses)); - ktest_destroy_enc_data(&(kr->authorization_data)); + ktest_destroy_addresses(&kr->addresses); + ktest_destroy_enc_data(&kr->authorization_data); if (kr->unenc_authdata) - ktest_destroy_authorization_data(&(kr->unenc_authdata)); + ktest_destroy_authorization_data(&kr->unenc_authdata); if (kr->second_ticket) - ktest_destroy_sequence_of_ticket(&(kr->second_ticket)); + ktest_destroy_sequence_of_ticket(&kr->second_ticket); } -void ktest_empty_kdc_rep(kr) - krb5_kdc_rep *kr; +void +ktest_empty_kdc_rep(krb5_kdc_rep *kr) { if (kr->padata) - ktest_destroy_pa_data_array(&(kr->padata)); + ktest_destroy_pa_data_array(&kr->padata); if (kr->client) - ktest_destroy_principal(&(kr->client)); + ktest_destroy_principal(&kr->client); if (kr->ticket) - ktest_destroy_ticket(&(kr->ticket)); + ktest_destroy_ticket(&kr->ticket); ktest_destroy_enc_data(&kr->enc_part); @@ -1262,38 +947,35 @@ void ktest_empty_kdc_rep(kr) } } - -void ktest_empty_authenticator(a) - krb5_authenticator * a; +void +ktest_empty_authenticator(krb5_authenticator *a) { - if (a->client) - ktest_destroy_principal(&(a->client)); + ktest_destroy_principal(&a->client); if (a->checksum) - ktest_destroy_checksum(&(a->checksum)); + ktest_destroy_checksum(&a->checksum); if (a->subkey) - ktest_destroy_keyblock(&(a->subkey)); + ktest_destroy_keyblock(&a->subkey); if (a->authorization_data) - ktest_destroy_authorization_data(&(a->authorization_data)); + ktest_destroy_authorization_data(&a->authorization_data); } -void ktest_empty_enc_tkt_part(etp) - krb5_enc_tkt_part * etp; +void +ktest_empty_enc_tkt_part(krb5_enc_tkt_part *etp) { - if (etp->session) - ktest_destroy_keyblock(&(etp->session)); + ktest_destroy_keyblock(&etp->session); if (etp->client) - ktest_destroy_principal(&(etp->client)); + ktest_destroy_principal(&etp->client); if (etp->caddrs) - ktest_destroy_addresses(&(etp->caddrs)); + ktest_destroy_addresses(&etp->caddrs); if (etp->authorization_data) - ktest_destroy_authorization_data(&(etp->authorization_data)); - ktest_destroy_transited(&(etp->transited)); + ktest_destroy_authorization_data(&etp->authorization_data); + ktest_destroy_transited(&etp->transited); } -void ktest_destroy_enc_tkt_part(etp) - krb5_enc_tkt_part ** etp; +void +ktest_destroy_enc_tkt_part(krb5_enc_tkt_part **etp) { if (*etp) { ktest_empty_enc_tkt_part(*etp); @@ -1302,256 +984,242 @@ void ktest_destroy_enc_tkt_part(etp) } } -void ktest_empty_enc_kdc_rep_part(ekr) - krb5_enc_kdc_rep_part * ekr; +void +ktest_empty_enc_kdc_rep_part(krb5_enc_kdc_rep_part *ekr) { - if (ekr->session) - ktest_destroy_keyblock(&(ekr->session)); + ktest_destroy_keyblock(&ekr->session); if (ekr->server) - ktest_destroy_principal(&(ekr->server)); + ktest_destroy_principal(&ekr->server); if (ekr->caddrs) - ktest_destroy_addresses(&(ekr->caddrs)); - ktest_destroy_last_req(&(ekr->last_req)); + ktest_destroy_addresses(&ekr->caddrs); + ktest_destroy_last_req(&ekr->last_req); } - -void ktest_destroy_transited(t) - krb5_transited * t; +void +ktest_destroy_transited(krb5_transited *t) { if (t->tr_contents.data) - ktest_empty_data(&(t->tr_contents)); + ktest_empty_data(&t->tr_contents); } - -void ktest_empty_ap_rep(ar) - krb5_ap_rep * ar; +void +ktest_empty_ap_rep(krb5_ap_rep *ar) { ktest_destroy_enc_data(&ar->enc_part); } -void ktest_empty_ap_req(ar) - krb5_ap_req * ar; +void +ktest_empty_ap_req(krb5_ap_req *ar) { - if (ar->ticket) - ktest_destroy_ticket(&(ar->ticket)); - ktest_destroy_enc_data(&(ar->authenticator)); + ktest_destroy_ticket(&ar->ticket); + ktest_destroy_enc_data(&ar->authenticator); } -void ktest_empty_cred_enc_part(cep) - krb5_cred_enc_part * cep; +void +ktest_empty_cred_enc_part(krb5_cred_enc_part *cep) { if (cep->s_address) - ktest_destroy_address(&(cep->s_address)); + ktest_destroy_address(&cep->s_address); if (cep->r_address) - ktest_destroy_address(&(cep->r_address)); + ktest_destroy_address(&cep->r_address); if (cep->ticket_info) - ktest_destroy_sequence_of_cred_info(&(cep->ticket_info)); + ktest_destroy_sequence_of_cred_info(&cep->ticket_info); } -void ktest_destroy_cred_info(ci) - krb5_cred_info ** ci; +void +ktest_destroy_cred_info(krb5_cred_info **ci) { if ((*ci)->session) - ktest_destroy_keyblock(&((*ci)->session)); + ktest_destroy_keyblock(&(*ci)->session); if ((*ci)->client) - ktest_destroy_principal(&((*ci)->client)); + ktest_destroy_principal(&(*ci)->client); if ((*ci)->server) - ktest_destroy_principal(&((*ci)->server)); + ktest_destroy_principal(&(*ci)->server); if ((*ci)->caddrs) - ktest_destroy_addresses(&((*ci)->caddrs)); + ktest_destroy_addresses(&(*ci)->caddrs); free(*ci); *ci = NULL; } -void ktest_destroy_sequence_of_cred_info(soci) - krb5_cred_info *** soci; +void +ktest_destroy_sequence_of_cred_info(krb5_cred_info ***soci) { int i; - for (i=0; (*soci)[i] != NULL; i++) - ktest_destroy_cred_info(&((*soci)[i])); + for (i = 0; (*soci)[i] != NULL; i++) + ktest_destroy_cred_info(&(*soci)[i]); free(*soci); *soci = NULL; } - -void ktest_empty_safe(s) - krb5_safe * s; +void +ktest_empty_safe(krb5_safe *s) { - ktest_empty_data(&(s->user_data)); - ktest_destroy_address(&(s->s_address)); - ktest_destroy_address(&(s->r_address)); - ktest_destroy_checksum(&(s->checksum)); + ktest_empty_data(&s->user_data); + ktest_destroy_address(&s->s_address); + ktest_destroy_address(&s->r_address); + ktest_destroy_checksum(&s->checksum); } -void ktest_empty_priv_enc_part(pep) - krb5_priv_enc_part * pep; +void +ktest_empty_priv_enc_part(krb5_priv_enc_part *pep) { - ktest_empty_data(&(pep->user_data)); - ktest_destroy_address(&(pep->s_address)); - ktest_destroy_address(&(pep->r_address)); + ktest_empty_data(&pep->user_data); + ktest_destroy_address(&pep->s_address); + ktest_destroy_address(&pep->r_address); } -void ktest_empty_priv(p) - krb5_priv * p; +void +ktest_empty_priv(krb5_priv *p) { - ktest_destroy_enc_data(&(p->enc_part)); + ktest_destroy_enc_data(&p->enc_part); } -void ktest_empty_cred(c) - krb5_cred * c; +void +ktest_empty_cred(krb5_cred *c) { - - ktest_destroy_sequence_of_ticket(&(c->tickets)); - ktest_destroy_enc_data(&(c->enc_part)); + ktest_destroy_sequence_of_ticket(&c->tickets); + ktest_destroy_enc_data(&c->enc_part); /* enc_part2 */ - } -void ktest_destroy_last_req(lr) - krb5_last_req_entry *** lr; +void +ktest_destroy_last_req(krb5_last_req_entry ***lr) { int i; if (*lr) { - for (i=0; (*lr)[i] != NULL; i++) { + for (i=0; (*lr)[i] != NULL; i++) free((*lr)[i]); - } + free(*lr); } } -void ktest_empty_error(kerr) - krb5_error * kerr; +void +ktest_empty_error(krb5_error *kerr) { if (kerr->client) - ktest_destroy_principal(&(kerr->client)); + ktest_destroy_principal(&kerr->client); if (kerr->server) - ktest_destroy_principal(&(kerr->server)); - ktest_empty_data(&(kerr->text)); - ktest_empty_data(&(kerr->e_data)); + ktest_destroy_principal(&kerr->server); + ktest_empty_data(&kerr->text); + ktest_empty_data(&kerr->e_data); } -void ktest_empty_ap_rep_enc_part(arep) - krb5_ap_rep_enc_part * arep; +void +ktest_empty_ap_rep_enc_part(krb5_ap_rep_enc_part *arep) { - ktest_destroy_keyblock(&((arep)->subkey)); + ktest_destroy_keyblock(&(arep)->subkey); } -void ktest_empty_passwd_phrase_element(ppe) - passwd_phrase_element * ppe; +void +ktest_empty_passwd_phrase_element(passwd_phrase_element *ppe) { - ktest_destroy_data(&(ppe->passwd)); - ktest_destroy_data(&(ppe->phrase)); + ktest_destroy_data(&ppe->passwd); + ktest_destroy_data(&ppe->phrase); } -void ktest_empty_pwd_data(pd) - krb5_pwd_data * pd; +void +ktest_empty_pwd_data(krb5_pwd_data *pd) { int i; - for (i=0; i <= pd->sequence_count; i++) { + for (i = 0; i <= pd->sequence_count; i++) { if (pd->element[i]) { ktest_empty_passwd_phrase_element(pd->element[i]); free(pd->element[i]); - pd->element[i] = NULL; } } free(pd->element); - } -void ktest_empty_alt_method(am) - krb5_alt_method *am; +void +ktest_empty_alt_method(krb5_alt_method *am) { - if (am->data) { - free(am->data); - am->data = NULL; - } + free(am->data); + am->data = NULL; } -void ktest_empty_sam_challenge(p) - krb5_sam_challenge * p; +void +ktest_empty_sam_challenge(krb5_sam_challenge *p) { - ktest_empty_data(&(p->sam_type_name)); - ktest_empty_data(&(p->sam_track_id)); - ktest_empty_data(&(p->sam_challenge_label)); - ktest_empty_data(&(p->sam_challenge)); - ktest_empty_data(&(p->sam_response_prompt)); - ktest_empty_data(&(p->sam_pk_for_sad)); - - if (p->sam_cksum.contents != NULL) { - free(p->sam_cksum.contents); - p->sam_cksum.contents = NULL; - } - + ktest_empty_data(&p->sam_type_name); + ktest_empty_data(&p->sam_track_id); + ktest_empty_data(&p->sam_challenge_label); + ktest_empty_data(&p->sam_challenge); + ktest_empty_data(&p->sam_response_prompt); + ktest_empty_data(&p->sam_pk_for_sad); + free(p->sam_cksum.contents); + p->sam_cksum.contents = NULL; } -void ktest_empty_sam_response(p) - krb5_sam_response * p; +void +ktest_empty_sam_response(krb5_sam_response *p) { - ktest_empty_data(&(p->sam_track_id)); - ktest_empty_data(&(p->sam_enc_key.ciphertext)); - ktest_empty_data(&(p->sam_enc_nonce_or_ts.ciphertext)); + ktest_empty_data(&p->sam_track_id); + ktest_empty_data(&p->sam_enc_key.ciphertext); + ktest_empty_data(&p->sam_enc_nonce_or_ts.ciphertext); } -void ktest_empty_sam_key(p) - krb5_sam_key *p; +void +ktest_empty_sam_key(krb5_sam_key *p) { - if (p->sam_key.contents) - free(p->sam_key.contents); + free(p->sam_key.contents); } -void ktest_empty_predicted_sam_response(p) - krb5_predicted_sam_response *p; +void +ktest_empty_predicted_sam_response(krb5_predicted_sam_response *p) { ktest_empty_keyblock(&p->sam_key); ktest_destroy_principal(&p->client); ktest_empty_data(&p->msd); } -void ktest_empty_enc_sam_response_enc(p) - krb5_enc_sam_response_enc *p; +void +ktest_empty_enc_sam_response_enc(krb5_enc_sam_response_enc *p) { ktest_empty_data(&p->sam_sad); } -void ktest_empty_sam_response_2(p) - krb5_sam_response_2 *p; +void +ktest_empty_sam_response_2(krb5_sam_response_2 *p) { ktest_empty_data(&p->sam_track_id); ktest_empty_data(&p->sam_enc_nonce_or_sad.ciphertext); } -void ktest_empty_enc_sam_response_enc_2(p) - krb5_enc_sam_response_enc_2 *p; + +void +ktest_empty_enc_sam_response_enc_2(krb5_enc_sam_response_enc_2 *p) { ktest_empty_data(&p->sam_sad); } -void ktest_empty_pa_s4u_x509_user(p) - krb5_pa_s4u_x509_user *p; +void +ktest_empty_pa_s4u_x509_user(krb5_pa_s4u_x509_user *p) { ktest_destroy_principal(&p->user_id.user); ktest_empty_data(&p->user_id.subject_cert); - if (p->cksum.contents) free(p->cksum.contents); + free(p->cksum.contents); } -void ktest_empty_ad_kdcissued(p) - krb5_ad_kdcissued *p; +void +ktest_empty_ad_kdcissued(krb5_ad_kdcissued *p) { - if (p->ad_checksum.contents) free(p->ad_checksum.contents); + free(p->ad_checksum.contents); ktest_destroy_principal(&p->i_principal); ktest_destroy_authorization_data(&p->elements); } -void ktest_empty_ad_signedpath_data(p) - krb5_ad_signedpath_data *p; +void +ktest_empty_ad_signedpath_data(krb5_ad_signedpath_data *p) { int i; + ktest_destroy_principal(&p->client); if (p->delegated != NULL) { for (i = 0; p->delegated[i] != NULL; i++) { @@ -1564,11 +1232,12 @@ void ktest_empty_ad_signedpath_data(p) ktest_destroy_authorization_data(&p->authorization_data); } -void ktest_empty_ad_signedpath(p) - krb5_ad_signedpath *p; +void +ktest_empty_ad_signedpath(krb5_ad_signedpath *p) { int i; - if (p->checksum.contents) free(p->checksum.contents); + + free(p->checksum.contents); if (p->delegated != NULL) { for (i = 0; p->delegated[i] != NULL; i++) { krb5_principal princ = p->delegated[i]; @@ -1579,25 +1248,25 @@ void ktest_empty_ad_signedpath(p) ktest_destroy_pa_data_array(&p->method_data); } -void ktest_empty_iakerb_header(p) - krb5_iakerb_header *p; +void +ktest_empty_iakerb_header(krb5_iakerb_header *p) { krb5_free_data_contents(NULL, &p->target_realm); krb5_free_data(NULL, p->cookie); } -void ktest_empty_iakerb_finished(p) - krb5_iakerb_finished *p; +void +ktest_empty_iakerb_finished(krb5_iakerb_finished *p) { krb5_free_checksum_contents(NULL, &p->checksum); } #ifdef ENABLE_LDAP -void ktest_empty_ldap_seqof_key_data(ctx, p) - krb5_context ctx; - ldap_seqof_key_data *p; +void +ktest_empty_ldap_seqof_key_data(krb5_context ctx, ldap_seqof_key_data *p) { int i; + for (i = 0; i < p->n_key_data; i++) { free(p->key_data[i].key_data_contents[0]); free(p->key_data[i].key_data_contents[1]); diff --git a/src/tests/asn.1/ktest.h b/src/tests/asn.1/ktest.h index 99f44c6e3b..70a5507f94 100644 --- a/src/tests/asn.1/ktest.h +++ b/src/tests/asn.1/ktest.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* tests/asn.1/ktest.h */ /* * Copyright (C) 1994 by the Massachusetts Institute of Technology. @@ -35,210 +36,119 @@ #define SAMPLE_NONCE 42 #define SAMPLE_FLAGS 0xFEDCBA98 #define SAMPLE_ERROR 0x3C; -krb5_error_code ktest_make_sample_data - (krb5_data *d); -krb5_error_code ktest_make_sample_authenticator - (krb5_authenticator *a); - krb5_error_code ktest_make_sample_principal - (krb5_principal *p); - krb5_error_code ktest_make_sample_checksum - (krb5_checksum *cs); - krb5_error_code ktest_make_sample_keyblock - (krb5_keyblock *kb); -krb5_error_code ktest_make_sample_ticket - (krb5_ticket *tkt); - krb5_error_code ktest_make_sample_enc_data - (krb5_enc_data *ed); -krb5_error_code ktest_make_sample_enc_tkt_part - (krb5_enc_tkt_part *etp); - krb5_error_code ktest_make_sample_transited - (krb5_transited *t); - krb5_error_code ktest_make_sample_ticket_times - (krb5_ticket_times *tt); - krb5_error_code ktest_make_sample_addresses - (krb5_address ***caddrs); - krb5_error_code ktest_make_sample_address - (krb5_address *a); - krb5_error_code ktest_make_sample_authorization_data - (krb5_authdata ***ad); - krb5_error_code ktest_make_sample_authdata - (krb5_authdata *ad); -krb5_error_code ktest_make_sample_enc_kdc_rep_part - (krb5_enc_kdc_rep_part *ekr); -krb5_error_code ktest_make_sample_kdc_req - (krb5_kdc_req *kr); - krb5_error_code ktest_make_sample_last_req - (krb5_last_req_entry ***lr); - krb5_error_code ktest_make_sample_last_req_entry - (krb5_last_req_entry **lre); -krb5_error_code ktest_make_sample_kdc_rep - (krb5_kdc_rep *kdcr); - krb5_error_code ktest_make_sample_pa_data_array - (krb5_pa_data ***pad); - krb5_error_code ktest_make_sample_empty_pa_data_array - (krb5_pa_data ***pad); - krb5_error_code ktest_make_sample_pa_data - (krb5_pa_data *pad); -krb5_error_code ktest_make_sample_ap_req - (krb5_ap_req *ar); -krb5_error_code ktest_make_sample_ap_rep - (krb5_ap_rep *ar); -krb5_error_code ktest_make_sample_ap_rep_enc_part - (krb5_ap_rep_enc_part *arep); -krb5_error_code ktest_make_sample_kdc_req_body - (krb5_kdc_req *krb); -krb5_error_code ktest_make_sample_safe - (krb5_safe *s); -krb5_error_code ktest_make_sample_priv - (krb5_priv *p); -krb5_error_code ktest_make_sample_priv_enc_part - (krb5_priv_enc_part *pep); -krb5_error_code ktest_make_sample_cred - (krb5_cred *c); -krb5_error_code ktest_make_sample_cred_enc_part - (krb5_cred_enc_part *cep); - krb5_error_code ktest_make_sample_sequence_of_ticket - (krb5_ticket ***sot); -krb5_error_code ktest_make_sample_error - (krb5_error *kerr); -krb5_error_code ktest_make_sequence_of_cred_info - (krb5_cred_info ***soci); - krb5_error_code ktest_make_sample_cred_info - (krb5_cred_info *ci); -krb5_error_code ktest_make_sample_passwd_phrase_element - (passwd_phrase_element *ppe); -krb5_error_code ktest_make_sample_krb5_pwd_data - (krb5_pwd_data *pd); -krb5_error_code ktest_make_sample_alt_method - (krb5_alt_method *am); +void ktest_make_sample_data(krb5_data *d); +void ktest_make_sample_authenticator(krb5_authenticator *a); +void ktest_make_sample_principal(krb5_principal *p); +void ktest_make_sample_checksum(krb5_checksum *cs); +void ktest_make_sample_keyblock(krb5_keyblock *kb); +void ktest_make_sample_ticket(krb5_ticket *tkt); +void ktest_make_sample_enc_data(krb5_enc_data *ed); +void ktest_make_sample_enc_tkt_part(krb5_enc_tkt_part *etp); +void ktest_make_sample_transited(krb5_transited *t); +void ktest_make_sample_ticket_times(krb5_ticket_times *tt); +void ktest_make_sample_addresses(krb5_address ***caddrs); +void ktest_make_sample_address(krb5_address *a); +void ktest_make_sample_authorization_data(krb5_authdata ***ad); +void ktest_make_sample_authdata(krb5_authdata *ad); +void ktest_make_sample_enc_kdc_rep_part(krb5_enc_kdc_rep_part *ekr); +void ktest_make_sample_kdc_req(krb5_kdc_req *kr); -krb5_error_code ktest_make_sample_etype_info - (krb5_etype_info_entry *** p); -krb5_error_code ktest_make_sample_etype_info2 - (krb5_etype_info_entry *** p); -krb5_error_code ktest_make_sample_pa_enc_ts - (krb5_pa_enc_ts *am); -krb5_error_code ktest_make_sample_sam_challenge - (krb5_sam_challenge * p); -krb5_error_code ktest_make_sample_sam_response - (krb5_sam_response * p); -krb5_error_code ktest_make_sample_sam_response_2 - (krb5_sam_response_2 * p); -krb5_error_code ktest_make_sample_sam_key(krb5_sam_key *p); -krb5_error_code ktest_make_sample_enc_sam_response_enc - (krb5_enc_sam_response_enc *p); -krb5_error_code ktest_make_sample_predicted_sam_response(krb5_predicted_sam_response *p); -krb5_error_code ktest_make_sample_enc_sam_response_enc_2(krb5_enc_sam_response_enc_2 *p); -krb5_error_code ktest_make_sample_pa_s4u_x509_user(krb5_pa_s4u_x509_user *p); -krb5_error_code ktest_make_sample_ad_kdcissued(krb5_ad_kdcissued *p); -krb5_error_code ktest_make_sample_ad_signedpath_data(krb5_ad_signedpath_data *p); -krb5_error_code ktest_make_sample_ad_signedpath(krb5_ad_signedpath *p); -krb5_error_code ktest_make_sample_iakerb_header(krb5_iakerb_header *p); -krb5_error_code ktest_make_sample_iakerb_finished(krb5_iakerb_finished *p); +void ktest_make_sample_last_req(krb5_last_req_entry ***lr); +void ktest_make_sample_last_req_entry(krb5_last_req_entry **lre); +void ktest_make_sample_kdc_rep(krb5_kdc_rep *kdcr); +void ktest_make_sample_pa_data_array(krb5_pa_data ***pad); +void ktest_make_sample_empty_pa_data_array(krb5_pa_data ***pad); +void ktest_make_sample_pa_data(krb5_pa_data *pad); +void ktest_make_sample_ap_req(krb5_ap_req *ar); +void ktest_make_sample_ap_rep(krb5_ap_rep *ar); +void ktest_make_sample_ap_rep_enc_part(krb5_ap_rep_enc_part *arep); +void ktest_make_sample_kdc_req_body(krb5_kdc_req *krb); +void ktest_make_sample_safe(krb5_safe *s); +void ktest_make_sample_priv(krb5_priv *p); +void ktest_make_sample_priv_enc_part(krb5_priv_enc_part *pep); +void ktest_make_sample_cred(krb5_cred *c); +void ktest_make_sample_cred_enc_part(krb5_cred_enc_part *cep); +void ktest_make_sample_sequence_of_ticket(krb5_ticket ***sot); +void ktest_make_sample_error(krb5_error *kerr); +void ktest_make_sequence_of_cred_info(krb5_cred_info ***soci); +void ktest_make_sample_cred_info(krb5_cred_info *ci); +void ktest_make_sample_passwd_phrase_element(passwd_phrase_element *ppe); +void ktest_make_sample_krb5_pwd_data(krb5_pwd_data *pd); +void ktest_make_sample_alt_method(krb5_alt_method *am); + +void ktest_make_sample_etype_info(krb5_etype_info_entry ***p); +void ktest_make_sample_etype_info2(krb5_etype_info_entry ***p); +void ktest_make_sample_pa_enc_ts(krb5_pa_enc_ts *am); +void ktest_make_sample_sam_challenge(krb5_sam_challenge *p); +void ktest_make_sample_sam_response(krb5_sam_response *p); +void ktest_make_sample_sam_response_2(krb5_sam_response_2 *p); +void ktest_make_sample_sam_key(krb5_sam_key *p); +void ktest_make_sample_enc_sam_response_enc(krb5_enc_sam_response_enc *p); +void ktest_make_sample_predicted_sam_response(krb5_predicted_sam_response *p); +void ktest_make_sample_enc_sam_response_enc_2(krb5_enc_sam_response_enc_2 *p); +void ktest_make_sample_pa_s4u_x509_user(krb5_pa_s4u_x509_user *p); +void ktest_make_sample_ad_kdcissued(krb5_ad_kdcissued *p); +void ktest_make_sample_ad_signedpath_data(krb5_ad_signedpath_data *p); +void ktest_make_sample_ad_signedpath(krb5_ad_signedpath *p); +void ktest_make_sample_iakerb_header(krb5_iakerb_header *p); +void ktest_make_sample_iakerb_finished(krb5_iakerb_finished *p); #ifdef ENABLE_LDAP -krb5_error_code ktest_make_sample_ldap_seqof_key_data(ldap_seqof_key_data * p); +void ktest_make_sample_ldap_seqof_key_data(ldap_seqof_key_data *p); #endif /*----------------------------------------------------------------------*/ -void ktest_empty_authorization_data - (krb5_authdata **ad); -void ktest_destroy_authorization_data - (krb5_authdata ***ad); - void ktest_destroy_authorization_data - (krb5_authdata ***ad); -void ktest_empty_addresses - (krb5_address **a); -void ktest_destroy_addresses - (krb5_address ***a); - void ktest_destroy_address - (krb5_address **a); -void ktest_empty_pa_data_array - (krb5_pa_data **pad); -void ktest_destroy_pa_data_array - (krb5_pa_data ***pad); - void ktest_destroy_pa_data - (krb5_pa_data **pad); +void ktest_empty_authorization_data(krb5_authdata **ad); +void ktest_destroy_authorization_data(krb5_authdata ***ad); +void ktest_destroy_authorization_data(krb5_authdata ***ad); +void ktest_empty_addresses(krb5_address **a); +void ktest_destroy_addresses(krb5_address ***a); +void ktest_destroy_address(krb5_address **a); +void ktest_empty_pa_data_array(krb5_pa_data **pad); +void ktest_destroy_pa_data_array(krb5_pa_data ***pad); +void ktest_destroy_pa_data(krb5_pa_data **pad); -void ktest_destroy_data - (krb5_data **d); -void ktest_empty_data - (krb5_data *d); -void ktest_destroy_principal - (krb5_principal *p); -void ktest_destroy_checksum - (krb5_checksum **cs); -void ktest_empty_keyblock - (krb5_keyblock *kb); -void ktest_destroy_keyblock - (krb5_keyblock **kb); -void ktest_destroy_authdata - (krb5_authdata **ad); -void ktest_destroy_sequence_of_integer - (long **soi); -void ktest_destroy_sequence_of_ticket - (krb5_ticket ***sot); - void ktest_destroy_ticket - (krb5_ticket **tkt); -void ktest_empty_ticket - (krb5_ticket *tkt); -void ktest_destroy_enc_data - (krb5_enc_data *ed); -void ktest_empty_error - (krb5_error * kerr); -void ktest_destroy_etype_info_entry - (krb5_etype_info_entry *i); -void ktest_destroy_etype_info - (krb5_etype_info_entry **info); +void ktest_destroy_data(krb5_data **d); +void ktest_empty_data(krb5_data *d); +void ktest_destroy_principal(krb5_principal *p); +void ktest_destroy_checksum(krb5_checksum **cs); +void ktest_empty_keyblock(krb5_keyblock *kb); +void ktest_destroy_keyblock(krb5_keyblock **kb); +void ktest_destroy_authdata(krb5_authdata **ad); +void ktest_destroy_sequence_of_integer(long **soi); +void ktest_destroy_sequence_of_ticket(krb5_ticket ***sot); +void ktest_destroy_ticket(krb5_ticket **tkt); +void ktest_empty_ticket(krb5_ticket *tkt); +void ktest_destroy_enc_data(krb5_enc_data *ed); +void ktest_empty_error(krb5_error *kerr); +void ktest_destroy_etype_info_entry(krb5_etype_info_entry *i); +void ktest_destroy_etype_info(krb5_etype_info_entry **info); -void ktest_empty_kdc_req - (krb5_kdc_req *kr); -void ktest_empty_kdc_rep - (krb5_kdc_rep *kr); +void ktest_empty_kdc_req(krb5_kdc_req *kr); +void ktest_empty_kdc_rep(krb5_kdc_rep *kr); -void ktest_empty_authenticator - (krb5_authenticator *a); -void ktest_empty_enc_tkt_part - (krb5_enc_tkt_part * etp); -void ktest_destroy_enc_tkt_part - (krb5_enc_tkt_part ** etp); -void ktest_empty_enc_kdc_rep_part - (krb5_enc_kdc_rep_part * ekr); -void ktest_destroy_transited - (krb5_transited * t); -void ktest_empty_ap_rep - (krb5_ap_rep * ar); -void ktest_empty_ap_req - (krb5_ap_req * ar); -void ktest_empty_cred_enc_part - (krb5_cred_enc_part * cep); -void ktest_destroy_cred_info - (krb5_cred_info ** ci); -void ktest_destroy_sequence_of_cred_info - (krb5_cred_info *** soci); -void ktest_empty_safe - (krb5_safe * s); -void ktest_empty_priv - (krb5_priv * p); -void ktest_empty_priv_enc_part - (krb5_priv_enc_part * pep); -void ktest_empty_cred - (krb5_cred * c); -void ktest_destroy_last_req - (krb5_last_req_entry *** lr); -void ktest_empty_ap_rep_enc_part - (krb5_ap_rep_enc_part * arep); -void ktest_empty_passwd_phrase_element - (passwd_phrase_element * ppe); -void ktest_empty_pwd_data - (krb5_pwd_data * pd); -void ktest_empty_alt_method - (krb5_alt_method *am); -void ktest_empty_sam_challenge - (krb5_sam_challenge * p); -void ktest_empty_sam_response - (krb5_sam_response * p); +void ktest_empty_authenticator(krb5_authenticator *a); +void ktest_empty_enc_tkt_part(krb5_enc_tkt_part *etp); +void ktest_destroy_enc_tkt_part(krb5_enc_tkt_part **etp); +void ktest_empty_enc_kdc_rep_part(krb5_enc_kdc_rep_part *ekr); +void ktest_destroy_transited(krb5_transited *t); +void ktest_empty_ap_rep(krb5_ap_rep *ar); +void ktest_empty_ap_req(krb5_ap_req *ar); +void ktest_empty_cred_enc_part(krb5_cred_enc_part *cep); +void ktest_destroy_cred_info(krb5_cred_info **ci); +void ktest_destroy_sequence_of_cred_info(krb5_cred_info ***soci); +void ktest_empty_safe(krb5_safe *s); +void ktest_empty_priv(krb5_priv *p); +void ktest_empty_priv_enc_part(krb5_priv_enc_part *pep); +void ktest_empty_cred(krb5_cred *c); +void ktest_destroy_last_req(krb5_last_req_entry ***lr); +void ktest_empty_ap_rep_enc_part(krb5_ap_rep_enc_part *arep); +void ktest_empty_passwd_phrase_element(passwd_phrase_element *ppe); +void ktest_empty_pwd_data(krb5_pwd_data *pd); +void ktest_empty_alt_method(krb5_alt_method *am); +void ktest_empty_sam_challenge(krb5_sam_challenge *p); +void ktest_empty_sam_response(krb5_sam_response *p); void ktest_empty_sam_key(krb5_sam_key *p); void ktest_empty_enc_sam_response_enc(krb5_enc_sam_response_enc *p); void ktest_empty_predicted_sam_response(krb5_predicted_sam_response *p); diff --git a/src/tests/asn.1/ktest_equal.c b/src/tests/asn.1/ktest_equal.c index a1a95d445d..209d6a9cd4 100644 --- a/src/tests/asn.1/ktest_equal.c +++ b/src/tests/asn.1/ktest_equal.c @@ -44,12 +44,12 @@ ((ref->length == var->length) && \ comparator(ref->length,ref->field,var->field)) -int ktest_equal_authenticator(ref, var) - krb5_authenticator * ref; - krb5_authenticator * var; +int +ktest_equal_authenticator(krb5_authenticator *ref, krb5_authenticator *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; p = p && ptr_equal(client,ktest_equal_principal_data); p = p && ptr_equal(checksum,ktest_equal_checksum); @@ -61,60 +61,54 @@ int ktest_equal_authenticator(ref, var) return p; } -int ktest_equal_principal_data(ref, var) - krb5_principal_data * ref; - krb5_principal_data * var; +int +ktest_equal_principal_data(krb5_principal_data *ref, krb5_principal_data *var) { - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; return(struct_equal(realm,ktest_equal_data) && len_equal(length,data,ktest_equal_array_of_data) && scalar_equal(type)); } -int ktest_equal_authdata(ref, var) - krb5_authdata * ref; - krb5_authdata * var; +int +ktest_equal_authdata(krb5_authdata *ref, krb5_authdata *var) { - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; return(scalar_equal(ad_type) && len_equal(length,contents,ktest_equal_array_of_octet)); } -int ktest_equal_checksum(ref, var) - krb5_checksum * ref; - krb5_checksum * var; +int +ktest_equal_checksum(krb5_checksum *ref, krb5_checksum *var) { - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; return(scalar_equal(checksum_type) && len_equal(length,contents,ktest_equal_array_of_octet)); } -int ktest_equal_keyblock(ref, var) - krb5_keyblock * ref; - krb5_keyblock * var; +int +ktest_equal_keyblock(krb5_keyblock *ref, krb5_keyblock *var) { - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; return(scalar_equal(enctype) && len_equal(length,contents,ktest_equal_array_of_octet)); } -int ktest_equal_data(ref, var) - krb5_data * ref; - krb5_data * var; +int +ktest_equal_data(krb5_data *ref, krb5_data *var) { - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; return(len_equal(length,data,ktest_equal_array_of_char)); } -int ktest_equal_ticket(ref, var) - krb5_ticket * ref; - krb5_ticket * var; +int +ktest_equal_ticket(krb5_ticket *ref, krb5_ticket *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; p = p && ptr_equal(server,ktest_equal_principal_data); p = p && struct_equal(enc_part,ktest_equal_enc_data); @@ -122,37 +116,34 @@ int ktest_equal_ticket(ref, var) return p; } -int ktest_equal_enc_data(ref, var) - krb5_enc_data * ref; - krb5_enc_data * var; +int +ktest_equal_enc_data(krb5_enc_data *ref, krb5_enc_data *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(enctype); - p=p&&scalar_equal(kvno); - p=p&&struct_equal(ciphertext,ktest_equal_data); + p = p && scalar_equal(enctype); + p = p && scalar_equal(kvno); + p = p && struct_equal(ciphertext,ktest_equal_data); return p; } -int ktest_equal_encryption_key(ref, var) - krb5_keyblock * ref; - krb5_keyblock * var; +int +ktest_equal_encryption_key(krb5_keyblock *ref, krb5_keyblock *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; p = p && scalar_equal(enctype); p = p && len_equal(length,contents,ktest_equal_array_of_octet); return p; } -int ktest_equal_enc_tkt_part(ref, var) - krb5_enc_tkt_part * ref; - krb5_enc_tkt_part * var; +int +ktest_equal_enc_tkt_part(krb5_enc_tkt_part *ref, krb5_enc_tkt_part *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; p = p && scalar_equal(flags); p = p && ptr_equal(session,ktest_equal_encryption_key); @@ -164,24 +155,22 @@ int ktest_equal_enc_tkt_part(ref, var) return p; } -int ktest_equal_transited(ref, var) - krb5_transited * ref; - krb5_transited * var; +int +ktest_equal_transited(krb5_transited *ref, krb5_transited *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; p = p && scalar_equal(tr_type); p = p && struct_equal(tr_contents,ktest_equal_data); return p; } -int ktest_equal_ticket_times(ref, var) - krb5_ticket_times * ref; - krb5_ticket_times * var; +int +ktest_equal_ticket_times(krb5_ticket_times *ref, krb5_ticket_times *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; p = p && scalar_equal(authtime); p = p && scalar_equal(starttime); @@ -190,310 +179,291 @@ int ktest_equal_ticket_times(ref, var) return p; } -int ktest_equal_address(ref, var) - krb5_address * ref; - krb5_address * var; +int +ktest_equal_address(krb5_address *ref, krb5_address *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(addrtype); - p=p&&len_equal(length,contents,ktest_equal_array_of_octet); + p = p && scalar_equal(addrtype); + p = p && len_equal(length,contents,ktest_equal_array_of_octet); return p; } -int ktest_equal_enc_kdc_rep_part(ref, var) - krb5_enc_kdc_rep_part * ref; - krb5_enc_kdc_rep_part * var; +int +ktest_equal_enc_kdc_rep_part(krb5_enc_kdc_rep_part *ref, + krb5_enc_kdc_rep_part *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&ptr_equal(session,ktest_equal_keyblock); - p=p&&ptr_equal(last_req,ktest_equal_last_req); - p=p&&scalar_equal(nonce); - p=p&&scalar_equal(key_exp); - p=p&&scalar_equal(flags); - p=p&&struct_equal(times,ktest_equal_ticket_times); - p=p&&ptr_equal(server,ktest_equal_principal_data); - p=p&&ptr_equal(caddrs,ktest_equal_addresses); + p = p && ptr_equal(session,ktest_equal_keyblock); + p = p && ptr_equal(last_req,ktest_equal_last_req); + p = p && scalar_equal(nonce); + p = p && scalar_equal(key_exp); + p = p && scalar_equal(flags); + p = p && struct_equal(times,ktest_equal_ticket_times); + p = p && ptr_equal(server,ktest_equal_principal_data); + p = p && ptr_equal(caddrs,ktest_equal_addresses); return p; } -int ktest_equal_priv(ref, var) - krb5_priv * ref; - krb5_priv * var; +int +ktest_equal_priv(krb5_priv *ref, krb5_priv *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(enc_part,ktest_equal_enc_data); + p = p && struct_equal(enc_part,ktest_equal_enc_data); return p; } -int ktest_equal_cred(ref, var) - krb5_cred * ref; - krb5_cred * var; +int +ktest_equal_cred(krb5_cred *ref, krb5_cred *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&ptr_equal(tickets,ktest_equal_sequence_of_ticket); - p=p&&struct_equal(enc_part,ktest_equal_enc_data); + p = p && ptr_equal(tickets,ktest_equal_sequence_of_ticket); + p = p && struct_equal(enc_part,ktest_equal_enc_data); return p; } -int ktest_equal_error(ref, var) - krb5_error * ref; - krb5_error * var; +int +ktest_equal_error(krb5_error *ref, krb5_error *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(ctime); - p=p&&scalar_equal(cusec); - p=p&&scalar_equal(susec); - p=p&&scalar_equal(stime); - p=p&&scalar_equal(error); - p=p&&ptr_equal(client,ktest_equal_principal_data); - p=p&&ptr_equal(server,ktest_equal_principal_data); - p=p&&struct_equal(text,ktest_equal_data); - p=p&&struct_equal(e_data,ktest_equal_data); + p = p && scalar_equal(ctime); + p = p && scalar_equal(cusec); + p = p && scalar_equal(susec); + p = p && scalar_equal(stime); + p = p && scalar_equal(error); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && ptr_equal(server,ktest_equal_principal_data); + p = p && struct_equal(text,ktest_equal_data); + p = p && struct_equal(e_data,ktest_equal_data); return p; } -int ktest_equal_ap_req(ref, var) - krb5_ap_req * ref; - krb5_ap_req * var; +int +ktest_equal_ap_req(krb5_ap_req *ref, krb5_ap_req *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(ap_options); - p=p&&ptr_equal(ticket,ktest_equal_ticket); - p=p&&struct_equal(authenticator,ktest_equal_enc_data); + p = p && scalar_equal(ap_options); + p = p && ptr_equal(ticket,ktest_equal_ticket); + p = p && struct_equal(authenticator,ktest_equal_enc_data); return p; } -int ktest_equal_ap_rep(ref, var) - krb5_ap_rep * ref; - krb5_ap_rep * var; +int +ktest_equal_ap_rep(krb5_ap_rep *ref, krb5_ap_rep *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(enc_part,ktest_equal_enc_data); + p = p && struct_equal(enc_part,ktest_equal_enc_data); return p; } -int ktest_equal_ap_rep_enc_part(ref, var) - krb5_ap_rep_enc_part * ref; - krb5_ap_rep_enc_part * var; +int +ktest_equal_ap_rep_enc_part(krb5_ap_rep_enc_part *ref, + krb5_ap_rep_enc_part *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(ctime); - p=p&&scalar_equal(cusec); - p=p&&ptr_equal(subkey,ktest_equal_encryption_key); - p=p&&scalar_equal(seq_number); + p = p && scalar_equal(ctime); + p = p && scalar_equal(cusec); + p = p && ptr_equal(subkey,ktest_equal_encryption_key); + p = p && scalar_equal(seq_number); return p; } -int ktest_equal_safe(ref, var) - krb5_safe * ref; - krb5_safe * var; +int +ktest_equal_safe(krb5_safe *ref, krb5_safe *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(user_data,ktest_equal_data); - p=p&&scalar_equal(timestamp); - p=p&&scalar_equal(usec); - p=p&&scalar_equal(seq_number); - p=p&&ptr_equal(s_address,ktest_equal_address); - p=p&&ptr_equal(r_address,ktest_equal_address); - p=p&&ptr_equal(checksum,ktest_equal_checksum); + p = p && struct_equal(user_data,ktest_equal_data); + p = p && scalar_equal(timestamp); + p = p && scalar_equal(usec); + p = p && scalar_equal(seq_number); + p = p && ptr_equal(s_address,ktest_equal_address); + p = p && ptr_equal(r_address,ktest_equal_address); + p = p && ptr_equal(checksum,ktest_equal_checksum); return p; } -int ktest_equal_enc_cred_part(ref, var) - krb5_cred_enc_part * ref; - krb5_cred_enc_part * var; +int +ktest_equal_enc_cred_part(krb5_cred_enc_part *ref, krb5_cred_enc_part *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(nonce); - p=p&&scalar_equal(timestamp); - p=p&&scalar_equal(usec); - p=p&&ptr_equal(s_address,ktest_equal_address); - p=p&&ptr_equal(r_address,ktest_equal_address); - p=p&&ptr_equal(ticket_info,ktest_equal_sequence_of_cred_info); + p = p && scalar_equal(nonce); + p = p && scalar_equal(timestamp); + p = p && scalar_equal(usec); + p = p && ptr_equal(s_address,ktest_equal_address); + p = p && ptr_equal(r_address,ktest_equal_address); + p = p && ptr_equal(ticket_info,ktest_equal_sequence_of_cred_info); return p; } -int ktest_equal_enc_priv_part(ref, var) - krb5_priv_enc_part * ref; - krb5_priv_enc_part * var; +int +ktest_equal_enc_priv_part(krb5_priv_enc_part *ref, krb5_priv_enc_part *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(user_data,ktest_equal_data); - p=p&&scalar_equal(timestamp); - p=p&&scalar_equal(usec); - p=p&&scalar_equal(seq_number); - p=p&&ptr_equal(s_address,ktest_equal_address); - p=p&&ptr_equal(r_address,ktest_equal_address); + p = p && struct_equal(user_data,ktest_equal_data); + p = p && scalar_equal(timestamp); + p = p && scalar_equal(usec); + p = p && scalar_equal(seq_number); + p = p && ptr_equal(s_address,ktest_equal_address); + p = p && ptr_equal(r_address,ktest_equal_address); return p; } -int ktest_equal_as_rep(ref, var) - krb5_kdc_rep * ref; - krb5_kdc_rep * var; +int +ktest_equal_as_rep(krb5_kdc_rep *ref, krb5_kdc_rep *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(msg_type); - p=p&&ptr_equal(padata,ktest_equal_sequence_of_pa_data); - p=p&&ptr_equal(client,ktest_equal_principal_data); - p=p&&ptr_equal(ticket,ktest_equal_ticket); - p=p&&struct_equal(enc_part,ktest_equal_enc_data); - p=p&&ptr_equal(enc_part2,ktest_equal_enc_kdc_rep_part); + p = p && scalar_equal(msg_type); + p = p && ptr_equal(padata,ktest_equal_sequence_of_pa_data); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && ptr_equal(ticket,ktest_equal_ticket); + p = p && struct_equal(enc_part,ktest_equal_enc_data); + p = p && ptr_equal(enc_part2,ktest_equal_enc_kdc_rep_part); return p; } -int ktest_equal_tgs_rep(ref, var) - krb5_kdc_rep * ref; - krb5_kdc_rep * var; +int +ktest_equal_tgs_rep(krb5_kdc_rep *ref, krb5_kdc_rep *var) { return ktest_equal_as_rep(ref,var); } -int ktest_equal_as_req(ref, var) - krb5_kdc_req * ref; - krb5_kdc_req * var; -{ - int p=TRUE; - if (ref==var) return TRUE; - else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(msg_type); - p=p&&ptr_equal(padata,ktest_equal_sequence_of_pa_data); - p=p&&scalar_equal(kdc_options); - p=p&&ptr_equal(client,ktest_equal_principal_data); - p=p&&ptr_equal(server,ktest_equal_principal_data); - p=p&&scalar_equal(from); - p=p&&scalar_equal(till); - p=p&&scalar_equal(rtime); - p=p&&scalar_equal(nonce); - p=p&&len_equal(nktypes,ktype,ktest_equal_array_of_enctype); - p=p&&ptr_equal(addresses,ktest_equal_addresses); - p=p&&struct_equal(authorization_data,ktest_equal_enc_data); +int +ktest_equal_as_req(krb5_kdc_req *ref, krb5_kdc_req *var) +{ + int p = TRUE; + if (ref == var) return TRUE; + else if (ref == NULL || var == NULL) return FALSE; + p = p && scalar_equal(msg_type); + p = p && ptr_equal(padata,ktest_equal_sequence_of_pa_data); + p = p && scalar_equal(kdc_options); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && ptr_equal(server,ktest_equal_principal_data); + p = p && scalar_equal(from); + p = p && scalar_equal(till); + p = p && scalar_equal(rtime); + p = p && scalar_equal(nonce); + p = p && len_equal(nktypes,ktype,ktest_equal_array_of_enctype); + p = p && ptr_equal(addresses,ktest_equal_addresses); + p = p && struct_equal(authorization_data,ktest_equal_enc_data); /* This field isn't actually in the ASN.1 encoding. */ -/* p=p&&ptr_equal(unenc_authdata,ktest_equal_authorization_data); */ +/* p = p && ptr_equal(unenc_authdata,ktest_equal_authorization_data); */ return p; } -int ktest_equal_tgs_req(ref, var) - krb5_kdc_req * ref; - krb5_kdc_req * var; +int +ktest_equal_tgs_req(krb5_kdc_req *ref, krb5_kdc_req *var) { return ktest_equal_as_req(ref,var); } -int ktest_equal_kdc_req_body(ref, var) - krb5_kdc_req * ref; - krb5_kdc_req * var; +int +ktest_equal_kdc_req_body(krb5_kdc_req *ref, krb5_kdc_req *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(kdc_options); - p=p&&ptr_equal(client,ktest_equal_principal_data); - p=p&&ptr_equal(server,ktest_equal_principal_data); - p=p&&scalar_equal(from); - p=p&&scalar_equal(till); - p=p&&scalar_equal(rtime); - p=p&&scalar_equal(nonce); - p=p&&len_equal(nktypes,ktype,ktest_equal_array_of_enctype); - p=p&&ptr_equal(addresses,ktest_equal_addresses); - p=p&&struct_equal(authorization_data,ktest_equal_enc_data); + p = p && scalar_equal(kdc_options); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && ptr_equal(server,ktest_equal_principal_data); + p = p && scalar_equal(from); + p = p && scalar_equal(till); + p = p && scalar_equal(rtime); + p = p && scalar_equal(nonce); + p = p && len_equal(nktypes,ktype,ktest_equal_array_of_enctype); + p = p && ptr_equal(addresses,ktest_equal_addresses); + p = p && struct_equal(authorization_data,ktest_equal_enc_data); /* This isn't part of the ASN.1 encoding. */ - /* p=p&&ptr_equal(unenc_authdata,ktest_equal_authorization_data); */ + /* p = p && ptr_equal(unenc_authdata,ktest_equal_authorization_data); */ return p; } -int ktest_equal_last_req_entry(ref, var) - krb5_last_req_entry * ref; - krb5_last_req_entry * var; +int +ktest_equal_last_req_entry(krb5_last_req_entry *ref, krb5_last_req_entry *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(lr_type); - p=p&&scalar_equal(value); + p = p && scalar_equal(lr_type); + p = p && scalar_equal(value); return p; } -int ktest_equal_pa_data(ref, var) - krb5_pa_data * ref; - krb5_pa_data * var; +int +ktest_equal_pa_data(krb5_pa_data *ref, krb5_pa_data *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(pa_type); - p=p&&len_equal(length,contents,ktest_equal_array_of_octet); + p = p && scalar_equal(pa_type); + p = p && len_equal(length,contents,ktest_equal_array_of_octet); return p; } -int ktest_equal_cred_info(ref, var) - krb5_cred_info * ref; - krb5_cred_info * var; +int +ktest_equal_cred_info(krb5_cred_info *ref, krb5_cred_info *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&ptr_equal(session,ktest_equal_keyblock); - p=p&&ptr_equal(client,ktest_equal_principal_data); - p=p&&ptr_equal(server,ktest_equal_principal_data); - p=p&&scalar_equal(flags); - p=p&&struct_equal(times,ktest_equal_ticket_times); - p=p&&ptr_equal(caddrs,ktest_equal_addresses); + p = p && ptr_equal(session,ktest_equal_keyblock); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && ptr_equal(server,ktest_equal_principal_data); + p = p && scalar_equal(flags); + p = p && struct_equal(times,ktest_equal_ticket_times); + p = p && ptr_equal(caddrs,ktest_equal_addresses); return p; } -int ktest_equal_passwd_phrase_element(ref, var) - passwd_phrase_element * ref; - passwd_phrase_element * var; +int +ktest_equal_passwd_phrase_element(passwd_phrase_element *ref, + passwd_phrase_element *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&ptr_equal(passwd,ktest_equal_data); - p=p&&ptr_equal(phrase,ktest_equal_data); + p = p && ptr_equal(passwd,ktest_equal_data); + p = p && ptr_equal(phrase,ktest_equal_data); return p; } -int ktest_equal_krb5_pwd_data(ref, var) - krb5_pwd_data * ref; - krb5_pwd_data * var; +int +ktest_equal_krb5_pwd_data(krb5_pwd_data *ref, krb5_pwd_data *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(sequence_count); - p=p&&ptr_equal(element,ktest_equal_array_of_passwd_phrase_element); + p = p && scalar_equal(sequence_count); + p = p && ptr_equal(element,ktest_equal_array_of_passwd_phrase_element); return p; } -int ktest_equal_krb5_alt_method(ref, var) - krb5_alt_method *ref; - krb5_alt_method *var; +int +ktest_equal_krb5_alt_method(krb5_alt_method *ref, krb5_alt_method *var) { if (ref->method != var->method) return FALSE; @@ -504,9 +474,9 @@ int ktest_equal_krb5_alt_method(ref, var) return TRUE; } -int ktest_equal_krb5_etype_info_entry(ref, var) - krb5_etype_info_entry *ref; - krb5_etype_info_entry *var; +int +ktest_equal_krb5_etype_info_entry(krb5_etype_info_entry *ref, + krb5_etype_info_entry *var) { if (ref->etype != var->etype) return FALSE; @@ -518,185 +488,179 @@ int ktest_equal_krb5_etype_info_entry(ref, var) return TRUE; } -int ktest_equal_krb5_pa_enc_ts(ref, var) - krb5_pa_enc_ts *ref; - krb5_pa_enc_ts *var; +int +ktest_equal_krb5_pa_enc_ts(krb5_pa_enc_ts *ref, krb5_pa_enc_ts *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(patimestamp); - p=p&&scalar_equal(pausec); + p = p && scalar_equal(patimestamp); + p = p && scalar_equal(pausec); return p; } #define equal_str(f) struct_equal(f,ktest_equal_data) -int ktest_equal_sam_challenge(ref, var) - krb5_sam_challenge *ref; - krb5_sam_challenge *var; +int +ktest_equal_sam_challenge(krb5_sam_challenge *ref, krb5_sam_challenge *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(sam_type); - p=p&&scalar_equal(sam_flags); - p=p&&scalar_equal(sam_nonce); - p=p&&ktest_equal_checksum(&ref->sam_cksum,&var->sam_cksum); - p=p&&equal_str(sam_track_id); - p=p&&equal_str(sam_challenge_label); - p=p&&equal_str(sam_challenge); - p=p&&equal_str(sam_response_prompt); - p=p&&equal_str(sam_pk_for_sad); + p = p && scalar_equal(sam_type); + p = p && scalar_equal(sam_flags); + p = p && scalar_equal(sam_nonce); + p = p && ktest_equal_checksum(&ref->sam_cksum,&var->sam_cksum); + p = p && equal_str(sam_track_id); + p = p && equal_str(sam_challenge_label); + p = p && equal_str(sam_challenge); + p = p && equal_str(sam_response_prompt); + p = p && equal_str(sam_pk_for_sad); return p; } -int ktest_equal_sam_response(ref, var) - krb5_sam_response *ref; - krb5_sam_response *var; +int +ktest_equal_sam_response(krb5_sam_response *ref, krb5_sam_response *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(sam_type); - p=p&&scalar_equal(sam_flags); - p=p&&equal_str(sam_track_id); - p=p&&struct_equal(sam_enc_key,ktest_equal_enc_data); - p=p&&struct_equal(sam_enc_nonce_or_ts,ktest_equal_enc_data); - p=p&&scalar_equal(sam_nonce); - p=p&&scalar_equal(sam_patimestamp); + p = p && scalar_equal(sam_type); + p = p && scalar_equal(sam_flags); + p = p && equal_str(sam_track_id); + p = p && struct_equal(sam_enc_key,ktest_equal_enc_data); + p = p && struct_equal(sam_enc_nonce_or_ts,ktest_equal_enc_data); + p = p && scalar_equal(sam_nonce); + p = p && scalar_equal(sam_patimestamp); return p; } -int ktest_equal_pa_s4u_x509_user(ref, var) - krb5_pa_s4u_x509_user *ref; - krb5_pa_s4u_x509_user *var; +int +ktest_equal_pa_s4u_x509_user(krb5_pa_s4u_x509_user *ref, + krb5_pa_s4u_x509_user *var) { int p = TRUE; if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(user_id.nonce); - p=p&&ptr_equal(user_id.user,ktest_equal_principal_data); - p=p&&struct_equal(user_id.subject_cert,ktest_equal_data); - p=p&&scalar_equal(user_id.options); - p=p&&struct_equal(cksum,ktest_equal_checksum); + p = p && scalar_equal(user_id.nonce); + p = p && ptr_equal(user_id.user,ktest_equal_principal_data); + p = p && struct_equal(user_id.subject_cert,ktest_equal_data); + p = p && scalar_equal(user_id.options); + p = p && struct_equal(cksum,ktest_equal_checksum); return p; } -int ktest_equal_ad_kdcissued(ref, var) - krb5_ad_kdcissued *ref; - krb5_ad_kdcissued *var; +int +ktest_equal_ad_kdcissued(krb5_ad_kdcissued *ref, krb5_ad_kdcissued *var) { int p = TRUE; if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(ad_checksum,ktest_equal_checksum); - p=p&&ptr_equal(i_principal,ktest_equal_principal_data); - p=p&&ptr_equal(elements,ktest_equal_authorization_data); + p = p && struct_equal(ad_checksum,ktest_equal_checksum); + p = p && ptr_equal(i_principal,ktest_equal_principal_data); + p = p && ptr_equal(elements,ktest_equal_authorization_data); return p; } -int ktest_equal_ad_signedpath_data(ref, var) - krb5_ad_signedpath_data *ref; - krb5_ad_signedpath_data *var; +int +ktest_equal_ad_signedpath_data(krb5_ad_signedpath_data *ref, + krb5_ad_signedpath_data *var) { int p = TRUE; if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&ptr_equal(client,ktest_equal_principal_data); - p=p&&scalar_equal(authtime); - p=p&&ptr_equal(delegated,ktest_equal_sequence_of_principal); - p=p&&ptr_equal(method_data,ktest_equal_sequence_of_pa_data); - p=p&&ptr_equal(authorization_data,ktest_equal_authorization_data); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && scalar_equal(authtime); + p = p && ptr_equal(delegated,ktest_equal_sequence_of_principal); + p = p && ptr_equal(method_data,ktest_equal_sequence_of_pa_data); + p = p && ptr_equal(authorization_data,ktest_equal_authorization_data); return p; } -int ktest_equal_ad_signedpath(ref, var) - krb5_ad_signedpath* ref; - krb5_ad_signedpath* var; +int +ktest_equal_ad_signedpath(krb5_ad_signedpath *ref, krb5_ad_signedpath *var) { int p = TRUE; if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(enctype); - p=p&&struct_equal(checksum,ktest_equal_checksum); - p=p&&ptr_equal(delegated,ktest_equal_sequence_of_principal); - p=p&&ptr_equal(method_data,ktest_equal_sequence_of_pa_data); + p = p && scalar_equal(enctype); + p = p && struct_equal(checksum,ktest_equal_checksum); + p = p && ptr_equal(delegated,ktest_equal_sequence_of_principal); + p = p && ptr_equal(method_data,ktest_equal_sequence_of_pa_data); return p; } -int ktest_equal_iakerb_header(ref, var) - krb5_iakerb_header *ref; - krb5_iakerb_header *var; +int +ktest_equal_iakerb_header(krb5_iakerb_header *ref, krb5_iakerb_header *var) { int p = TRUE; if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(target_realm,ktest_equal_data); - p=p&&ptr_equal(cookie,ktest_equal_data); + p = p && struct_equal(target_realm,ktest_equal_data); + p = p && ptr_equal(cookie,ktest_equal_data); return p; } -int ktest_equal_iakerb_finished(ref, var) - krb5_iakerb_finished *ref; - krb5_iakerb_finished *var; +int +ktest_equal_iakerb_finished(krb5_iakerb_finished *ref, + krb5_iakerb_finished *var) { int p = TRUE; if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&struct_equal(checksum,ktest_equal_checksum); + p = p && struct_equal(checksum,ktest_equal_checksum); return p; } #ifdef ENABLE_LDAP -static int equal_key_data(ref, var) - krb5_key_data *ref; - krb5_key_data *var; -{ - int p=TRUE; - if (ref==var) return TRUE; - else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(key_data_ver); - p=p&&scalar_equal(key_data_kvno); - p=p&&scalar_equal(key_data_type[0]); - p=p&&scalar_equal(key_data_type[1]); - p=p&&len_equal(key_data_length[0],key_data_contents[0], +static int +equal_key_data(krb5_key_data *ref, krb5_key_data *var) +{ + int p = TRUE; + if (ref == var) return TRUE; + else if (ref == NULL || var == NULL) return FALSE; + p = p && scalar_equal(key_data_ver); + p = p && scalar_equal(key_data_kvno); + p = p && scalar_equal(key_data_type[0]); + p = p && scalar_equal(key_data_type[1]); + p = p && len_equal(key_data_length[0],key_data_contents[0], ktest_equal_array_of_octet); - p=p&&len_equal(key_data_length[1],key_data_contents[1], + p = p && len_equal(key_data_length[1],key_data_contents[1], ktest_equal_array_of_octet); return p; } -static int equal_key_data_array(int n, krb5_key_data *ref, krb5_key_data *val) + +static int +equal_key_data_array(int n, krb5_key_data *ref, krb5_key_data *val) { - int i, p=TRUE; + int i, p = TRUE; for (i = 0; i < n; i++) { - p=p&&equal_key_data(ref+i, val+i); + p = p && equal_key_data(ref+i, val+i); } return p; } -int ktest_equal_ldap_sequence_of_keys(ref, var) - ldap_seqof_key_data *ref; - ldap_seqof_key_data *var; + +int +ktest_equal_ldap_sequence_of_keys(ldap_seqof_key_data *ref, + ldap_seqof_key_data *var) { - int p=TRUE; - if (ref==var) return TRUE; + int p = TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; - p=p&&scalar_equal(mkvno); - p=p&&len_equal(n_key_data,key_data,equal_key_data_array); + p = p && scalar_equal(mkvno); + p = p && len_equal(n_key_data,key_data,equal_key_data_array); return p; } #endif /**** arrays ****************************************************************/ -int ktest_equal_array_of_data(length, ref, var) - const int length; - krb5_data * ref; - krb5_data * var; +int +ktest_equal_array_of_data(int length, krb5_data *ref, krb5_data *var) { - int i,p=TRUE; + int i,p = TRUE; - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; for (i=0; i<(length); i++) { p = p && ktest_equal_data(&(ref[i]),&(var[i])); @@ -704,42 +668,37 @@ int ktest_equal_array_of_data(length, ref, var) return p; } -int ktest_equal_array_of_octet(length, ref, var) - const unsigned int length; - krb5_octet * ref; - krb5_octet * var; +int +ktest_equal_array_of_octet(unsigned int length, krb5_octet *ref, + krb5_octet *var) { - unsigned int i, p=TRUE; + unsigned int i, p = TRUE; - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; for (i=0; i<length; i++) p = p && (ref[i] == var[i]); return p; } -int ktest_equal_array_of_char(length, ref, var) - const unsigned int length; - char * ref; - char * var; +int +ktest_equal_array_of_char(unsigned int length, char *ref, char *var) { - unsigned int i, p=TRUE; + unsigned int i, p = TRUE; - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; for (i=0; i<length; i++) p = p && (ref[i] == var[i]); return p; } -int ktest_equal_array_of_enctype(length, ref, var) - const int length; - krb5_enctype * ref; - krb5_enctype * var; +int +ktest_equal_array_of_enctype(int length, krb5_enctype *ref, krb5_enctype *var) { - int i, p=TRUE; + int i, p = TRUE; - if (ref==var) return TRUE; + if (ref == var) return TRUE; else if (ref == NULL || var == NULL) return FALSE; for (i=0; i<length; i++) p = p && (ref[i] == var[i]); @@ -747,8 +706,8 @@ int ktest_equal_array_of_enctype(length, ref, var) } #define array_compare(comparator) \ - int i,p=TRUE; \ - if (ref==var) return TRUE; \ + int i,p = TRUE; \ + if (ref == var) return TRUE; \ if (!ref || !ref[0]) \ return (!var || !var[0]); \ if (!var || !var[0]) return FALSE; \ @@ -757,65 +716,56 @@ int ktest_equal_array_of_enctype(length, ref, var) if (ref[i] == NULL && var[i] == NULL) return p; \ else return FALSE -int ktest_equal_authorization_data(ref, var) - krb5_authdata ** ref; - krb5_authdata ** var; +int +ktest_equal_authorization_data(krb5_authdata **ref, krb5_authdata **var) { array_compare(ktest_equal_authdata); } -int ktest_equal_addresses(ref, var) - krb5_address ** ref; - krb5_address ** var; +int +ktest_equal_addresses(krb5_address **ref, krb5_address **var) { array_compare(ktest_equal_address); } -int ktest_equal_last_req(ref, var) - krb5_last_req_entry ** ref; - krb5_last_req_entry ** var; +int +ktest_equal_last_req(krb5_last_req_entry **ref, krb5_last_req_entry **var) { array_compare(ktest_equal_last_req_entry); } -int ktest_equal_sequence_of_ticket(ref, var) - krb5_ticket ** ref; - krb5_ticket ** var; +int +ktest_equal_sequence_of_ticket(krb5_ticket **ref, krb5_ticket **var) { array_compare(ktest_equal_ticket); } -int ktest_equal_sequence_of_pa_data(ref, var) - krb5_pa_data ** ref; - krb5_pa_data ** var; +int +ktest_equal_sequence_of_pa_data(krb5_pa_data **ref, krb5_pa_data **var) { array_compare(ktest_equal_pa_data); } -int ktest_equal_sequence_of_cred_info(ref, var) - krb5_cred_info ** ref; - krb5_cred_info ** var; +int +ktest_equal_sequence_of_cred_info(krb5_cred_info **ref, krb5_cred_info **var) { array_compare(ktest_equal_cred_info); } -int ktest_equal_sequence_of_principal(ref, var) - krb5_principal * ref; - krb5_principal * var; +int +ktest_equal_sequence_of_principal(krb5_principal *ref, krb5_principal *var) { array_compare(ktest_equal_principal_data); } -int ktest_equal_array_of_passwd_phrase_element(ref, var) - passwd_phrase_element ** ref; - passwd_phrase_element ** var; +int +ktest_equal_array_of_passwd_phrase_element(passwd_phrase_element **ref, passwd_phrase_element **var) { array_compare(ktest_equal_passwd_phrase_element); } -int ktest_equal_etype_info(ref, var) - krb5_etype_info_entry ** ref; - krb5_etype_info_entry ** var; +int +ktest_equal_etype_info(krb5_etype_info_entry **ref, krb5_etype_info_entry **var) { array_compare(ktest_equal_krb5_etype_info_entry); } diff --git a/src/tests/asn.1/ktest_equal.h b/src/tests/asn.1/ktest_equal.h index 8d4a6e810b..ee90f4ff4f 100644 --- a/src/tests/asn.1/ktest_equal.h +++ b/src/tests/asn.1/ktest_equal.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* tests/asn.1/ktest_equal.h */ /* * Copyright (C) 1994 by the Massachusetts Institute of Technology. @@ -32,16 +33,16 @@ /* int ktest_equal_structure(krb5_structure *ref, *var) */ /* effects Returns true (non-zero) if ref and var are semantically equivalent (i.e. have the same values, - but aren't necessarily the same object). - Returns false (zero) if ref and var differ. */ + but aren't necessarily the same object). + Returns false (zero) if ref and var differ. */ #define generic(funcname,type)\ int funcname (type *ref, type *var) #define len_array(funcname,type)\ -int funcname (const int length, type *ref, type *var) +int funcname (int length, type *ref, type *var) #define len_unsigned_array(funcname,type)\ -int funcname (const unsigned int length, type *ref, type *var) +int funcname (unsigned int length, type *ref, type *var) generic(ktest_equal_authenticator,krb5_authenticator); generic(ktest_equal_principal_data,krb5_principal_data); @@ -86,58 +87,41 @@ generic(ktest_equal_krb5_pa_enc_ts,krb5_pa_enc_ts); generic(ktest_equal_sam_challenge,krb5_sam_challenge); generic(ktest_equal_sam_response,krb5_sam_response); -int ktest_equal_last_req - (krb5_last_req_entry **ref, krb5_last_req_entry **var); -int ktest_equal_sequence_of_ticket - (krb5_ticket **ref, krb5_ticket **var); -int ktest_equal_sequence_of_pa_data - (krb5_pa_data **ref, krb5_pa_data **var); -int ktest_equal_sequence_of_cred_info - (krb5_cred_info **ref, krb5_cred_info **var); -int ktest_equal_sequence_of_principal - (krb5_principal *ref, krb5_principal *var); +int ktest_equal_last_req(krb5_last_req_entry **ref, krb5_last_req_entry **var); +int ktest_equal_sequence_of_ticket(krb5_ticket **ref, krb5_ticket **var); +int ktest_equal_sequence_of_pa_data(krb5_pa_data **ref, krb5_pa_data **var); +int ktest_equal_sequence_of_cred_info(krb5_cred_info **ref, + krb5_cred_info **var); +int ktest_equal_sequence_of_principal(krb5_principal *ref, + krb5_principal *var); len_array(ktest_equal_array_of_enctype,krb5_enctype); len_array(ktest_equal_array_of_data,krb5_data); len_unsigned_array(ktest_equal_array_of_octet,krb5_octet); -int ktest_equal_array_of_passwd_phrase_element - (passwd_phrase_element **ref, passwd_phrase_element **var); -int ktest_equal_authorization_data - (krb5_authdata **ref, krb5_authdata **var); -int ktest_equal_addresses - (krb5_address **ref, krb5_address **var); -int ktest_equal_array_of_char - (const unsigned int length, char *ref, char *var); - -int ktest_equal_etype_info - (krb5_etype_info_entry ** ref, - krb5_etype_info_entry ** var); - -int ktest_equal_krb5_etype_info_entry - (krb5_etype_info_entry * ref, - krb5_etype_info_entry * var); - -int ktest_equal_pa_s4u_x509_user - (krb5_pa_s4u_x509_user *ref, - krb5_pa_s4u_x509_user *var); - -int ktest_equal_ad_kdcissued - (krb5_ad_kdcissued *ref, - krb5_ad_kdcissued *var); -int ktest_equal_ad_signedpath_data - (krb5_ad_signedpath_data *ref, - krb5_ad_signedpath_data *var); -int ktest_equal_ad_signedpath - (krb5_ad_signedpath *ref, - krb5_ad_signedpath *var); -int ktest_equal_iakerb_header - (krb5_iakerb_header *ref, - krb5_iakerb_header *var); -int ktest_equal_iakerb_finished - (krb5_iakerb_finished *ref, - krb5_iakerb_finished *var); +int ktest_equal_array_of_passwd_phrase_element(passwd_phrase_element **ref, + passwd_phrase_element **var); +int ktest_equal_authorization_data(krb5_authdata **ref, krb5_authdata **var); +int ktest_equal_addresses(krb5_address **ref, krb5_address **var); +int ktest_equal_array_of_char(const unsigned int length, char *ref, char *var); + +int ktest_equal_etype_info(krb5_etype_info_entry **ref, + krb5_etype_info_entry **var); + +int ktest_equal_krb5_etype_info_entry(krb5_etype_info_entry *ref, + krb5_etype_info_entry *var); +int ktest_equal_pa_s4u_x509_user(krb5_pa_s4u_x509_user *ref, + krb5_pa_s4u_x509_user *var); +int ktest_equal_ad_kdcissued(krb5_ad_kdcissued *ref, krb5_ad_kdcissued *var); +int ktest_equal_ad_signedpath_data(krb5_ad_signedpath_data *ref, + krb5_ad_signedpath_data *var); +int ktest_equal_ad_signedpath(krb5_ad_signedpath *ref, + krb5_ad_signedpath *var); +int ktest_equal_iakerb_header(krb5_iakerb_header *ref, + krb5_iakerb_header *var); +int ktest_equal_iakerb_finished(krb5_iakerb_finished *ref, + krb5_iakerb_finished *var); int ktest_equal_ldap_sequence_of_keys(ldap_seqof_key_data *ref, - ldap_seqof_key_data *var); + ldap_seqof_key_data *var); #endif diff --git a/src/tests/asn.1/utility.c b/src/tests/asn.1/utility.c index 8f852d8d82..db1a9c09f8 100644 --- a/src/tests/asn.1/utility.c +++ b/src/tests/asn.1/utility.c @@ -34,23 +34,39 @@ krb5int_access acc; char hexchar (const unsigned int digit); -asn1_error_code asn1_krb5_data_unparse(code, s) - const krb5_data * code; - char ** s; +void * +ealloc(size_t size) +{ + void *ptr = calloc(1, size); + + if (ptr == NULL) + abort(); + return ptr; +} + +char * +estrdup(const char *str) +{ + char *newstr = strdup(str); + + if (newstr == NULL) + abort(); + return newstr; +} + +void +asn1_krb5_data_unparse(const krb5_data *code, char **s) { if (*s != NULL) free(*s); if (code==NULL) { - *s = strdup("<NULL>"); - if (*s == NULL) return ENOMEM; + *s = estrdup("<NULL>"); } else if (code->data == NULL || ((int) code->length) <= 0) { - *s = strdup("<EMPTY>"); - if (*s==NULL) return ENOMEM; + *s = estrdup("<EMPTY>"); } else { unsigned int i; - *s = (char*)calloc((size_t) 3*(code->length), sizeof(char)); - if (*s == NULL) return ENOMEM; + *s = ealloc(3 * code->length); for (i = 0; i < code->length; i++) { (*s)[3*i] = hexchar((unsigned char) (((code->data)[i]&0xF0)>>4)); (*s)[3*i+1] = hexchar((unsigned char) ((code->data)[i]&0x0F)); @@ -58,11 +74,10 @@ asn1_error_code asn1_krb5_data_unparse(code, s) } (*s)[3*(code->length)-1] = '\0'; } - return 0; } -char hexchar(digit) - const unsigned int digit; +char +hexchar(const unsigned int digit) { if (digit<=9) return '0'+digit; @@ -72,22 +87,16 @@ char hexchar(digit) return 'X'; } -krb5_error_code krb5_data_parse(d, s) - krb5_data * d; - const char * s; +void +krb5_data_parse(krb5_data *d, const char *s) { - /*if (d->data != NULL) { - free(d->data); - d->length = 0; - }*/ - d->data = (char*)calloc(strlen(s),sizeof(char)); - if (d->data == NULL) return ENOMEM; d->length = strlen(s); - memcpy(d->data,s,strlen(s)); - return 0; + d->data = ealloc(d->length); + memcpy(d->data, s, d->length); } -krb5_error_code krb5_data_hex_parse(krb5_data *d, const char *s) +asn1_error_code +krb5_data_hex_parse(krb5_data *d, const char *s) { int lo; long v; @@ -95,9 +104,7 @@ krb5_error_code krb5_data_hex_parse(krb5_data *d, const char *s) char *dp; char buf[2]; - d->data = calloc((strlen(s) / 2 + 1), 1); - if (d->data == NULL) - return ENOMEM; + d->data = ealloc(strlen(s) / 2 + 1); d->length = 0; buf[1] = '\0'; for (lo = 0, dp = d->data, cp = s; *cp; cp++) { @@ -124,8 +131,8 @@ krb5_error_code krb5_data_hex_parse(krb5_data *d, const char *s) } #if 0 -void asn1buf_print(buf) - const asn1buf * buf; +void +asn1buf_print(const asn1buf *buf) { asn1buf bufcopy; char *s=NULL; @@ -150,7 +157,8 @@ void asn1buf_print(buf) } #endif -void init_access(const char *progname) +void +init_access(const char *progname) { krb5_error_code ret; ret = krb5int_accessor(&acc, KRB5INT_ACCESS_VERSION); diff --git a/src/tests/asn.1/utility.h b/src/tests/asn.1/utility.h index 93a66afa59..a0e81cd922 100644 --- a/src/tests/asn.1/utility.h +++ b/src/tests/asn.1/utility.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* tests/asn.1/utility.h */ /* * Copyright (C) 1994 by the Massachusetts Institute of Technology. @@ -30,29 +31,29 @@ #include "asn1buf.h" #include "k5-int.h" -asn1_error_code asn1_krb5_data_unparse - (const krb5_data *code, char **s); +/* Aborts on failure. ealloc returns zero-filled memory. */ +void *ealloc(size_t size); +char *estrdup(const char *str); + +void asn1_krb5_data_unparse(const krb5_data *code, char **s); /* modifies *s; effects Instantiates *s with a string representation of the series - of hex octets in *code. (e.g. "02 02 00 7F") If code==NULL, - the string rep is "<NULL>". If code is empty (it contains no - data or has length <= 0), the string rep is "<EMPTY>". - If *s is non-NULL, then its currently-allocated storage - will be freed prior to the instantiation. - Returns ENOMEM or the string rep cannot be created. */ - -krb5_error_code krb5_data_parse - (krb5_data *d, const char *s); + of hex octets in *code. (e.g. "02 02 00 7F") If code==NULL, + the string rep is "<NULL>". If code is empty (it contains no + data or has length <= 0), the string rep is "<EMPTY>". + If *s is non-NULL, then its currently-allocated storage + will be freed prior to the instantiation. + Returns ENOMEM or the string rep cannot be created. */ + +void krb5_data_parse(krb5_data *d, const char *s); /* effects Parses character string *s into krb5_data *d. */ -krb5_error_code krb5_data_hex_parse - (krb5_data *d, const char *s); +asn1_error_code krb5_data_hex_parse(krb5_data *d, const char *s); /* requires *s is the string representation of a sequence of hexadecimal octets. (e.g. "02 01 00") effects Parses *s into krb5_data *d. */ -void asn1buf_print - (const asn1buf *buf); +void asn1buf_print(const asn1buf *buf); extern krb5int_access acc; extern void init_access(const char *progname); |