~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/tests/asn.1/krb5_encode_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2009-05-07 16:16:34 UTC
  • mfrom: (13.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090507161634-xqyk0s9na0le4flj
Tags: 1.7dfsg~beta1-4
When  decrypting the TGS response fails with the subkey, try with the
session key to work around Heimdal bug, Closes: #527353 

Show diffs side-by-side

added added

removed removed

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