From: Theodore Tso Date: Sat, 26 Aug 1995 02:03:30 +0000 (+0000) Subject: krb5_encode_test.c (main): Add tests for encode_krb5_padata_sequence() X-Git-Tag: krb5-1.0-beta6~1261 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=737891a17158d9f27f84b6f848f9e3b8fed364ae;p=krb5.git krb5_encode_test.c (main): Add tests for encode_krb5_padata_sequence() krb5_decode_test.c (main): Add tests for decode_krb5_padata_sequence(). ktest.c (ktest_make_sample_empty_pa_data_array): New function which creates an empty pa_data array. trval.c: Various -Wall cleanups. Makefile.in (trval): Add rule to build the standalone trval program. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6594 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/tests/asn.1/ChangeLog b/src/tests/asn.1/ChangeLog index f39e74ab8..f5d4b1420 100644 --- a/src/tests/asn.1/ChangeLog +++ b/src/tests/asn.1/ChangeLog @@ -1,3 +1,18 @@ +Fri Aug 25 21:50:37 1995 Theodore Y. Ts'o + + * krb5_encode_test.c (main): Add tests for + encode_krb5_padata_sequence(). + + * krb5_decode_test.c (main): Add tests for + decode_krb5_padata_sequence(). + + * ktest.c (ktest_make_sample_empty_pa_data_array): New function + which creates an empty pa_data array. + + * trval.c: Various -Wall cleanups. + + * Makefile.in (trval): Add rule to build the standalone trval + program. Thu Jul 27 15:29:10 EDT 1995 Paul Park (pjpark@mit.edu) * krb5_{en,de}code_test.c - Use k5-int instead of krb5 and asn1.h. diff --git a/src/tests/asn.1/Makefile.in b/src/tests/asn.1/Makefile.in index 96010e12b..db2221bf4 100644 --- a/src/tests/asn.1/Makefile.in +++ b/src/tests/asn.1/Makefile.in @@ -2,7 +2,7 @@ CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDES) COMERRLIB=$(TOPLIBD)/libcom_err.a -all:: krb5_encode_test krb5_decode_test +all:: krb5_encode_test krb5_decode_test trval LOCALINCLUDES = -I$(srcdir)/../../lib/krb5/asn.1 @@ -16,6 +16,9 @@ DECOBJS = krb5_decode_test.o ktest.o ktest_equal.o utility.o krb5_decode_test: $(DECOBJS) $(DEPLIBS) $(LD) $(LDFLAGS) $(LDARGS) -o krb5_decode_test $(DECOBJS) $(LIBS) +trval: $(srcdir)/trval.c + $(CC) -o trval $(CFLAGS) -DSTANDALONE $(srcdir)/trval.c + check:: krb5_decode_test krb5_encode_test LD_LIBRARY_PATH=$(TOPLIBD) ./krb5_decode_test $(RM) test.out diff --git a/src/tests/asn.1/krb5_decode_test.c b/src/tests/asn.1/krb5_decode_test.c index 69040344f..266683bc6 100644 --- a/src/tests/asn.1/krb5_decode_test.c +++ b/src/tests/asn.1/krb5_decode_test.c @@ -352,5 +352,43 @@ void main() 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); } + /****************************************************************/ + /* 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); + } + 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,""); + exit(1); + } + retval = decode_krb5_padata_sequence(&code,&var); + if(retval) com_err("decoding padata_sequence",retval,""); + assert(ktest_equal_sequence_of_pa_data(ref,var),"pa_data\n") + } + + /****************************************************************/ + /* 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); + } + retval = krb5_data_hex_parse(&code,"30 00"); + if(retval){ + com_err("parsing padata_sequence (empty)",retval,""); + exit(1); + } + retval = decode_krb5_padata_sequence(&code,&var); + if(retval) com_err("decoding padata_sequence (empty)",retval,""); + assert(ktest_equal_sequence_of_pa_data(ref,var),"pa_data (empty)\n") + } + exit(error_count); } diff --git a/src/tests/asn.1/krb5_encode_test.c b/src/tests/asn.1/krb5_encode_test.c index f25f73e2d..c7b3487d4 100644 --- a/src/tests/asn.1/krb5_encode_test.c +++ b/src/tests/asn.1/krb5_encode_test.c @@ -435,5 +435,27 @@ void main(argc, argv) encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data); } + /****************************************************************/ + /* encode_padata_sequence */ + { + krb5_pa_data **pa; + + setup(pa,krb5_pa_data,"PreauthData",ktest_make_sample_pa_data_array); + retval = encode_krb5_padata_sequence((const krb5_pa_data**)pa,&(code)); + if(retval) com_err("encoding padata_sequence",retval,""); + encoder_print_results(code, "padata_sequence", ""); + } + + /****************************************************************/ + /* encode_padata_sequence (empty) */ + { + krb5_pa_data **pa; + + setup(pa,krb5_pa_data,"EmptyPreauthData",ktest_make_sample_empty_pa_data_array); + retval = encode_krb5_padata_sequence((const krb5_pa_data**)pa,&(code)); + if(retval) com_err("encoding padata_sequence(empty)",retval,""); + encoder_print_results(code, "padata_sequence(empty)", ""); + } + exit(error_count); } diff --git a/src/tests/asn.1/ktest.c b/src/tests/asn.1/ktest.c index b3a1c5363..4951e15d3 100644 --- a/src/tests/asn.1/ktest.c +++ b/src/tests/asn.1/ktest.c @@ -300,6 +300,17 @@ krb5_error_code ktest_make_sample_pa_data_array(pad) return 0; } +krb5_error_code ktest_make_sample_empty_pa_data_array(pad) + krb5_pa_data *** pad; +{ + *pad = (krb5_pa_data**)calloc(1,sizeof(krb5_pa_data*)); + if(*pad == NULL) return ENOMEM; + + (*pad)[0] = NULL; + + return 0; +} + krb5_error_code ktest_make_sample_pa_data(pad) krb5_pa_data * pad; { diff --git a/src/tests/asn.1/ktest.h b/src/tests/asn.1/ktest.h index 512eb3184..752a5f834 100644 --- a/src/tests/asn.1/ktest.h +++ b/src/tests/asn.1/ktest.h @@ -50,6 +50,8 @@ krb5_error_code ktest_make_sample_kdc_rep KRB5_PROTOTYPE((krb5_kdc_rep *kdcr)); krb5_error_code ktest_make_sample_pa_data_array KRB5_PROTOTYPE((krb5_pa_data ***pad)); + krb5_error_code ktest_make_sample_empty_pa_data_array + KRB5_PROTOTYPE((krb5_pa_data ***pad)); krb5_error_code ktest_make_sample_pa_data KRB5_PROTOTYPE((krb5_pa_data *pad)); krb5_error_code ktest_make_sample_ap_req diff --git a/src/tests/asn.1/reference_encode.out b/src/tests/asn.1/reference_encode.out index 876012103..8022948fd 100644 --- a/src/tests/asn.1/reference_encode.out +++ b/src/tests/asn.1/reference_encode.out @@ -37,3 +37,5 @@ encode_krb5_error(optionals NULL): 7E 60 30 5E A0 03 02 01 05 A1 03 02 01 1E A3 encode_krb5_authorization_data: 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 encode_krb5_pwd_sequence: 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 encode_krb5_pwd_data: 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 +encode_krb5_padata_sequence: 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 +encode_krb5_padata_sequence(empty): 30 00 diff --git a/src/tests/asn.1/trval.c b/src/tests/asn.1/trval.c index 196c19699..71e3102e3 100644 --- a/src/tests/asn.1/trval.c +++ b/src/tests/asn.1/trval.c @@ -32,6 +32,8 @@ * trval.c.c *****************************************************************************/ +#include +#include #include #include @@ -100,6 +102,8 @@ int print_krb5_types = 0; int print_skip_krb5_tagnum = 0; #endif +void print_tag_type(); +int trval(), trval2(), decode_len(), do_cons(), do_prim(); /****************************************************************************/ @@ -110,7 +114,6 @@ int main(argc, argv) char **argv; { int optflg = 1; - int options = 0; FILE *fp; int r; @@ -132,7 +135,7 @@ int main(argc, argv) continue; } r = trval(fp, stdout); - close(fp); + fclose(fp); } } if (optflg) r = trval(stdin, stdout); @@ -292,7 +295,7 @@ int do_prim(fp, tag, enc, len, lev) } } if ((j = (n % WIDTH)) != 0) { - fprintf(fp, " ", j); + fprintf(fp, " "); for (i=0; i 6b 72 62 35 64 61 74 61 krb5data +encode_krb5_padata_sequence: + +[Sequence/Sequence Of] +. [Sequence/Sequence Of] +. . [1] [Integer] <1> + 0d . +. . [2] [Octet String] <7> + 70 61 2d 64 61 74 61 pa-data +. [Sequence/Sequence Of] +. . [1] [Integer] <1> + 0d . +. . [2] [Octet String] <7> + 70 61 2d 64 61 74 61 pa-data + +encode_krb5_padata_sequence(empty): + +[Sequence/Sequence Of] +