From bb9b0b84859c9d2c699eb4464d541f864d305c79 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Thu, 4 Aug 1994 06:14:21 +0000 Subject: [PATCH] checking in Harry's ASN.1 encoder tests. Will fix up later git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4035 dc483132-0cff-0310-8789-dd5450dbe970 --- src/tests/asn.1/Makefile | 36 ++ src/tests/asn.1/README | 28 + src/tests/asn.1/debug.h | 20 + src/tests/asn.1/krb5_decode_test.c | 356 +++++++++++ src/tests/asn.1/krb5_encode_test.c | 11 + src/tests/asn.1/krb5_encode_test_body.c | 378 +++++++++++ src/tests/asn.1/ktest.c | 802 ++++++++++++++++++++++++ src/tests/asn.1/ktest.h | 130 ++++ src/tests/asn.1/ktest_equal.c | 631 +++++++++++++++++++ src/tests/asn.1/ktest_equal.h | 78 +++ src/tests/asn.1/reference_encode.out | 39 ++ src/tests/asn.1/utility.c | 106 ++++ src/tests/asn.1/utility.h | 32 + 13 files changed, 2647 insertions(+) create mode 100644 src/tests/asn.1/Makefile create mode 100644 src/tests/asn.1/README create mode 100644 src/tests/asn.1/debug.h create mode 100644 src/tests/asn.1/krb5_decode_test.c create mode 100644 src/tests/asn.1/krb5_encode_test.c create mode 100644 src/tests/asn.1/krb5_encode_test_body.c create mode 100644 src/tests/asn.1/ktest.c create mode 100644 src/tests/asn.1/ktest.h create mode 100644 src/tests/asn.1/ktest_equal.c create mode 100644 src/tests/asn.1/ktest_equal.h create mode 100644 src/tests/asn.1/reference_encode.out create mode 100644 src/tests/asn.1/utility.c create mode 100644 src/tests/asn.1/utility.h diff --git a/src/tests/asn.1/Makefile b/src/tests/asn.1/Makefile new file mode 100644 index 000000000..cc033f399 --- /dev/null +++ b/src/tests/asn.1/Makefile @@ -0,0 +1,36 @@ +CC = cc +CCFLAGS = -g -I../../include +LIBS = -L../../lib -lkrb5 -lcom_err + +all: krb5_encode_test krb5_decode_test + +ENCOBJS = krb5_encode_test.o ktest.o ktest_equal.o utility.o asn1buf.o +krb5_encode_test: $(ENCOBJS) + $(CC) $(CCFLAGS) -o krb5_encode_test $(ENCOBJS) $(LIBS) + +DECOBJS = krb5_decode_test.o ktest.o ktest_equal.o +krb5_decode_test: $(DECOBJS) + $(CC) $(CCFLAGS) -o krb5_decode_test $(DECOBJS) $(LIBS) + +clean: + rm -f *~ *.o krb5_encode_test krb5_decode_test + + +################ Dependencies ################ +asn1buf.o: asn1buf.h +asn1buf.h: krbasn1.h +krb5_decode_test.o: ktest.h utility.h ktest_equal.h debug.h +krb5_encode_test.o: utility.h krb5_encode_test_body.c +krb5_encode_test_body.o: ktest.h debug.h +ktest.o: ktest.h utility.h +ktest_equal.o: ktest_equal.h +utility.o: utility.h +utility.h: krbasn1.h asn1buf.h +############################################## + +################ Inference Rules ################ +.SUFFIXES: .o .c + +.c.o: + $(CC) -c $(CCFLAGS) $< +################################################# diff --git a/src/tests/asn.1/README b/src/tests/asn.1/README new file mode 100644 index 000000000..2c0c09809 --- /dev/null +++ b/src/tests/asn.1/README @@ -0,0 +1,28 @@ +krb5_encode_test runs through all the functions declared in + src/include/krb5/asn.1/krb5_encode.h. It passes various sample + inputs to each function and prints the result to standard + output. This output should match the contents of the file + "reference_encode.out". + + Each function is first run with a relatively simple, contrived + sample structure. Then if the structure has any optional parts, + these parts are cleared and another run is made. + + Some structures (namely, those containing a krb5_kdc_req_body) + have a third run, due to the fact that two of the kdc_req_body's + optional fields have mutually exclusive conditions under which + they may be omitted. + + +krb5_decode_test runs through all the functions declared in + src/include/krb5/asn.1/krb5_decode.h. It has the encodings in + reference_encode.out hard-coded into itself. It sets up the + krb5 structures the same way krb5_encode_test does, then passes + its hard-coded encoding strings through the krb5 decoders. + + The outputs of these functions are compared to the previously + set-up structures in memory, and the results are reported to + standard output. If every line comes out prefixed by "OK: ", + then the decoders are working properly. If any decoder produces + an anomalous output, then its output line will be prefixed by + "ERROR: " diff --git a/src/tests/asn.1/debug.h b/src/tests/asn.1/debug.h new file mode 100644 index 000000000..2c9cf8105 --- /dev/null +++ b/src/tests/asn.1/debug.h @@ -0,0 +1,20 @@ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +/* + assert utility macro for test programs: + If the predicate (pred) is true, then + OK: is printed. Otherwise, + ERROR: is printed. + + message should be a printf format string. +*/ + +#include + +#define assert(pred,message)\ + if(pred) printf("OK: ");\ + else printf("ERROR: ");\ + printf(message); + +#endif diff --git a/src/tests/asn.1/krb5_decode_test.c b/src/tests/asn.1/krb5_decode_test.c new file mode 100644 index 000000000..ba314555b --- /dev/null +++ b/src/tests/asn.1/krb5_decode_test.c @@ -0,0 +1,356 @@ +#include +#include "ktest.h" +#include +#include "utility.h" +#include "ktest_equal.h" + +#include "debug.h" +#include + +/* See krb5_encode_test_body.c for explanation. */ +/*#define ISODE_SUCKS*/ + +void main() +{ + krb5_data code; + krb5_error_code retval; + + initialize_asn1_error_table(); + initialize_krb5_error_table(); + +#define setup(type,typestring,constructor)\ + type ref, *var;\ + retval = constructor(&ref);\ + if(retval){\ + com_err(strcat("making sample ",typestring),retval,"");\ + exit(1);\ + } + +#define decode_run(typestring,description,encoding,decoder,comparator)\ + retval = krb5_data_hex_parse(&code,encoding);\ + if(retval){\ + com_err(strcat("parsing ",strcat(typestring,description)),retval,"");\ + exit(1);\ + }\ + retval = decoder(&code,&var);\ + if(retval){\ + com_err(strcat("decoding ",strcat(typestring,description)),retval,"");\ + }\ + assert(comparator(&ref,var),typestring);\ + printf("%s\n",description) + + + /****************************************************************/ + /* decode_krb5_authenticator */ + { + setup(krb5_authenticator,"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); + + ktest_destroy_checksum(&(ref.checksum)); + ktest_destroy_keyblock(&(ref.subkey)); + ref.seq_number = 0; + ktest_empty_authorization_data(ref.authorization_data); + decode_run("authenticator","(optionals empty)","62 4F 30 4D 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 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",decode_krb5_authenticator,ktest_equal_authenticator); + + ktest_destroy_authorization_data(&(ref.authorization_data)); + + decode_run("authenticator","(optionals NULL)","62 4F 30 4D 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 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",decode_krb5_authenticator,ktest_equal_authenticator); + } + + /****************************************************************/ + /* decode_krb5_ticket */ + { + setup(krb5_ticket,"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); + } + + /****************************************************************/ + /* decode_krb5_encryption_key */ + { + setup(krb5_keyblock,"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); + } + + /****************************************************************/ + /* decode_krb5_enc_tkt_part */ + { + setup(krb5_enc_tkt_part,"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); + + ref.times.starttime = 0; + ref.times.renew_till = 0; + ktest_destroy_address(&(ref.caddrs[1])); + ktest_destroy_address(&(ref.caddrs[0])); + ktest_destroy_authdata(&(ref.authorization_data[1])); + ktest_destroy_authdata(&(ref.authorization_data[0])); + /* ISODE version fails on the empty caddrs field */ + ktest_destroy_addresses(&(ref.caddrs)); + ktest_destroy_authorization_data(&(ref.authorization_data)); + + decode_run("enc_tkt_part","(optionals NULL)","63 81 A5 30 81 A2 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 A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A",decode_krb5_enc_tkt_part,ktest_equal_enc_tkt_part); + } + + /****************************************************************/ + /* decode_krb5_enc_kdc_rep_part */ + { + setup(krb5_enc_kdc_rep_part,"krb5_enc_kdc_rep_part",ktest_make_sample_enc_kdc_rep_part); + + decode_run("enc_kdc_rep_part","","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); + + ref.key_exp = 0; + ref.times.starttime = 0; + ref.times.renew_till = 0; + ref.flags &= ~TKT_FLG_RENEWABLE; + ktest_destroy_addresses(&(ref.caddrs)); + + decode_run("enc_kdc_rep_part","(optionals NULL)","7A 81 B4 30 81 B1 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 A4 07 03 05 00 FE 5C BA 98 A5 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 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",decode_krb5_enc_kdc_rep_part,ktest_equal_enc_kdc_rep_part); + } + + /****************************************************************/ + /* decode_krb5_as_rep */ + { + setup(krb5_kdc_rep,"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); + ktest_destroy_pa_data_array(&(ref.padata)); + decode_run("as_rep","(optionals NULL)","6B 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0B 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); + } + + /****************************************************************/ + /* decode_krb5_tgs_rep */ + { + setup(krb5_kdc_rep,"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); + + ktest_destroy_pa_data_array(&(ref.padata)); + decode_run("tgs_rep","(optionals NULL)","6D 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0D 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); + } + + /****************************************************************/ + /* decode_krb5_ap_req */ + { + setup(krb5_ap_req,"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); + } + + /****************************************************************/ + /* decode_krb5_ap_rep */ + { + setup(krb5_ap_rep,"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); + } + + /****************************************************************/ + /* decode_krb5_ap_rep_enc_part */ + { + setup(krb5_ap_rep_enc_part,"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); + + ktest_destroy_keyblock(&(ref.subkey)); + ref.seq_number = 0; + decode_run("ap_rep_enc_part","(optionals NULL)","7B 1C 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_ap_rep_enc_part,ktest_equal_ap_rep_enc_part); + } + + /****************************************************************/ + /* decode_krb5_as_req */ + { + setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req); + ref.msg_type = KRB5_AS_REQ; + + ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + decode_run("as_req","","6A 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0A 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 A4 82 01 AA 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_as_req,ktest_equal_as_req); + + ktest_destroy_pa_data_array(&(ref.padata)); + ktest_destroy_principal(&(ref.client)); +#ifndef ISODE_SUCKS + ktest_destroy_principal(&(ref.server)); +#endif + ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY; + ref.from = 0; + ref.rtime = 0; + ktest_destroy_addresses(&(ref.addresses)); + ktest_destroy_enc_data(&(ref.authorization_data)); + decode_run("as_req","(optionals NULL except second_ticket)","6A 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0A A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 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 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_as_req,ktest_equal_as_req); + ktest_destroy_sequence_of_ticket(&(ref.second_ticket)); +#ifndef ISODE_SUCKS + ktest_make_sample_principal(&(ref.server)); +#endif + ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + decode_run("as_req","(optionals NULL except server)","6A 69 30 67 A1 03 02 01 05 A2 03 02 01 0A A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 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 A5 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",decode_krb5_as_req,ktest_equal_as_req); + } + + /****************************************************************/ + /* decode_krb5_tgs_req */ + { + setup(krb5_kdc_req,"krb5_kdc_req",ktest_make_sample_kdc_req); + ref.msg_type = KRB5_TGS_REQ; + + ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + decode_run("tgs_req","","6C 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0C 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 A4 82 01 AA 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_tgs_req,ktest_equal_tgs_req); + + ktest_destroy_pa_data_array(&(ref.padata)); + ktest_destroy_principal(&(ref.client)); +#ifndef ISODE_SUCKS + ktest_destroy_principal(&(ref.server)); +#endif + ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY; + ref.from = 0; + ref.rtime = 0; + ktest_destroy_addresses(&(ref.addresses)); + ktest_destroy_enc_data(&(ref.authorization_data)); + decode_run("tgs_req","(optionals NULL except second_ticket)","6C 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0C A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 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 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_tgs_req,ktest_equal_tgs_req); + + ktest_destroy_sequence_of_ticket(&(ref.second_ticket)); +#ifndef ISODE_SUCKS + ktest_make_sample_principal(&(ref.server)); +#endif + ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + decode_run("tgs_req","(optionals NULL except server)","6C 69 30 67 A1 03 02 01 05 A2 03 02 01 0C A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 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 A5 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",decode_krb5_tgs_req,ktest_equal_tgs_req); + } + + /****************************************************************/ + /* decode_krb5_kdc_req_body */ + { + krb5_kdc_req ref, *var; + retval = ktest_make_sample_kdc_req_body(&ref); + if(retval){ + com_err("making sample kdc_req_body",retval,""); + exit(1); + } + 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); + + ktest_destroy_principal(&(ref.client)); +#ifndef ISODE_SUCKS + ktest_destroy_principal(&(ref.server)); +#endif + ref.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY; + ref.from = 0; + ref.rtime = 0; + ktest_destroy_addresses(&(ref.addresses)); + ktest_destroy_enc_data(&(ref.authorization_data)); + decode_run("kdc_req_body","(optionals NULL except second_ticket)","30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 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 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); + + ktest_destroy_sequence_of_ticket(&(ref.second_ticket)); +#ifndef ISODE_SUCKS + ktest_make_sample_principal(&(ref.server)); +#endif + ref.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + decode_run("kdc_req_body","(optionals NULL except server)","30 59 A0 07 03 05 00 FE DC BA 90 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 A5 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",decode_krb5_kdc_req_body,ktest_equal_kdc_req_body); + } + + /****************************************************************/ + /* decode_krb5_safe */ + { + setup(krb5_safe,"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); + + ref.timestamp = 0; + ref.usec = 0; + ref.seq_number = 0; + ktest_destroy_address(&(ref.r_address)); + decode_run("safe","(optionals NULL)","74 3E 30 3C A0 03 02 01 05 A1 03 02 01 14 A2 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 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); + } + + /****************************************************************/ + /* decode_krb5_priv */ + { + setup(krb5_priv,"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); + } + + /****************************************************************/ + /* decode_krb5_enc_priv_part */ + { + setup(krb5_priv_enc_part,"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); + + ref.timestamp = 0; + ref.usec = 0; + ref.seq_number = 0; + ktest_destroy_address(&(ref.r_address)); + decode_run("enc_priv_part","(optionals NULL)","7C 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 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); + } + + /****************************************************************/ + /* decode_krb5_cred */ + { + setup(krb5_cred,"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); + } + + /****************************************************************/ + /* decode_krb5_enc_cred_part */ + { + setup(krb5_cred_enc_part,"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); + + ktest_destroy_principal(&(ref.ticket_info[0]->client)); + ktest_destroy_principal(&(ref.ticket_info[0]->server)); + ref.ticket_info[0]->flags = 0; + ref.ticket_info[0]->times.authtime = 0; + ref.ticket_info[0]->times.starttime = 0; + ref.ticket_info[0]->times.endtime = 0; + ref.ticket_info[0]->times.renew_till = 0; + ktest_destroy_addresses(&(ref.ticket_info[0]->caddrs)); + ref.nonce = 0; + ref.timestamp = 0; + ref.usec = 0; + ktest_destroy_address(&(ref.s_address)); + ktest_destroy_address(&(ref.r_address)); + decode_run("enc_cred_part","(optionals NULL)","7D 82 01 0E 30 82 01 0A A0 82 01 06 30 82 01 02 30 15 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 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",decode_krb5_enc_cred_part,ktest_equal_enc_cred_part); + } + + /****************************************************************/ + /* decode_krb5_error */ + { + setup(krb5_error,"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); + + ref.ctime = 0; + ktest_destroy_principal(&(ref.client)); + ktest_empty_data(&(ref.text)); + ktest_empty_data(&(ref.e_data)); + decode_run("error","(optionals NULL)","7E 60 30 5E A0 03 02 01 05 A1 03 02 01 1E 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 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",decode_krb5_error,ktest_equal_error); + } + + /****************************************************************/ + /* 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); + } + 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,""); + exit(1); + } + retval = decode_krb5_authdata(&code,&var); + if(retval) com_err("decoding authorization_data",retval,""); + assert(ktest_equal_authorization_data(ref,var),"authorization_data\n") + } + + /****************************************************************/ + /* decode_pwd_sequence */ + { + setup(passwd_phrase_element,"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); + } + + /****************************************************************/ + /* decode_passwd_data */ + { + setup(krb5_pwd_data,"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); + } + + exit(0); +} diff --git a/src/tests/asn.1/krb5_encode_test.c b/src/tests/asn.1/krb5_encode_test.c new file mode 100644 index 000000000..b3fe50a32 --- /dev/null +++ b/src/tests/asn.1/krb5_encode_test.c @@ -0,0 +1,11 @@ +#include +#include +#include +#include +#include "utility.h" + +#define initialize_error_tables()\ + initialize_isod_error_table();\ + initialize_krb5_error_table(); + +#include "krb5_encode_test_body.c" diff --git a/src/tests/asn.1/krb5_encode_test_body.c b/src/tests/asn.1/krb5_encode_test_body.c new file mode 100644 index 000000000..2f2e5553d --- /dev/null +++ b/src/tests/asn.1/krb5_encode_test_body.c @@ -0,0 +1,378 @@ +#include "ktest.h" +#include + +#include "debug.h" + +/* The ISODE routines crashed when certain fields were omitted (even + though they were optional). My encoders should handle any NULL + fields (both optional and non-optional) gracefully, so this #define + is probably no longer needed. */ +/*#define ISODE_SUCKS*/ + +void main() +{ + krb5_data *code; + char *code_string=NULL; + krb5_error_code retval; + + initialize_error_tables(); + +#define setup(value,type,typestring,constructor)\ + retval = constructor(&(value));\ + if(retval){\ + com_err(strcat("making sample ",typestring),retval,"");\ + exit(1);\ + } + +#define encode_run(value,type,typestring,description,encoder)\ + retval = encoder(&(value),&(code));\ + if(retval){\ + com_err(strcat("encoding ",typestring),retval,"");\ + exit(1);\ + }\ + retval = asn1_krb5_data_unparse(code,&(code_string));\ + if(retval){\ + com_err(strcat("unparsing ",typestring),retval,"");\ + exit(1);\ + }\ + ktest_destroy_data(&code);\ + printf("encode_krb5_%s%s: %s\n",typestring,description,code_string); + + + /****************************************************************/ + /* encode_krb5_authenticator */ + { + krb5_authenticator authent; + setup(authent,authenticator,"authenticator",ktest_make_sample_authenticator); + + encode_run(authent,authenticator,"authenticator","",encode_krb5_authenticator); + + ktest_destroy_checksum(&(authent.checksum)); + ktest_destroy_keyblock(&(authent.subkey)); + authent.seq_number = 0; + ktest_empty_authorization_data(authent.authorization_data); + encode_run(authent,authenticator,"authenticator","(optionals empty)",encode_krb5_authenticator); + + ktest_destroy_authorization_data(&(authent.authorization_data)); + encode_run(authent,authenticator,"authenticator","(optionals NULL)",encode_krb5_authenticator); + } + + /****************************************************************/ + /* encode_krb5_ticket */ + { + krb5_ticket tkt; + setup(tkt,ticket,"ticket",ktest_make_sample_ticket); + encode_run(tkt,ticket,"ticket","",encode_krb5_ticket); + } + + /****************************************************************/ + /* encode_krb5_encryption_key */ + { + krb5_keyblock keyblk; + setup(keyblk,keyblock,"keyblock",ktest_make_sample_keyblock); + encode_run(keyblk,keyblock,"keyblock","",encode_krb5_encryption_key); + } + + /****************************************************************/ + /* encode_krb5_enc_tkt_part */ + { + krb5_ticket tkt; + 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); + + encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","",encode_krb5_enc_tkt_part); + + tkt.enc_part2->times.starttime = 0; + tkt.enc_part2->times.renew_till = 0; + ktest_destroy_address(&(tkt.enc_part2->caddrs[1])); + ktest_destroy_address(&(tkt.enc_part2->caddrs[0])); + ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[1])); + ktest_destroy_authdata(&(tkt.enc_part2->authorization_data[0])); + + /* ISODE version fails on the empty caddrs field */ + ktest_destroy_addresses(&(tkt.enc_part2->caddrs)); + ktest_destroy_authorization_data(&(tkt.enc_part2->authorization_data)); + + encode_run(*(tkt.enc_part2),enc_tkt_part,"enc_tkt_part","(optionals NULL)",encode_krb5_enc_tkt_part); + } + + /****************************************************************/ + /* encode_krb5_enc_kdc_rep_part */ + { + krb5_kdc_rep 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); + + encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","",encode_krb5_enc_kdc_rep_part); + + kdcr.enc_part2->key_exp = 0; + kdcr.enc_part2->times.starttime = 0; + kdcr.enc_part2->flags &= ~TKT_FLG_RENEWABLE; + ktest_destroy_addresses(&(kdcr.enc_part2->caddrs)); + + encode_run(*(kdcr.enc_part2),enc_kdc_rep_part,"enc_kdc_rep_part","(optionals NULL)",encode_krb5_enc_kdc_rep_part); + } + + /****************************************************************/ + /* encode_krb5_as_rep */ + { + krb5_kdc_rep kdcr; + setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep); + +/* kdcr.msg_type = KRB5_TGS_REP; + assert(encode_krb5_as_rep(&kdcr,&code) == KRB5_BADMSGTYPE, + "encode_krb5_as_rep type check\n"); + ktest_destroy_data(&code);*/ + + kdcr.msg_type = KRB5_AS_REP; + encode_run(kdcr,as_rep,"as_rep","",encode_krb5_as_rep); + + ktest_destroy_pa_data_array(&(kdcr.padata)); + encode_run(kdcr,as_rep,"as_rep","(optionals NULL)",encode_krb5_as_rep); + } + + /****************************************************************/ + /* encode_krb5_tgs_rep */ + { + krb5_kdc_rep kdcr; + setup(kdcr,kdc_rep,"kdc_rep",ktest_make_sample_kdc_rep); + +/* kdcr.msg_type = KRB5_AS_REP; + assert(encode_krb5_tgs_rep(&kdcr,&code) == KRB5_BADMSGTYPE, + "encode_krb5_tgs_rep type check\n");*/ + + kdcr.msg_type = KRB5_TGS_REP; + encode_run(kdcr,tgs_rep,"tgs_rep","",encode_krb5_tgs_rep); + + ktest_destroy_pa_data_array(&(kdcr.padata)); + encode_run(kdcr,tgs_rep,"tgs_rep","(optionals NULL)",encode_krb5_tgs_rep); + } + + /****************************************************************/ + /* encode_krb5_ap_req */ + { + krb5_ap_req apreq; + setup(apreq,ap_req,"ap_req",ktest_make_sample_ap_req); + encode_run(apreq,ap_req,"ap_req","",encode_krb5_ap_req); + } + + /****************************************************************/ + /* encode_krb5_ap_rep */ + { + krb5_ap_rep aprep; + setup(aprep,ap_rep,"ap_rep",ktest_make_sample_ap_rep); + encode_run(aprep,ap_rep,"ap_rep","",encode_krb5_ap_rep); + } + + /****************************************************************/ + /* 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); + encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","",encode_krb5_ap_rep_enc_part); + + ktest_destroy_keyblock(&(apenc.subkey)); + apenc.seq_number = 0; + encode_run(apenc,ap_rep_enc_part,"ap_rep_enc_part","(optionals NULL)",encode_krb5_ap_rep_enc_part); + } + + /****************************************************************/ + /* encode_krb5_as_req */ + { + krb5_kdc_req asreq; + setup(asreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req); + 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); + + ktest_destroy_pa_data_array(&(asreq.padata)); + ktest_destroy_principal(&(asreq.client)); +#ifndef ISODE_SUCKS + ktest_destroy_principal(&(asreq.server)); +#endif + asreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY; + asreq.from = 0; + asreq.rtime = 0; + ktest_destroy_addresses(&(asreq.addresses)); + ktest_destroy_enc_data(&(asreq.authorization_data)); + encode_run(asreq,as_req,"as_req","(optionals NULL except second_ticket)",encode_krb5_as_req); + ktest_destroy_sequence_of_ticket(&(asreq.second_ticket)); +#ifndef ISODE_SUCKS + ktest_make_sample_principal(&(asreq.server)); +#endif + asreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + encode_run(asreq,as_req,"as_req","(optionals NULL except server)",encode_krb5_as_req); + } + + /****************************************************************/ + /* encode_krb5_tgs_req */ + { + krb5_kdc_req tgsreq; + setup(tgsreq,kdc_req,"kdc_req",ktest_make_sample_kdc_req); + 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); + + ktest_destroy_pa_data_array(&(tgsreq.padata)); + ktest_destroy_principal(&(tgsreq.client)); +#ifndef ISODE_SUCKS + ktest_destroy_principal(&(tgsreq.server)); +#endif + tgsreq.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY; + tgsreq.from = 0; + tgsreq.rtime = 0; + ktest_destroy_addresses(&(tgsreq.addresses)); + ktest_destroy_enc_data(&(tgsreq.authorization_data)); + encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except second_ticket)",encode_krb5_tgs_req); + + ktest_destroy_sequence_of_ticket(&(tgsreq.second_ticket)); +#ifndef ISODE_SUCKS + ktest_make_sample_principal(&(tgsreq.server)); +#endif + tgsreq.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + encode_run(tgsreq,tgs_req,"tgs_req","(optionals NULL except server)",encode_krb5_tgs_req); + } + + /****************************************************************/ + /* encode_krb5_kdc_req_body */ + { + krb5_kdc_req kdcrb; + setup(kdcrb,kdc_req_body,"kdc_req_body",ktest_make_sample_kdc_req_body); + kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + encode_run(kdcrb,kdc_req_body,"kdc_req_body","",encode_krb5_kdc_req_body); + + ktest_destroy_principal(&(kdcrb.client)); +#ifndef ISODE_SUCKS + ktest_destroy_principal(&(kdcrb.server)); +#endif + kdcrb.kdc_options |= KDC_OPT_ENC_TKT_IN_SKEY; + kdcrb.from = 0; + kdcrb.rtime = 0; + ktest_destroy_addresses(&(kdcrb.addresses)); + ktest_destroy_enc_data(&(kdcrb.authorization_data)); + encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except second_ticket)",encode_krb5_kdc_req_body); + + ktest_destroy_sequence_of_ticket(&(kdcrb.second_ticket)); +#ifndef ISODE_SUCKS + ktest_make_sample_principal(&(kdcrb.server)); +#endif + kdcrb.kdc_options &= ~KDC_OPT_ENC_TKT_IN_SKEY; + encode_run(kdcrb,kdc_req_body,"kdc_req_body","(optionals NULL except server)",encode_krb5_kdc_req_body); + } + + /****************************************************************/ + /* encode_krb5_safe */ + { + krb5_safe s; + setup(s,safe,"safe",ktest_make_sample_safe); + encode_run(s,safe,"safe","",encode_krb5_safe); + + s.timestamp = 0; + /* s.usec should be opted out by the timestamp */ + s.seq_number = 0; + ktest_destroy_address(&(s.r_address)); + encode_run(s,safe,"safe","(optionals NULL)",encode_krb5_safe); + } + + /****************************************************************/ + /* encode_krb5_priv */ + { + krb5_priv p; + setup(p,priv,"priv",ktest_make_sample_priv); + encode_run(p,priv,"priv","",encode_krb5_priv); + } + + /****************************************************************/ + /* encode_krb5_enc_priv_part */ + { + krb5_priv_enc_part ep; + setup(ep,priv_enc_part,"priv_enc_part",ktest_make_sample_priv_enc_part); + encode_run(ep,enc_priv_part,"enc_priv_part","",encode_krb5_enc_priv_part); + + ep.timestamp = 0; + /* ep.usec should be opted out along with timestamp */ + ep.seq_number = 0; + ktest_destroy_address(&(ep.r_address)); + encode_run(ep,enc_priv_part,"enc_priv_part","(optionals NULL)",encode_krb5_enc_priv_part); + } + + /****************************************************************/ + /* encode_krb5_cred */ + { + krb5_cred c; + setup(c,cred,"cred",ktest_make_sample_cred); + encode_run(c,cred,"cred","",encode_krb5_cred); + } + + /****************************************************************/ + /* encode_krb5_enc_cred_part */ + { + krb5_cred_enc_part cep; + setup(cep,cred_enc_part,"cred_enc_part",ktest_make_sample_cred_enc_part); + encode_run(cep,enc_cred_part,"enc_cred_part","",encode_krb5_enc_cred_part); + + ktest_destroy_principal(&(cep.ticket_info[0]->client)); + ktest_destroy_principal(&(cep.ticket_info[0]->server)); + cep.ticket_info[0]->flags = 0; + cep.ticket_info[0]->times.authtime = 0; + cep.ticket_info[0]->times.starttime = 0; + cep.ticket_info[0]->times.endtime = 0; + cep.ticket_info[0]->times.renew_till = 0; + ktest_destroy_addresses(&(cep.ticket_info[0]->caddrs)); + cep.nonce = 0; + cep.timestamp = 0; + ktest_destroy_address(&(cep.s_address)); + ktest_destroy_address(&(cep.r_address)); + encode_run(cep,enc_cred_part,"enc_cred_part","(optionals NULL)",encode_krb5_enc_cred_part); + } + + /****************************************************************/ + /* encode_krb5_error */ + { + krb5_error kerr; + setup(kerr,error,"error",ktest_make_sample_error); + encode_run(kerr,error,"error","",encode_krb5_error); + + kerr.ctime = 0; + ktest_destroy_principal(&(kerr.client)); + ktest_empty_data(&(kerr.text)); + ktest_empty_data(&(kerr.e_data)); + encode_run(kerr,error,"error","(optionals NULL)",encode_krb5_error); + } + + /****************************************************************/ + /* encode_krb5_authdata */ + { + krb5_authdata **ad; + setup(ad,authorization_data,"authorization_data",ktest_make_sample_authorization_data); + + retval = encode_krb5_authdata((const krb5_authdata**)ad,&(code)); + if(retval) com_err("encoding authorization_data",retval,""); + retval = asn1_krb5_data_unparse(code,&(code_string)); + if(retval) com_err("unparsing authorization_data",retval,""); + ktest_destroy_data(&code); + printf("encode_krb5_authorization_data: %s\n",code_string); + } + + /****************************************************************/ + /* encode_pwd_sequence */ + { + passwd_phrase_element ppe; + setup(ppe,passwd_phrase_element,"PasswdSequence",ktest_make_sample_passwd_phrase_element); + encode_run(ppe,passwd_phrase_element,"pwd_sequence","",encode_krb5_pwd_sequence); + } + + /****************************************************************/ + /* encode_passwd_data */ + { + krb5_pwd_data pd; + setup(pd,krb5_pwd_data,"PasswdData",ktest_make_sample_krb5_pwd_data); + encode_run(pd,krb5_pwd_data,"pwd_data","",encode_krb5_pwd_data); + } + + exit(0); +} diff --git a/src/tests/asn.1/ktest.c b/src/tests/asn.1/ktest.c new file mode 100644 index 000000000..e87dee213 --- /dev/null +++ b/src/tests/asn.1/ktest.c @@ -0,0 +1,802 @@ +#include "ktest.h" +#include "utility.h" +#include + +krb5_error_code ktest_make_sample_authenticator(DECLARG(krb5_authenticator *, a)) + OLDDECLARG(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; + 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->seq_number = SAMPLE_SEQ_NUMBER; + retval = ktest_make_sample_authorization_data(&(a->authorization_data)); + if(retval) return retval; + + return 0; +} + +krb5_error_code ktest_make_sample_principal(DECLARG(krb5_principal *, p)) + OLDDECLARG(krb5_principal *, p) +{ + krb5_error_code retval; + + /*if(*p == NULL){*/ + *p = (krb5_principal)calloc(1,sizeof(krb5_principal_data)); + if(*p == NULL) return ENOMEM; + /*}*/ + retval = krb5_data_parse(&((*p)->realm),"ATHENA.MIT.EDU"); + if(retval) return retval; + (*p)->type = 1; + (*p)->length = 2; + (*p)->data = (krb5_data*)calloc(2,sizeof(krb5_data)); + if((*p)->data == NULL) return ENOMEM; + retval = krb5_data_parse(&((*p)->data[0]),"hftsai"); + if(retval) return retval; + retval = krb5_data_parse(&((*p)->data[1]),"extra"); + if(retval) return retval; + + return 0; +} + +krb5_error_code ktest_make_sample_checksum(DECLARG(krb5_checksum *, cs)) + OLDDECLARG(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; + memcpy(cs->contents,"1234",4); + + return 0; +} + +krb5_error_code ktest_make_sample_keyblock(DECLARG(krb5_keyblock *, kb)) + OLDDECLARG(krb5_keyblock *, kb) +{ + kb->keytype = 1; + kb->length = 8; + kb->contents = (krb5_octet*)calloc(8,sizeof(krb5_octet)); + if(kb->contents == NULL) return ENOMEM; + memcpy(kb->contents,"12345678",8); + + return 0; +} + +krb5_error_code ktest_make_sample_ticket(DECLARG(krb5_ticket *, tkt)) + OLDDECLARG(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; + + return 0; +} + +krb5_error_code ktest_make_sample_enc_data(DECLARG(krb5_enc_data *, ed)) + OLDDECLARG(krb5_enc_data *, ed) +{ + krb5_error_code retval; + + ed->etype = 0; + ed->kvno = 5; + retval = krb5_data_parse(&(ed->ciphertext),"krbASN.1 test message"); + if(retval) return retval; + + return 0; +} + +krb5_error_code ktest_make_sample_enc_tkt_part(DECLARG(krb5_enc_tkt_part *, etp)) + OLDDECLARG(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(DECLARG(krb5_address ***, caddrs)) + OLDDECLARG(krb5_address ***, caddrs) +{ + asn1_error_code retval; + 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)[2] = NULL; + return 0; +} + +krb5_error_code ktest_make_sample_authorization_data(DECLARG(krb5_authdata ***, ad)) + OLDDECLARG(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)[2] = NULL; + + return 0; +} + +krb5_error_code ktest_make_sample_transited(DECLARG(krb5_transited *, t)) + OLDDECLARG(krb5_transited *, t) +{ + t->tr_type = 1; + return krb5_data_parse(&(t->tr_contents), + "EDU,MIT.,ATHENA.,WASHINGTON.EDU,CS."); +} + +krb5_error_code ktest_make_sample_ticket_times(DECLARG(krb5_ticket_times *, tt)) + OLDDECLARG(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(DECLARG(krb5_address *, a)) + OLDDECLARG(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[0] = 18; + a->contents[1] = 208; + a->contents[2] = 0; + a->contents[3] = 35; + + return 0; +} + +krb5_error_code ktest_make_sample_authdata(DECLARG(krb5_authdata *, ad)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sample_enc_kdc_rep_part(DECLARG(krb5_enc_kdc_rep_part *, ekr)) + OLDDECLARG(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->nonce = SAMPLE_NONCE; + ekr->key_exp = SAMPLE_TIME; + ekr->flags = SAMPLE_FLAGS; + ekr->times.authtime = SAMPLE_TIME; + 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; +} + +krb5_error_code ktest_make_sample_last_req(DECLARG(krb5_last_req_entry ***, lr)) + OLDDECLARG(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++){ + (*lr)[i] = (krb5_last_req_entry*)calloc(1,sizeof(krb5_last_req_entry)); + if((*lr)[i] == NULL) return ENOMEM; + retval = ktest_make_sample_last_req_entry(&((*lr)[i])); + if(retval) return retval; + } + (*lr)[2] = NULL; + return 0; +} + +krb5_error_code ktest_make_sample_last_req_entry(DECLARG(krb5_last_req_entry **, lre)) + OLDDECLARG(krb5_last_req_entry **, lre) +{ + *lre = (krb5_last_req_entry*)calloc(1,sizeof(krb5_last_req_entry)); + if(*lre == NULL) return ENOMEM; + (*lre)->lr_type = -5; + (*lre)->value = SAMPLE_TIME; + return 0; +} + +krb5_error_code ktest_make_sample_kdc_rep(DECLARG(krb5_kdc_rep *, kdcr)) + OLDDECLARG(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; + kdcr->enc_part2 = NULL; + + return 0; +} + +krb5_error_code ktest_make_sample_pa_data_array(DECLARG(krb5_pa_data ***, pad)) + OLDDECLARG(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)[2] = NULL; + + return 0; +} + +krb5_error_code ktest_make_sample_pa_data(DECLARG(krb5_pa_data *, pad)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sample_ap_req(DECLARG(krb5_ap_req *, ar)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sample_ap_rep(DECLARG(krb5_ap_rep *, ar)) + OLDDECLARG(krb5_ap_rep *, ar) +{ + return ktest_make_sample_enc_data(&(ar->enc_part)); +} + +krb5_error_code ktest_make_sample_ap_rep_enc_part(DECLARG(krb5_ap_rep_enc_part *, arep)) + OLDDECLARG(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->seq_number = SAMPLE_SEQ_NUMBER; + + return 0; +} + +krb5_error_code ktest_make_sample_kdc_req(DECLARG(krb5_kdc_req *, kr)) + OLDDECLARG(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; + 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; + kr->from = SAMPLE_TIME; + kr->till = SAMPLE_TIME; + kr->rtime = SAMPLE_TIME; + kr->nonce = SAMPLE_NONCE; + kr->netypes = 2; + kr->etype = (krb5_enctype*)calloc(2,sizeof(krb5_enctype)); + kr->etype[0] = 0; + kr->etype[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; +} + +krb5_error_code ktest_make_sample_kdc_req_body(DECLARG(krb5_kdc_req *, krb)) + OLDDECLARG(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; + krb->from = SAMPLE_TIME; + krb->till = SAMPLE_TIME; + krb->rtime = SAMPLE_TIME; + krb->nonce = SAMPLE_NONCE; + krb->netypes = 2; + krb->etype = (krb5_enctype*)calloc(2,sizeof(krb5_enctype)); + krb->etype[0] = 0; + krb->etype[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; +} + +krb5_error_code ktest_make_sample_safe(DECLARG(krb5_safe *, s)) + OLDDECLARG(krb5_safe *, s) +{ + krb5_error_code retval; + + retval = ktest_make_sample_data(&(s->user_data)); + if(retval) return retval; + 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; +} + +krb5_error_code ktest_make_sample_priv(DECLARG(krb5_priv *, p)) + OLDDECLARG(krb5_priv *, p) +{ + return ktest_make_sample_enc_data(&(p->enc_part)); +} + +krb5_error_code ktest_make_sample_priv_enc_part(DECLARG(krb5_priv_enc_part *, pep)) + OLDDECLARG(krb5_priv_enc_part *, pep) +{ + krb5_error_code retval; + retval = ktest_make_sample_data(&(pep->user_data)); + if(retval) return retval; + 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; +} + +krb5_error_code ktest_make_sample_cred(DECLARG(krb5_cred *, c)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sample_sequence_of_ticket(DECLARG(krb5_ticket ***, sot)) + OLDDECLARG(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)[2] = NULL; + + return 0; +} + +krb5_error_code ktest_make_sample_cred_enc_part(DECLARG(krb5_cred_enc_part *, cep)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sequence_of_cred_info(DECLARG(krb5_cred_info ***, soci)) + OLDDECLARG(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)[2] = NULL; + + return 0; +} + +krb5_error_code ktest_make_sample_cred_info(DECLARG(krb5_cred_info *, ci)) + OLDDECLARG(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->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; +} + +krb5_error_code ktest_make_sample_error(DECLARG(krb5_error *, kerr)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sample_data(DECLARG(krb5_data *, d)) + OLDDECLARG(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_error_code ktest_make_sample_passwd_phrase_element(DECLARG(passwd_phrase_element *, ppe)) + OLDDECLARG(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; +} + +krb5_error_code ktest_make_sample_krb5_pwd_data(DECLARG(krb5_pwd_data *, pd)) + OLDDECLARG(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[2] = NULL; + + return 0; +} + + +/****************************************************************/ +/* destructors */ + +void ktest_destroy_data(DECLARG(krb5_data **, d)) + OLDDECLARG(krb5_data **, d) +{ + if(*d != NULL){ + if((*d)->data != NULL) free((*d)->data); + free(*d); + *d = NULL; + } +} + +void ktest_empty_data(DECLARG(krb5_data *, d)) + OLDDECLARG(krb5_data *, d) +{ + if(d->data != NULL){ + free(d->data); + d->data = NULL; + d->length = 0; + } +} + +void ktest_destroy_checksum(DECLARG(krb5_checksum **, cs)) + OLDDECLARG(krb5_checksum **, cs) +{ + if(*cs != NULL){ + if((*cs)->contents != NULL) free((*cs)->contents); + free(*cs); + *cs = NULL; + } +} + +void ktest_destroy_keyblock(DECLARG(krb5_keyblock **, kb)) + OLDDECLARG(krb5_keyblock **, kb) +{ + if(*kb != NULL){ + if((*kb)->contents != NULL) free((*kb)->contents); + free(*kb); + *kb = NULL; + } +} + +void ktest_empty_authorization_data(DECLARG(krb5_authdata **, ad)) + OLDDECLARG(krb5_authdata **, ad) +{ + int i; + + for(i=0; ad[i] != NULL; i++) + ktest_destroy_authdata(&(ad[i])); +} + +void ktest_destroy_authorization_data(DECLARG(krb5_authdata ***, ad)) + OLDDECLARG(krb5_authdata ***, ad) +{ + ktest_empty_authorization_data(*ad); + free(*ad); + *ad = NULL; +} + +void ktest_destroy_authdata(DECLARG(krb5_authdata **, ad)) + OLDDECLARG(krb5_authdata **, ad) +{ + if(*ad != NULL){ + if((*ad)->contents != NULL) free((*ad)->contents); + free(*ad); + *ad = NULL; + } +} + +void ktest_empty_pa_data_array(DECLARG(krb5_pa_data **, pad)) + OLDDECLARG(krb5_pa_data **, pad) +{ + int i; + + for(i=0; pad[i] != NULL; i++) + ktest_destroy_pa_data(&(pad[i])); +} + +void ktest_destroy_pa_data_array(DECLARG(krb5_pa_data ***, pad)) + OLDDECLARG(krb5_pa_data ***, pad) +{ + ktest_empty_pa_data_array(*pad); + free(*pad); + *pad = NULL; +} + +void ktest_destroy_pa_data(DECLARG(krb5_pa_data **, pad)) + OLDDECLARG(krb5_pa_data **, pad) +{ + if(*pad != NULL){ + if((*pad)->contents != NULL) free((*pad)->contents); + free(*pad); + *pad = NULL; + } +} + + +void ktest_destroy_address(DECLARG(krb5_address **, a)) + OLDDECLARG(krb5_address **, a) +{ + if(*a != NULL){ + if((*a)->contents != NULL) free((*a)->contents); + free(*a); + *a = NULL; + } +} + +void ktest_empty_addresses(DECLARG(krb5_address **, a)) + OLDDECLARG(krb5_address **, a) +{ + int i; + + for(i=0; a[i] != NULL; i++) + ktest_destroy_address(&(a[i])); +} + +void ktest_destroy_addresses(DECLARG(krb5_address ***, a)) + OLDDECLARG(krb5_address ***, a) +{ + ktest_empty_addresses(*a); + free(*a); + *a = NULL; +} + +void ktest_destroy_principal(DECLARG(krb5_principal *, p)) + OLDDECLARG(krb5_principal *, p) +{ + int i; + + for(i=0; i<(*p)->length; i++) + ktest_empty_data(&(((*p)->data)[i])); + free(*p); + *p = NULL; +} + +void ktest_destroy_sequence_of_integer(DECLARG(long **, soi)) + OLDDECLARG(long **, soi) +{ + free(*soi); + *soi = NULL; +} + +void ktest_destroy_sequence_of_enctype(DECLARG(krb5_enctype **, soi)) + OLDDECLARG(krb5_enctype **, soi) +{ + free(*soi); + *soi = NULL; +} + +void ktest_destroy_sequence_of_ticket(DECLARG(krb5_ticket ***, sot)) + OLDDECLARG(krb5_ticket ***, sot) +{ + int i; + + for(i=0; (*sot)[i] != NULL; i++) + ktest_destroy_ticket(&((*sot)[i])); + free(*sot); + *sot = NULL; +} + +void ktest_destroy_ticket(DECLARG(krb5_ticket **, tkt)) + OLDDECLARG(krb5_ticket **, tkt) +{ + ktest_destroy_principal(&((*tkt)->server)); + ktest_destroy_enc_data(&((*tkt)->enc_part)); + free(*tkt); + *tkt = NULL; +} + +void ktest_destroy_enc_data(DECLARG(krb5_enc_data *, ed)) + OLDDECLARG(krb5_enc_data *, ed) +{ + ktest_empty_data(&(ed->ciphertext)); +} diff --git a/src/tests/asn.1/ktest.h b/src/tests/asn.1/ktest.h new file mode 100644 index 000000000..29e5d4f46 --- /dev/null +++ b/src/tests/asn.1/ktest.h @@ -0,0 +1,130 @@ +#ifndef __KTEST_H__ +#define __KTEST_H__ + +#include + +#define SAMPLE_USEC 123456 +#define SAMPLE_TIME 771228197 /* Fri Jun 10 6:03:17 GMT 1994 */ +#define SAMPLE_SEQ_NUMBER 17 +#define SAMPLE_NONCE 42 +#define SAMPLE_FLAGS 0xFEDCBA98 +#define SAMPLE_ERROR 0x3C; +krb5_error_code ktest_make_sample_data + PROTOTYPE((krb5_data *d)); +krb5_error_code ktest_make_sample_authenticator + PROTOTYPE((krb5_authenticator *a)); + krb5_error_code ktest_make_sample_principal + PROTOTYPE((krb5_principal *p)); + krb5_error_code ktest_make_sample_checksum + PROTOTYPE((krb5_checksum *cs)); + krb5_error_code ktest_make_sample_keyblock + PROTOTYPE((krb5_keyblock *kb)); +krb5_error_code ktest_make_sample_ticket + PROTOTYPE((krb5_ticket *tkt)); + krb5_error_code ktest_make_sample_enc_data + PROTOTYPE((krb5_enc_data *ed)); +krb5_error_code ktest_make_sample_enc_tkt_part + PROTOTYPE((krb5_enc_tkt_part *etp)); + krb5_error_code ktest_make_sample_transited + PROTOTYPE((krb5_transited *t)); + krb5_error_code ktest_make_sample_ticket_times + PROTOTYPE((krb5_ticket_times *tt)); + krb5_error_code ktest_make_sample_addresses + PROTOTYPE((krb5_address ***caddrs)); + krb5_error_code ktest_make_sample_address + PROTOTYPE((krb5_address *a)); + krb5_error_code ktest_make_sample_authorization_data + PROTOTYPE((krb5_authdata ***ad)); + krb5_error_code ktest_make_sample_authdata + PROTOTYPE((krb5_authdata *ad)); +krb5_error_code ktest_make_sample_enc_kdc_rep_part + PROTOTYPE((krb5_enc_kdc_rep_part *ekr)); +krb5_error_code ktest_make_sample_kdc_req + PROTOTYPE((krb5_kdc_req *kr)); + + krb5_error_code ktest_make_sample_last_req + PROTOTYPE((krb5_last_req_entry ***lr)); + krb5_error_code ktest_make_sample_last_req_entry + PROTOTYPE((krb5_last_req_entry **lre)); +krb5_error_code ktest_make_sample_kdc_rep + PROTOTYPE((krb5_kdc_rep *kdcr)); + krb5_error_code ktest_make_sample_pa_data_array + PROTOTYPE((krb5_pa_data ***pad)); + krb5_error_code ktest_make_sample_pa_data + PROTOTYPE((krb5_pa_data *pad)); +krb5_error_code ktest_make_sample_ap_req + PROTOTYPE((krb5_ap_req *ar)); +krb5_error_code ktest_make_sample_ap_rep + PROTOTYPE((krb5_ap_rep *ar)); +krb5_error_code ktest_make_sample_ap_rep_enc_part + PROTOTYPE((krb5_ap_rep_enc_part *arep)); +krb5_error_code ktest_make_sample_kdc_req_body + PROTOTYPE((krb5_kdc_req *krb)); +krb5_error_code ktest_make_sample_safe + PROTOTYPE((krb5_safe *s)); +krb5_error_code ktest_make_sample_priv + PROTOTYPE((krb5_priv *p)); +krb5_error_code ktest_make_sample_priv_enc_part + PROTOTYPE((krb5_priv_enc_part *pep)); +krb5_error_code ktest_make_sample_cred + PROTOTYPE((krb5_cred *c)); +krb5_error_code ktest_make_sample_cred_enc_part + PROTOTYPE((krb5_cred_enc_part *cep)); + krb5_error_code ktest_make_sample_sequence_of_ticket + PROTOTYPE((krb5_ticket ***sot)); +krb5_error_code ktest_make_sample_error + PROTOTYPE((krb5_error *kerr)); +krb5_error_code ktest_make_sequence_of_cred_info + PROTOTYPE((krb5_cred_info ***soci)); + krb5_error_code ktest_make_sample_cred_info + PROTOTYPE((krb5_cred_info *ci)); +krb5_error_code ktest_make_sample_passwd_phrase_element + PROTOTYPE((passwd_phrase_element *ppe)); +krb5_error_code ktest_make_sample_krb5_pwd_data + PROTOTYPE((krb5_pwd_data *pd)); + +/*----------------------------------------------------------------------*/ + +void ktest_empty_authorization_data + PROTOTYPE((krb5_authdata **ad)); +void ktest_destroy_authorization_data + PROTOTYPE((krb5_authdata ***ad)); + void ktest_destroy_authorization_data + PROTOTYPE((krb5_authdata ***ad)); +void ktest_empty_addresses + PROTOTYPE((krb5_address **a)); +void ktest_destroy_addresses + PROTOTYPE((krb5_address ***a)); + void ktest_destroy_address + PROTOTYPE((krb5_address **a)); +void ktest_empty_pa_data_array + PROTOTYPE((krb5_pa_data **pad)); +void ktest_destroy_pa_data_array + PROTOTYPE((krb5_pa_data ***pad)); + void ktest_destroy_pa_data + PROTOTYPE((krb5_pa_data **pad)); + +void ktest_destroy_data + PROTOTYPE((krb5_data **d)); +void ktest_empty_data + PROTOTYPE((krb5_data *d)); +void ktest_destroy_principal + PROTOTYPE((krb5_principal *p)); +void ktest_destroy_checksum + PROTOTYPE((krb5_checksum **cs)); +void ktest_destroy_keyblock + PROTOTYPE((krb5_keyblock **kb)); +void ktest_destroy_authdata + PROTOTYPE((krb5_authdata **ad)); +void ktest_destroy_sequence_of_integer + PROTOTYPE((long **soi)); +void ktest_destroy_sequence_of_enctype + PROTOTYPE((krb5_enctype **soi)); +void ktest_destroy_sequence_of_ticket + PROTOTYPE((krb5_ticket ***sot)); + void ktest_destroy_ticket + PROTOTYPE((krb5_ticket **tkt)); +void ktest_destroy_enc_data + PROTOTYPE((krb5_enc_data *ed)); + +#endif diff --git a/src/tests/asn.1/ktest_equal.c b/src/tests/asn.1/ktest_equal.c new file mode 100644 index 000000000..7bb4d2676 --- /dev/null +++ b/src/tests/asn.1/ktest_equal.c @@ -0,0 +1,631 @@ +#include +#include "ktest_equal.h" + +#define FALSE 0 +#define TRUE 1 + +#define struct_equal(field,comparator)\ +comparator(&(ref->field),&(var->field)) + +#define ptr_equal(field,comparator)\ +comparator(ref->field,var->field) + +#define scalar_equal(field)\ +((ref->field) == (var->field)) + +#define len_equal(length,field,comparator)\ +((ref->length == var->length) && \ + comparator(ref->length,ref->field,var->field)) + +int ktest_equal_authenticator(DECLARG(krb5_authenticator *, ref), + DECLARG(krb5_authenticator *, var)) + OLDDECLARG(krb5_authenticator *, ref) + OLDDECLARG(krb5_authenticator *, 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 && ptr_equal(checksum,ktest_equal_checksum); + p = p && scalar_equal(cusec); + p = p && scalar_equal(ctime); + p = p && ptr_equal(subkey,ktest_equal_keyblock); + p = p && scalar_equal(seq_number); + p = p && ptr_equal(authorization_data,ktest_equal_authorization_data); + return p; +} + +int ktest_equal_principal_data(DECLARG(krb5_principal_data *, ref), + DECLARG(krb5_principal_data *, var)) + OLDDECLARG(krb5_principal_data *, ref) + OLDDECLARG(krb5_principal_data *, var) +{ + 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(DECLARG(krb5_authdata *, ref), + DECLARG(krb5_authdata *, var)) + OLDDECLARG(krb5_authdata *, ref) + OLDDECLARG(krb5_authdata *, var) +{ + 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(DECLARG(krb5_checksum *, ref), + DECLARG(krb5_checksum *, var)) + OLDDECLARG(krb5_checksum *, ref) + OLDDECLARG(krb5_checksum *, var) +{ + 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(DECLARG(krb5_keyblock *, ref), + DECLARG(krb5_keyblock *, var)) + OLDDECLARG(krb5_keyblock *, ref) + OLDDECLARG(krb5_keyblock *, var) +{ + if(ref==var) return TRUE; + else if(ref == NULL || var == NULL) return FALSE; + return(scalar_equal(keytype) && len_equal(length,contents,ktest_equal_array_of_octet)); +} + +int ktest_equal_data(DECLARG(krb5_data *, ref), + DECLARG(krb5_data *, var)) + OLDDECLARG(krb5_data *, ref) + OLDDECLARG(krb5_data *, var) +{ + 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(DECLARG(krb5_ticket *, ref), + DECLARG(krb5_ticket *, var)) + OLDDECLARG(krb5_ticket *, ref) + OLDDECLARG(krb5_ticket *, var) +{ + 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); + /* enc_part2 is irrelevant, as far as the ASN.1 code is concerned */ + return p; +} + +int ktest_equal_enc_data(DECLARG(krb5_enc_data *, ref), + DECLARG(krb5_enc_data *, var)) + OLDDECLARG(krb5_enc_data *, ref) + OLDDECLARG(krb5_enc_data *, var) +{ + int p=TRUE; + if(ref==var) return TRUE; + else if(ref == NULL || var == NULL) return FALSE; + p=p&&scalar_equal(etype); + p=p&&scalar_equal(kvno); + p=p&&struct_equal(ciphertext,ktest_equal_data); + return p; +} + +int ktest_equal_encryption_key(DECLARG(krb5_keyblock *, ref), + DECLARG(krb5_keyblock *, var)) + OLDDECLARG(krb5_keyblock *, ref) + OLDDECLARG(krb5_keyblock *, var) +{ + int p=TRUE; + if(ref==var) return TRUE; + else if(ref == NULL || var == NULL) return FALSE; + p = p && scalar_equal(keytype); + p = p && len_equal(length,contents,ktest_equal_array_of_octet); + return p; +} + +int ktest_equal_enc_tkt_part(DECLARG(krb5_enc_tkt_part *, ref), + DECLARG(krb5_enc_tkt_part *, var)) + OLDDECLARG(krb5_enc_tkt_part *, ref) + OLDDECLARG(krb5_enc_tkt_part *, var) +{ + 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); + p = p && ptr_equal(client,ktest_equal_principal_data); + p = p && struct_equal(transited,ktest_equal_transited); + p = p && struct_equal(times,ktest_equal_ticket_times); + p = p && ptr_equal(caddrs,ktest_equal_addresses); + p = p && ptr_equal(authorization_data,ktest_equal_authorization_data); + return p; +} + +int ktest_equal_transited(DECLARG(krb5_transited *, ref), + DECLARG(krb5_transited *, var)) + OLDDECLARG(krb5_transited *, ref) + OLDDECLARG(krb5_transited *, var) +{ + 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(DECLARG(krb5_ticket_times *, ref), + DECLARG(krb5_ticket_times *, var)) + OLDDECLARG(krb5_ticket_times *, ref) + OLDDECLARG(krb5_ticket_times *, var) +{ + 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); + p = p && scalar_equal(endtime); + p = p && scalar_equal(renew_till); + return p; +} + +int ktest_equal_address(DECLARG(krb5_address *, ref), + DECLARG(krb5_address *, var)) + OLDDECLARG(krb5_address *, ref) + OLDDECLARG(krb5_address *, var) +{ + 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); + return p; +} + +int ktest_equal_enc_kdc_rep_part(DECLARG(krb5_enc_kdc_rep_part *, ref), + DECLARG(krb5_enc_kdc_rep_part *, var)) + OLDDECLARG(krb5_enc_kdc_rep_part *, ref) + OLDDECLARG(krb5_enc_kdc_rep_part *, var) +{ + 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); + return p; +} + +int ktest_equal_priv(DECLARG(krb5_priv *, ref), + DECLARG(krb5_priv *, var)) + OLDDECLARG(krb5_priv *, ref) + OLDDECLARG(krb5_priv *, var) +{ + 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); + return p; +} + +int ktest_equal_cred(DECLARG(krb5_cred *, ref), + DECLARG(krb5_cred *, var)) + OLDDECLARG(krb5_cred *, ref) + OLDDECLARG(krb5_cred *, var) +{ + 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); + return p; +} + +int ktest_equal_error(DECLARG(krb5_error *, ref), + DECLARG(krb5_error *, var)) + OLDDECLARG(krb5_error *, ref) + OLDDECLARG(krb5_error *, var) +{ + 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); + return p; +} + +int ktest_equal_ap_req(DECLARG(krb5_ap_req *, ref), + DECLARG(krb5_ap_req *, var)) + OLDDECLARG(krb5_ap_req *, ref) + OLDDECLARG(krb5_ap_req *, var) +{ + 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); + return p; +} + +int ktest_equal_ap_rep(DECLARG(krb5_ap_rep *, ref), + DECLARG(krb5_ap_rep *, var)) + OLDDECLARG(krb5_ap_rep *, ref) + OLDDECLARG(krb5_ap_rep *, var) +{ + 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); + return p; +} + +int ktest_equal_ap_rep_enc_part(DECLARG(krb5_ap_rep_enc_part *, ref), + DECLARG(krb5_ap_rep_enc_part *, var)) + OLDDECLARG(krb5_ap_rep_enc_part *, ref) + OLDDECLARG(krb5_ap_rep_enc_part *, var) +{ + 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); + return p; +} + +int ktest_equal_safe(DECLARG(krb5_safe *, ref), + DECLARG(krb5_safe *, var)) + OLDDECLARG(krb5_safe *, ref) + OLDDECLARG(krb5_safe *, var) +{ + 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); + return p; +} + + +int ktest_equal_enc_cred_part(DECLARG(krb5_cred_enc_part *, ref), + DECLARG(krb5_cred_enc_part *, var)) + OLDDECLARG(krb5_cred_enc_part *, ref) + OLDDECLARG(krb5_cred_enc_part *, var) +{ + 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); + return p; +} + +int ktest_equal_enc_priv_part(DECLARG(krb5_priv_enc_part *, ref), + DECLARG(krb5_priv_enc_part *, var)) + OLDDECLARG(krb5_priv_enc_part *, ref) + OLDDECLARG(krb5_priv_enc_part *, var) +{ + 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); + return p; +} + +int ktest_equal_as_rep(DECLARG(krb5_kdc_rep *, ref), + DECLARG(krb5_kdc_rep *, var)) + OLDDECLARG(krb5_kdc_rep *, ref) + OLDDECLARG(krb5_kdc_rep *, 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&&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(DECLARG(krb5_kdc_rep *, ref), + DECLARG(krb5_kdc_rep *, var)) + OLDDECLARG(krb5_kdc_rep *, ref) + OLDDECLARG(krb5_kdc_rep *, var) +{ + return ktest_equal_as_rep(ref,var); +} + +int ktest_equal_as_req(DECLARG(krb5_kdc_req *, ref), + DECLARG(krb5_kdc_req *, var)) + OLDDECLARG(krb5_kdc_req *, ref) + OLDDECLARG(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(netypes,etype,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); */ + return p; +} + +int ktest_equal_tgs_req(DECLARG(krb5_kdc_req *, ref), + DECLARG(krb5_kdc_req *, var)) + OLDDECLARG(krb5_kdc_req *, ref) + OLDDECLARG(krb5_kdc_req *, var) +{ + return ktest_equal_as_req(ref,var); +} + +int ktest_equal_kdc_req_body(DECLARG(krb5_kdc_req *, ref), + DECLARG(krb5_kdc_req *, var)) + OLDDECLARG(krb5_kdc_req *, ref) + OLDDECLARG(krb5_kdc_req *, var) +{ + 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(netypes,etype,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); */ + return p; +} + +int ktest_equal_last_req_entry(DECLARG(krb5_last_req_entry *, ref), + DECLARG(krb5_last_req_entry *, var)) + OLDDECLARG(krb5_last_req_entry *, ref) + OLDDECLARG(krb5_last_req_entry *, var) +{ + 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); + return p; +} + +int ktest_equal_pa_data(DECLARG(krb5_pa_data *, ref), + DECLARG(krb5_pa_data *, var)) + OLDDECLARG(krb5_pa_data *, ref) + OLDDECLARG(krb5_pa_data *, var) +{ + 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); + return p; +} + +int ktest_equal_cred_info(DECLARG(krb5_cred_info *, ref), + DECLARG(krb5_cred_info *, var)) + OLDDECLARG(krb5_cred_info *, ref) + OLDDECLARG(krb5_cred_info *, var) +{ + 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); + + return p; +} + +int ktest_equal_passwd_phrase_element(DECLARG(passwd_phrase_element *, ref), + DECLARG(passwd_phrase_element *, var)) + OLDDECLARG(passwd_phrase_element *, ref) + OLDDECLARG(passwd_phrase_element *, var) +{ + 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); + return p; +} + +int ktest_equal_krb5_pwd_data(DECLARG(krb5_pwd_data *, ref), + DECLARG(krb5_pwd_data *, var)) + OLDDECLARG(krb5_pwd_data *, ref) + OLDDECLARG(krb5_pwd_data *, var) +{ + 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); + return p; +} + +/**** arrays ****************************************************************/ + +int ktest_equal_array_of_data(DECLARG(const int , length), + DECLARG(krb5_data *, ref), + DECLARG(krb5_data *, var)) + OLDDECLARG(const int , length) + OLDDECLARG(krb5_data *, ref) + OLDDECLARG(krb5_data *, var) +{ + int i,p=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])); + } + return p; +} + +int ktest_equal_array_of_octet(DECLARG(const int , length), + DECLARG(krb5_octet *, ref), + DECLARG(krb5_octet *, var)) + OLDDECLARG(const int , length) + OLDDECLARG(krb5_octet *, ref) + OLDDECLARG(krb5_octet *, var) +{ + int i, p=TRUE; + + if(ref==var) return TRUE; + else if(ref == NULL || var == NULL) return FALSE; + for(i=0; i + +/* 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. */ + +#define generic(funcname,type)\ +int funcname PROTOTYPE((type *ref, type *var)) + +#define len_array(funcname,type)\ +int funcname PROTOTYPE((const int length, type *ref, type *var)) + +generic(ktest_equal_authenticator,krb5_authenticator); +generic(ktest_equal_principal_data,krb5_principal_data); +generic(ktest_equal_checksum,krb5_checksum); +generic(ktest_equal_keyblock,krb5_keyblock); +generic(ktest_equal_data,krb5_data); +generic(ktest_equal_authdata,krb5_authdata); +generic(ktest_equal_ticket,krb5_ticket); +generic(ktest_equal_enc_tkt_part,krb5_enc_tkt_part); +generic(ktest_equal_transited,krb5_transited); +generic(ktest_equal_ticket_times,krb5_ticket_times); +generic(ktest_equal_address,krb5_address); +generic(ktest_equal_enc_data,krb5_enc_data); + +generic(ktest_equal_enc_kdc_rep_part,krb5_enc_kdc_rep_part); +generic(ktest_equal_priv,krb5_priv); +generic(ktest_equal_cred,krb5_cred); +generic(ktest_equal_error,krb5_error); +generic(ktest_equal_ap_req,krb5_ap_req); +generic(ktest_equal_ap_rep,krb5_ap_rep); +generic(ktest_equal_ap_rep_enc_part,krb5_ap_rep_enc_part); +generic(ktest_equal_safe,krb5_safe); + +generic(ktest_equal_last_req_entry,krb5_last_req_entry); +generic(ktest_equal_pa_data,krb5_pa_data); +generic(ktest_equal_cred_info,krb5_cred_info); + +generic(ktest_equal_enc_cred_part,krb5_cred_enc_part); +generic(ktest_equal_enc_priv_part,krb5_priv_enc_part); +generic(ktest_equal_as_rep,krb5_kdc_rep); +generic(ktest_equal_tgs_rep,krb5_kdc_rep); +generic(ktest_equal_as_req,krb5_kdc_req); +generic(ktest_equal_tgs_req,krb5_kdc_req); +generic(ktest_equal_kdc_req_body,krb5_kdc_req); +generic(ktest_equal_encryption_key,krb5_keyblock); + +generic(ktest_equal_passwd_phrase_element,passwd_phrase_element); +generic(ktest_equal_krb5_pwd_data,krb5_pwd_data); + +int ktest_equal_last_req + PROTOTYPE((krb5_last_req_entry **ref, krb5_last_req_entry **var)); +int ktest_equal_sequence_of_ticket + PROTOTYPE((krb5_ticket **ref, krb5_ticket **var)); +int ktest_equal_sequence_of_pa_data + PROTOTYPE((krb5_pa_data **ref, krb5_pa_data **var)); +int ktest_equal_sequence_of_cred_info + PROTOTYPE((krb5_cred_info **ref, krb5_cred_info **var)); + +len_array(ktest_equal_array_of_enctype,krb5_enctype); +len_array(ktest_equal_array_of_data,krb5_data); +len_array(ktest_equal_array_of_octet,krb5_octet); + +int ktest_equal_array_of_passwd_phrase_element + PROTOTYPE((passwd_phrase_element **ref, passwd_phrase_element **var)); +int ktest_equal_authorization_data + PROTOTYPE((krb5_authdata **ref, krb5_authdata **var)); +int ktest_equal_addresses + PROTOTYPE((krb5_address **ref, krb5_address **var)); +int ktest_equal_array_of_char + PROTOTYPE((const int length, char *ref, char *var)); + +#endif diff --git a/src/tests/asn.1/reference_encode.out b/src/tests/asn.1/reference_encode.out new file mode 100644 index 000000000..876012103 --- /dev/null +++ b/src/tests/asn.1/reference_encode.out @@ -0,0 +1,39 @@ +encode_krb5_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 +encode_krb5_authenticator(optionals empty): 62 4F 30 4D 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 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 +encode_krb5_authenticator(optionals NULL): 62 4F 30 4D 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 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 +encode_krb5_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 +encode_krb5_keyblock: 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 +encode_krb5_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 +encode_krb5_enc_tkt_part(optionals NULL): 63 81 A5 30 81 A2 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 A7 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A +encode_krb5_enc_kdc_rep_part: 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 +encode_krb5_enc_kdc_rep_part(optionals NULL): 7A 81 B4 30 81 B1 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 A4 07 03 05 00 FE 5C BA 98 A5 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 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 +encode_krb5_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 +encode_krb5_as_rep(optionals NULL): 6B 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0B 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 +encode_krb5_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 +encode_krb5_tgs_rep(optionals NULL): 6D 81 C2 30 81 BF A0 03 02 01 05 A1 03 02 01 0D 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 +encode_krb5_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 +encode_krb5_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 +encode_krb5_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 +encode_krb5_ap_rep_enc_part(optionals NULL): 7B 1C 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 +encode_krb5_as_req: 6A 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0A 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 A4 82 01 AA 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 +encode_krb5_as_req(optionals NULL except second_ticket): 6A 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0A A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 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 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 +encode_krb5_as_req(optionals NULL except server): 6A 69 30 67 A1 03 02 01 05 A2 03 02 01 0A A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 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 A5 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 +encode_krb5_tgs_req: 6C 82 01 E4 30 82 01 E0 A1 03 02 01 05 A2 03 02 01 0C 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 A4 82 01 AA 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 +encode_krb5_tgs_req(optionals NULL except second_ticket): 6C 82 01 14 30 82 01 10 A1 03 02 01 05 A2 03 02 01 0C A4 82 01 02 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 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 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 +encode_krb5_tgs_req(optionals NULL except server): 6C 69 30 67 A1 03 02 01 05 A2 03 02 01 0C A4 5B 30 59 A0 07 03 05 00 FE DC BA 90 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 A5 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 +encode_krb5_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 +encode_krb5_kdc_req_body(optionals NULL except second_ticket): 30 81 FF A0 07 03 05 00 FE DC BA 98 A2 10 1B 0E 41 54 48 45 4E 41 2E 4D 49 54 2E 45 44 55 A5 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 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 +encode_krb5_kdc_req_body(optionals NULL except server): 30 59 A0 07 03 05 00 FE DC BA 90 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 A5 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 +encode_krb5_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 +encode_krb5_safe(optionals NULL): 74 3E 30 3C A0 03 02 01 05 A1 03 02 01 14 A2 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 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 +encode_krb5_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 +encode_krb5_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 +encode_krb5_enc_priv_part(optionals NULL): 7C 1F 30 1D A0 0A 04 08 6B 72 62 35 64 61 74 61 A4 0F 30 0D A0 03 02 01 02 A1 06 04 04 12 D0 00 23 +encode_krb5_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 +encode_krb5_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 +encode_krb5_enc_cred_part(optionals NULL): 7D 82 01 0E 30 82 01 0A A0 82 01 06 30 82 01 02 30 15 A0 13 30 11 A0 03 02 01 01 A1 0A 04 08 31 32 33 34 35 36 37 38 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 +encode_krb5_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 +encode_krb5_error(optionals NULL): 7E 60 30 5E A0 03 02 01 05 A1 03 02 01 1E 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 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 +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 diff --git a/src/tests/asn.1/utility.c b/src/tests/asn.1/utility.c new file mode 100644 index 000000000..a514820bc --- /dev/null +++ b/src/tests/asn.1/utility.c @@ -0,0 +1,106 @@ +#include +#include "utility.h" +#include +#include + +char hexchar PROTOTYPE((const unsigned int digit)); + +asn1_error_code asn1_krb5_data_unparse(DECLARG(const krb5_data *, code), + DECLARG(char **, s)) + OLDDECLARG(const krb5_data *, code) + OLDDECLARG(char **, s) +{ + if(*s != NULL) free(s); + + if(code==NULL){ + *s = (char*)calloc(strlen("")+1, sizeof(char)); + if(*s == NULL) return ENOMEM; + strcpy(*s,""); + }else if(code->data == NULL || code->length <= 0){ + *s = (char*)calloc(strlen("")+1, sizeof(char)); + if(*s==NULL) return ENOMEM; + strcpy(*s,""); + }else{ + int i; + + *s = (char*)calloc(3*(code->length), sizeof(char)); + if(*s == NULL) return ENOMEM; + for(i = 0; i < code->length; i++){ + (*s)[3*i] = hexchar(((code->data)[i]&0xF0)>>4); + (*s)[3*i+1] = hexchar((code->data)[i]&0x0F); + (*s)[3*i+2] = ' '; + } + (*s)[3*(code->length)-1] = '\0'; + } + return 0; +} + +char hexchar(DECLARG(const unsigned int , digit)) + OLDDECLARG(const unsigned int , digit) +{ + if(digit<=9) + return '0'+digit; + else if(digit<=15) + return 'A'+digit-10; + else + return 'X'; +} + +krb5_error_code krb5_data_parse(DECLARG(krb5_data *, d), + DECLARG(const char *, s)) + OLDDECLARG(krb5_data *, d) + OLDDECLARG(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; +} + +krb5_error_code krb5_data_hex_parse(DECLARG(krb5_data *, d), + DECLARG(const char *, s)) + OLDDECLARG(krb5_data *, d) + OLDDECLARG(const char *, s) +{ + int i, digit; + char *pos; + + d->data = (char*)calloc((strlen(s)+1)/3,sizeof(char)); + if(d->data == NULL) return ENOMEM; + d->length = (strlen(s)+1)/3; + for(i=0,pos=(char*)s; ilength; i++,pos+=3){ + if(!sscanf(pos,"%x",&digit)) return ASN1_PARSE_ERROR; + d->data[i] = (char)digit; + } + return 0; +} + +void asn1buf_print(DECLARG(const asn1buf *, buf)) + OLDDECLARG(const asn1buf *, buf) +{ + asn1buf bufcopy; + char *s=NULL; + int length; + int i; + + bufcopy.base = bufcopy.next = buf->next; + bufcopy.bound = buf->bound; + length = asn1buf_len(&bufcopy); + + s = calloc(3*length, sizeof(char)); + if(s == NULL) return; + for(i=0; i>4); + s[3*i+1] = hexchar((bufcopy.base)[i]&0x0F); + s[3*i+2] = ' '; + } + s[3*length-1] = '\0'; + + printf("%s\n",s); + free(s); +} diff --git a/src/tests/asn.1/utility.h b/src/tests/asn.1/utility.h new file mode 100644 index 000000000..66ca4dc86 --- /dev/null +++ b/src/tests/asn.1/utility.h @@ -0,0 +1,32 @@ +#ifndef __UTILITY_H__ +#define __UTILITY_H__ + +#include +#include "krbasn1.h" +#include "asn1buf.h" + +asn1_error_code asn1_krb5_data_unparse + PROTOTYPE((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 "". If code is empty (it contains no + data or has length <= 0), the string rep is "". + 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 + PROTOTYPE((krb5_data *d, const char *s)); +/* effects Parses character string *s into krb5_data *d. */ + +krb5_error_code krb5_data_hex_parse + PROTOTYPE((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 + PROTOTYPE((const asn1buf *buf)); + +#endif -- 2.26.2