1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3 * Copyright (C) 1992,1993 Trusted Information Systems, Inc.
4 *
5 * Permission to include this software in the Kerberos V5 distribution
6 * was graciously provided by Trusted Information Systems.
7 *
8 * Trusted Information Systems makes no representation about the
9 * suitability of this software for any purpose. It is provided
10 * "as is" without express or implied warranty.
11 */
12 /*
13 * Copyright (C) 1994 Massachusetts Institute of Technology
14 *
15 * Export of this software from the United States of America may
16 * require a specific license from the United States Government.
17 * It is the responsibility of any person or organization contemplating
18 * export to obtain such a license before exporting.
19 *
20 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
21 * distribute this software and its documentation for any purpose and
22 * without fee is hereby granted, provided that the above copyright
23 * notice appear in all copies and that both that copyright notice and
24 * this permission notice appear in supporting documentation, and that
25 * the name of M.I.T. not be used in advertising or publicity pertaining
26 * to distribution of the software without specific, written prior
27 * permission. Furthermore if you modify this software you must label
28 * your software as modified software and not distribute it in such a
29 * fashion that it might be confused with the original M.I.T. software.
30 * M.I.T. makes no representations about the suitability of
31 * this software for any purpose. It is provided "as is" without express
32 * or implied warranty.
33 */
34
35 /*****************************************************************************
36 * trval.c.c
37 *****************************************************************************/
38
39 #include <unistd.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <ctype.h>
43 #include <string.h>
44
45 #define OK 0
46 #define NOTOK (-1)
47
48 /* IDENTIFIER OCTET = TAG CLASS | FORM OF ENCODING | TAG NUMBER */
49
50 /* TAG CLASSES */
51 #define ID_CLASS 0xc0 /* bits 8 and 7 */
52 #define CLASS_UNIV 0x00 /* 0 = universal */
53 #define CLASS_APPL 0x40 /* 1 = application */
54 #define CLASS_CONT 0x80 /* 2 = context-specific */
55 #define CLASS_PRIV 0xc0 /* 3 = private */
56
57 /* FORM OF ENCODING */
58 #define ID_FORM 0x20 /* bit 6 */
59 #define FORM_PRIM 0x00 /* 0 = primitive */
60 #define FORM_CONS 0x20 /* 1 = constructed */
61
62 /* TAG NUMBERS */
63 #define ID_TAG 0x1f /* bits 5-1 */
64 #define PRIM_BOOL 0x01 /* Boolean */
65 #define PRIM_INT 0x02 /* Integer */
66 #define PRIM_BITS 0x03 /* Bit String */
67 #define PRIM_OCTS 0x04 /* Octet String */
68 #define PRIM_NULL 0x05 /* Null */
69 #define PRIM_OID 0x06 /* Object Identifier */
70 #define PRIM_ODE 0x07 /* Object Descriptor */
71 #define CONS_EXTN 0x08 /* External */
72 #define PRIM_REAL 0x09 /* Real */
73 #define PRIM_ENUM 0x0a /* Enumerated type */
74 #define PRIM_ENCR 0x0b /* Encrypted */
75 #define PRIM_UTF8 0x0c /* UTF8String */
76 #define CONS_SEQ 0x10 /* SEQUENCE/SEQUENCE OF */
77 #define CONS_SET 0x11 /* SET/SET OF */
78 #define DEFN_NUMS 0x12 /* Numeric String */
79 #define DEFN_PRTS 0x13 /* Printable String */
80 #define DEFN_T61S 0x14 /* T.61 String */
81 #define DEFN_VTXS 0x15 /* Videotex String */
82 #define DEFN_IA5S 0x16 /* IA5 String */
83 #define DEFN_UTCT 0x17 /* UTCTime */
84 #define DEFN_GENT 0x18 /* Generalized Time */
85 #define DEFN_GFXS 0x19 /* Graphics string (ISO2375) */
86 #define DEFN_VISS 0x1a /* Visible string */
87 #define DEFN_GENS 0x1b /* General string */
88 #define DEFN_CHRS 0x1c /* Character string */
89
90 #define LEN_XTND 0x80 /* long or indefinite form */
91 #define LEN_SMAX 127 /* largest short form */
92 #define LEN_MASK 0x7f /* mask to get number of bytes in length */
93 #define LEN_INDF (-1) /* indefinite length */
94
95 #define KRB5 /* Do krb5 application types */
96
97 int print_types = 0;
98 int print_id_and_len = 1;
99 int print_constructed_length = 1;
100 int print_primitive_length = 1;
101 int print_skip_context = 0;
102 int print_skip_tagnum = 1;
103 int print_context_shortcut = 0;
104 int do_hex = 0;
105 #ifdef KRB5
106 int print_krb5_types = 0;
107 #endif
108
109 int current_appl_type = -1;
110
111 int decode_len (FILE *, unsigned char *, int);
112 int do_prim (FILE *, int, unsigned char *, int, int);
113 int do_cons (FILE *, unsigned char *, int, int, int *);
114 int do_prim_bitstring (FILE *, int, unsigned char *, int, int);
115 int do_prim_int (FILE *, int, unsigned char *, int, int);
116 int do_prim_string (FILE *, int, unsigned char *, int, int);
117 void print_tag_type (FILE *, int, int);
118 int trval (FILE *, FILE *);
119 int trval2 (FILE *, unsigned char *, int, int, int *);
120
121
122 /****************************************************************************/
123
124 static int
convert_nibble(int ch)125 convert_nibble(int ch)
126 {
127 if (isdigit(ch))
128 return (ch - '0');
129 if (ch >= 'a' && ch <= 'f')
130 return (ch - 'a' + 10);
131 if (ch >= 'A' && ch <= 'F')
132 return (ch - 'A' + 10);
133 return -1;
134 }
135
136 int
trval(FILE * fin,FILE * fout)137 trval(FILE *fin, FILE *fout)
138 {
139 unsigned char *p;
140 unsigned int maxlen;
141 int len;
142 int cc, cc2, n1, n2;
143 int r;
144 int rlen;
145
146 maxlen = BUFSIZ;
147 p = (unsigned char *)malloc(maxlen);
148 len = 0;
149 while ((cc = fgetc(fin)) != EOF) {
150 if ((unsigned int) len == maxlen) {
151 maxlen += BUFSIZ;
152 p = (unsigned char *)realloc(p, maxlen);
153 }
154 if (do_hex) {
155 if (cc == ' ' || cc == '\n' || cc == '\t')
156 continue;
157 cc2 = fgetc(fin);
158 if (cc2 == EOF)
159 break;
160 n1 = convert_nibble(cc);
161 n2 = convert_nibble(cc2);
162 cc = (n1 << 4) + n2;
163 }
164 p[len++] = cc;
165 }
166 fprintf(fout, "<%d>", len);
167 r = trval2(fout, p, len, 0, &rlen);
168 fprintf(fout, "\n");
169 (void) free(p);
170 return(r);
171 }
172
173 int
trval2(FILE * fp,unsigned char * enc,int len,int lev,int * rlen)174 trval2(FILE *fp, unsigned char *enc, int len, int lev, int *rlen)
175 {
176 int l, eid, elen, xlen, r, rlen2 = 0;
177 int rlen_ext = 0;
178
179 r = OK;
180 *rlen = -1;
181
182 if (len < 2) {
183 fprintf(fp, "missing id and length octets (%d)\n", len);
184 return(NOTOK);
185 }
186
187 fprintf(fp, "\n");
188 for (l=0; l<lev; l++) fprintf(fp, ". ");
189
190 context_restart:
191 eid = enc[0];
192 elen = enc[1];
193
194 if (print_id_and_len) {
195 fprintf(fp, "%02x ", eid);
196 fprintf(fp, "%02x ", elen);
197 }
198
199 if (elen == LEN_XTND) {
200 fprintf(fp,
201 "indefinite length encoding not implemented (0x%02x)\n", elen);
202 return(NOTOK);
203 }
204
205 xlen = 0;
206 if (elen & LEN_XTND) {
207 xlen = elen & LEN_MASK;
208 if (xlen > len - 2) {
209 fprintf(fp, "extended length too long (%d > %d - 2)\n", xlen, len);
210 return(NOTOK);
211 }
212 elen = decode_len(fp, enc+2, xlen);
213 }
214
215 if (elen > len - 2 - xlen) {
216 fprintf(fp, "length too long (%d > %d - 2 - %d)\n", elen, len, xlen);
217 return(NOTOK);
218 }
219
220 print_tag_type(fp, eid, lev);
221
222 if (print_context_shortcut && (eid & ID_CLASS) == CLASS_CONT &&
223 (eid & ID_FORM) == FORM_CONS && lev > 0) {
224 rlen_ext += 2 + xlen;
225 enc += 2 + xlen;
226 fprintf(fp, " ");
227 goto context_restart;
228 }
229
230 switch(eid & ID_FORM) {
231 case FORM_PRIM:
232 r = do_prim(fp, eid & ID_TAG, enc+2+xlen, elen, lev+1);
233 *rlen = 2 + xlen + elen + rlen_ext;
234 break;
235 case FORM_CONS:
236 if (print_constructed_length) {
237 fprintf(fp, " constr");
238 fprintf(fp, " <%d>", elen);
239 }
240 r = do_cons(fp, enc+2+xlen, elen, lev+1, &rlen2);
241 *rlen = 2 + xlen + rlen2 + rlen_ext;
242 break;
243 }
244
245 return(r);
246 }
247
248 int
decode_len(FILE * fp,unsigned char * enc,int len)249 decode_len(FILE *fp, unsigned char *enc, int len)
250 {
251 int rlen;
252 int i;
253
254 if (print_id_and_len)
255 fprintf(fp, "%02x ", enc[0]);
256 rlen = enc[0];
257 for (i=1; i<len; i++) {
258 if (print_id_and_len)
259 fprintf(fp, "%02x ", enc[i]);
260 rlen = (rlen * 0x100) + enc[i];
261 }
262 return(rlen);
263 }
264
265 /*
266 * This is the printing function for bit strings
267 */
268 int
do_prim_bitstring(FILE * fp,int tag,unsigned char * enc,int len,int lev)269 do_prim_bitstring(FILE *fp, int tag, unsigned char *enc, int len, int lev)
270 {
271 int i;
272 long num = 0;
273
274 if (tag != PRIM_BITS || len > 5)
275 return 0;
276
277 for (i=1; i < len; i++) {
278 num = num << 8;
279 num += enc[i];
280 }
281
282 fprintf(fp, " 0x%lx", num);
283 if (enc[0])
284 fprintf(fp, " (%d unused bits)", enc[0]);
285 return 1;
286 }
287
288 /*
289 * This is the printing function for integers
290 */
291 int
do_prim_int(FILE * fp,int tag,unsigned char * enc,int len,int lev)292 do_prim_int(FILE *fp, int tag, unsigned char *enc, int len, int lev)
293 {
294 int i;
295 long num = 0;
296
297 if (tag != PRIM_INT || len > 4)
298 return 0;
299
300 if (enc[0] & 0x80)
301 num = -1;
302
303 for (i=0; i < len; i++) {
304 num = num << 8;
305 num += enc[i];
306 }
307
308 fprintf(fp, " %ld", num);
309 return 1;
310 }
311
312
313 /*
314 * This is the printing function which we use if it's a string or
315 * other other type which is best printed as a string
316 */
317 int
do_prim_string(FILE * fp,int tag,unsigned char * enc,int len,int lev)318 do_prim_string(FILE *fp, int tag, unsigned char *enc, int len, int lev)
319 {
320 int i;
321
322 /*
323 * Only try this printing function with "reasonable" types
324 */
325 if ((tag < DEFN_NUMS) && (tag != PRIM_OCTS) && (tag != PRIM_UTF8))
326 return 0;
327
328 for (i=0; i < len; i++)
329 if (!isprint(enc[i]))
330 return 0;
331 fprintf(fp, " \"%.*s\"", len, enc);
332 return 1;
333 }
334
335 int
do_prim(FILE * fp,int tag,unsigned char * enc,int len,int lev)336 do_prim(FILE *fp, int tag, unsigned char *enc, int len, int lev)
337 {
338 int n;
339 int i;
340 int j;
341 int width;
342
343 if (do_prim_string(fp, tag, enc, len, lev))
344 return OK;
345 if (do_prim_int(fp, tag, enc, len, lev))
346 return OK;
347 if (do_prim_bitstring(fp, tag, enc, len, lev))
348 return OK;
349
350 if (print_primitive_length)
351 fprintf(fp, " <%d>", len);
352
353 width = (80 - (lev * 3) - 8) / 4;
354
355 for (n = 0; n < len; n++) {
356 if ((n % width) == 0) {
357 fprintf(fp, "\n");
358 for (i=0; i<lev; i++) fprintf(fp, " ");
359 }
360 fprintf(fp, "%02x ", enc[n]);
361 if ((n % width) == (width-1)) {
362 fprintf(fp, " ");
363 for (i=n-(width-1); i<=n; i++)
364 if (isprint(enc[i])) fprintf(fp, "%c", enc[i]);
365 else fprintf(fp, ".");
366 }
367 }
368 if ((j = (n % width)) != 0) {
369 fprintf(fp, " ");
370 for (i=0; i<width-j; i++) fprintf(fp, " ");
371 for (i=n-j; i<n; i++)
372 if (isprint(enc[i])) fprintf(fp, "%c", enc[i]);
373 else fprintf(fp, ".");
374 }
375 return(OK);
376 }
377
378 int
do_cons(FILE * fp,unsigned char * enc,int len,int lev,int * rlen)379 do_cons(FILE *fp, unsigned char *enc, int len, int lev, int *rlen)
380 {
381 int n;
382 int r = 0;
383 int rlen2;
384 int rlent;
385 int save_appl;
386
387 save_appl = current_appl_type;
388 for (n = 0, rlent = 0; n < len; n+=rlen2, rlent+=rlen2) {
389 r = trval2(fp, enc+n, len-n, lev, &rlen2);
390 current_appl_type = save_appl;
391 if (r != OK) return(r);
392 }
393 if (rlent != len) {
394 fprintf(fp, "inconsistent constructed lengths (%d != %d)\n",
395 rlent, len);
396 return(NOTOK);
397 }
398 *rlen = rlent;
399 return(r);
400 }
401
402 struct typestring_table {
403 int k1, k2;
404 char *str;
405 int new_appl;
406 };
407
408 static char *
lookup_typestring(struct typestring_table * table,int key1,int key2)409 lookup_typestring(struct typestring_table *table, int key1, int key2)
410 {
411 struct typestring_table *ent;
412
413 for (ent = table; ent->k1 > 0; ent++) {
414 if ((ent->k1 == key1) &&
415 (ent->k2 == key2)) {
416 if (ent->new_appl)
417 current_appl_type = ent->new_appl;
418 return ent->str;
419 }
420 }
421 return 0;
422 }
423
424
425 struct typestring_table univ_types[] = {
426 { PRIM_BOOL, -1, "Boolean"},
427 { PRIM_INT, -1, "Integer"},
428 { PRIM_BITS, -1, "Bit String"},
429 { PRIM_OCTS, -1, "Octet String"},
430 { PRIM_NULL, -1, "Null"},
431 { PRIM_OID, -1, "Object Identifier"},
432 { PRIM_ODE, -1, "Object Descriptor"},
433 { CONS_EXTN, -1, "External"},
434 { PRIM_REAL, -1, "Real"},
435 { PRIM_ENUM, -1, "Enumerated type"},
436 { PRIM_ENCR, -1, "Encrypted"},
437 { PRIM_UTF8, -1, "UTF8String"},
438 { CONS_SEQ, -1, "Sequence/Sequence Of"},
439 { CONS_SET, -1, "Set/Set Of"},
440 { DEFN_NUMS, -1, "Numeric String"},
441 { DEFN_PRTS, -1, "Printable String"},
442 { DEFN_T61S, -1, "T.61 String"},
443 { DEFN_VTXS, -1, "Videotex String"},
444 { DEFN_IA5S, -1, "IA5 String"},
445 { DEFN_UTCT, -1, "UTCTime"},
446 { DEFN_GENT, -1, "Generalized Time"},
447 { DEFN_GFXS, -1, "Graphics string (ISO2375)"},
448 { DEFN_VISS, -1, "Visible string"},
449 { DEFN_GENS, -1, "General string"},
450 { DEFN_CHRS, -1, "Character string"},
451 { -1, -1, 0}
452 };
453
454 #ifdef KRB5
455 struct typestring_table krb5_types[] = {
456 { 1, -1, "Krb5 Ticket"},
457 { 2, -1, "Krb5 Authenticator"},
458 { 3, -1, "Krb5 Encrypted ticket part"},
459 { 10, -1, "Krb5 AS-REQ packet"},
460 { 11, -1, "Krb5 AS-REP packet"},
461 { 12, -1, "Krb5 TGS-REQ packet"},
462 { 13, -1, "Krb5 TGS-REP packet"},
463 { 14, -1, "Krb5 AP-REQ packet"},
464 { 15, -1, "Krb5 AP-REP packet"},
465 { 20, -1, "Krb5 SAFE packet"},
466 { 21, -1, "Krb5 PRIV packet"},
467 { 22, -1, "Krb5 CRED packet"},
468 { 30, -1, "Krb5 ERROR packet"},
469 { 25, -1, "Krb5 Encrypted AS-REP part"},
470 { 26, -1, "Krb5 Encrypted TGS-REP part"},
471 { 27, -1, "Krb5 Encrypted AP-REP part"},
472 { 28, -1, "Krb5 Encrypted PRIV part"},
473 { 29, -1, "Krb5 Encrypted CRED part"},
474 { -1, -1, 0}
475 };
476
477 struct typestring_table krb5_fields[] = {
478 { 1000, 0, "name-type"}, /* PrincipalName */
479 { 1000, 1, "name-string"},
480
481 { 1001, 0, "etype"}, /* Encrypted data */
482 { 1001, 1, "kvno"},
483 { 1001, 2, "cipher"},
484
485 { 1002, 0, "addr-type"}, /* HostAddress */
486 { 1002, 1, "address"},
487
488 { 1003, 0, "addr-type"}, /* HostAddresses */
489 { 1003, 1, "address"},
490
491 { 1004, 0, "ad-type"}, /* AuthorizationData */
492 { 1004, 1, "ad-data"},
493
494 { 1005, 0, "keytype"}, /* EncryptionKey */
495 { 1005, 1, "keyvalue"},
496
497 { 1006, 0, "cksumtype"}, /* Checksum */
498 { 1006, 1, "checksum"},
499
500 { 1007, 0, "kdc-options"}, /* KDC-REQ-BODY */
501 { 1007, 1, "cname", 1000},
502 { 1007, 2, "realm"},
503 { 1007, 3, "sname", 1000},
504 { 1007, 4, "from"},
505 { 1007, 5, "till"},
506 { 1007, 6, "rtime"},
507 { 1007, 7, "nonce"},
508 { 1007, 8, "etype"},
509 { 1007, 9, "addresses", 1003},
510 { 1007, 10, "enc-authorization-data", 1001},
511 { 1007, 11, "additional-tickets"},
512
513 { 1008, 1, "padata-type"}, /* PA-DATA */
514 { 1008, 2, "pa-data"},
515
516 { 1009, 0, "user-data"}, /* KRB-SAFE-BODY */
517 { 1009, 1, "timestamp"},
518 { 1009, 2, "usec"},
519 { 1009, 3, "seq-number"},
520 { 1009, 4, "s-address", 1002},
521 { 1009, 5, "r-address", 1002},
522
523 { 1010, 0, "lr-type"}, /* LastReq */
524 { 1010, 1, "lr-value"},
525
526 { 1011, 0, "key", 1005}, /* KRB-CRED-INFO */
527 { 1011, 1, "prealm"},
528 { 1011, 2, "pname", 1000},
529 { 1011, 3, "flags"},
530 { 1011, 4, "authtime"},
531 { 1011, 5, "startime"},
532 { 1011, 6, "endtime"},
533 { 1011, 7, "renew-till"},
534 { 1011, 8, "srealm"},
535 { 1011, 9, "sname", 1000},
536 { 1011, 10, "caddr", 1002},
537
538 { 1, 0, "tkt-vno"}, /* Ticket */
539 { 1, 1, "realm"},
540 { 1, 2, "sname", 1000},
541 { 1, 3, "tkt-enc-part", 1001},
542
543 { 2, 0, "authenticator-vno"}, /* Authenticator */
544 { 2, 1, "crealm"},
545 { 2, 2, "cname", 1000},
546 { 2, 3, "cksum", 1006},
547 { 2, 4, "cusec"},
548 { 2, 5, "ctime"},
549 { 2, 6, "subkey", 1005},
550 { 2, 7, "seq-number"},
551 { 2, 8, "authorization-data", 1004},
552
553 { 3, 0, "flags"}, /* EncTicketPart */
554 { 3, 1, "key", 1005},
555 { 3, 2, "crealm"},
556 { 3, 3, "cname", 1000},
557 { 3, 4, "transited"},
558 { 3, 5, "authtime"},
559 { 3, 6, "starttime"},
560 { 3, 7, "endtime"},
561 { 3, 8, "renew-till"},
562 { 3, 9, "caddr", 1003},
563 { 3, 10, "authorization-data", 1004},
564
565 { 10, 1, "pvno"}, /* AS-REQ */
566 { 10, 2, "msg-type"},
567 { 10, 3, "padata", 1008},
568 { 10, 4, "req-body", 1007},
569
570 { 11, 0, "pvno"}, /* AS-REP */
571 { 11, 1, "msg-type"},
572 { 11, 2, "padata", 1008},
573 { 11, 3, "crealm"},
574 { 11, 4, "cname", 1000},
575 { 11, 5, "ticket"},
576 { 11, 6, "enc-part", 1001},
577
578 { 12, 1, "pvno"}, /* TGS-REQ */
579 { 12, 2, "msg-type"},
580 { 12, 3, "padata", 1008},
581 { 12, 4, "req-body", 1007},
582
583 { 13, 0, "pvno"}, /* TGS-REP */
584 { 13, 1, "msg-type"},
585 { 13, 2, "padata", 1008},
586 { 13, 3, "crealm"},
587 { 13, 4, "cname", 1000},
588 { 13, 5, "ticket"},
589 { 13, 6, "enc-part", 1001},
590
591 { 14, 0, "pvno"}, /* AP-REQ */
592 { 14, 1, "msg-type"},
593 { 14, 2, "ap-options"},
594 { 14, 3, "ticket"},
595 { 14, 4, "authenticator", 1001},
596
597 { 15, 0, "pvno"}, /* AP-REP */
598 { 15, 1, "msg-type"},
599 { 15, 2, "enc-part", 1001},
600
601 { 20, 0, "pvno"}, /* KRB-SAFE */
602 { 20, 1, "msg-type"},
603 { 20, 2, "safe-body", 1009},
604 { 20, 3, "cksum", 1006},
605
606 { 21, 0, "pvno"}, /* KRB-PRIV */
607 { 21, 1, "msg-type"},
608 { 21, 2, "enc-part", 1001},
609
610 { 22, 0, "pvno"}, /* KRB-CRED */
611 { 22, 1, "msg-type"},
612 { 22, 2, "tickets"},
613 { 22, 3, "enc-part", 1001},
614
615 { 25, 0, "key", 1005}, /* EncASRepPart */
616 { 25, 1, "last-req", 1010},
617 { 25, 2, "nonce"},
618 { 25, 3, "key-expiration"},
619 { 25, 4, "flags"},
620 { 25, 5, "authtime"},
621 { 25, 6, "starttime"},
622 { 25, 7, "enddtime"},
623 { 25, 8, "renew-till"},
624 { 25, 9, "srealm"},
625 { 25, 10, "sname", 1000},
626 { 25, 11, "caddr", 1003},
627
628 { 26, 0, "key", 1005}, /* EncTGSRepPart */
629 { 26, 1, "last-req", 1010},
630 { 26, 2, "nonce"},
631 { 26, 3, "key-expiration"},
632 { 26, 4, "flags"},
633 { 26, 5, "authtime"},
634 { 26, 6, "starttime"},
635 { 26, 7, "enddtime"},
636 { 26, 8, "renew-till"},
637 { 26, 9, "srealm"},
638 { 26, 10, "sname", 1000},
639 { 26, 11, "caddr", 1003},
640
641 { 27, 0, "ctime"}, /* EncApRepPart */
642 { 27, 1, "cusec"},
643 { 27, 2, "subkey", 1005},
644 { 27, 3, "seq-number"},
645
646 { 28, 0, "user-data"}, /* EncKrbPrivPart */
647 { 28, 1, "timestamp"},
648 { 28, 2, "usec"},
649 { 28, 3, "seq-number"},
650 { 28, 4, "s-address", 1002},
651 { 28, 5, "r-address", 1002},
652
653 { 29, 0, "ticket-info", 1011}, /* EncKrbCredPart */
654 { 29, 1, "nonce"},
655 { 29, 2, "timestamp"},
656 { 29, 3, "usec"},
657 { 29, 4, "s-address", 1002},
658 { 29, 5, "r-address", 1002},
659
660 { 30, 0, "pvno"}, /* KRB-ERROR */
661 { 30, 1, "msg-type"},
662 { 30, 2, "ctime"},
663 { 30, 3, "cusec"},
664 { 30, 4, "stime"},
665 { 30, 5, "susec"},
666 { 30, 6, "error-code"},
667 { 30, 7, "crealm"},
668 { 30, 8, "cname", 1000},
669 { 30, 9, "realm"},
670 { 30, 10, "sname", 1000},
671 { 30, 11, "e-text"},
672 { 30, 12, "e-data"},
673
674 { -1, -1, 0}
675 };
676 #endif
677
678 void
print_tag_type(FILE * fp,int eid,int lev)679 print_tag_type(FILE *fp, int eid, int lev)
680 {
681 int tag = eid & ID_TAG;
682 int do_space = 1;
683 char *str;
684
685 fprintf(fp, "[");
686
687 switch(eid & ID_CLASS) {
688 case CLASS_UNIV:
689 if (print_types && print_skip_tagnum)
690 do_space = 0;
691 else
692 fprintf(fp, "UNIV %d", tag);
693 break;
694 case CLASS_APPL:
695 current_appl_type = tag;
696 #ifdef KRB5
697 if (print_krb5_types) {
698 str = lookup_typestring(krb5_types, tag, -1);
699 if (str) {
700 fputs(str, fp);
701 break;
702 }
703 }
704 #endif
705 fprintf(fp, "APPL %d", tag);
706 break;
707 case CLASS_CONT:
708 #ifdef KRB5
709 if (print_krb5_types && current_appl_type) {
710 str = lookup_typestring(krb5_fields,
711 current_appl_type, tag);
712 if (str) {
713 fputs(str, fp);
714 break;
715 }
716 }
717 #endif
718 if (print_skip_context && lev)
719 fprintf(fp, "%d", tag);
720 else
721 fprintf(fp, "CONT %d", tag);
722 break;
723 case CLASS_PRIV:
724 fprintf(fp, "PRIV %d", tag);
725 break;
726 }
727
728 if (print_types && ((eid & ID_CLASS) == CLASS_UNIV)) {
729 if (do_space)
730 fputs(" ", fp);
731 str = lookup_typestring(univ_types, eid & ID_TAG, -1);
732 if (str)
733 fputs(str, fp);
734 else
735 fprintf(fp, "UNIV %d???", eid & ID_TAG);
736 }
737
738 fprintf(fp, "]");
739
740 }
741
742 /*****************************************************************************/
743