home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / krb / util.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-25  |  1.9 KB  |  82 lines

  1. /*
  2.  * $Source: /usr/src/kerberosIV/krb/RCS/util.c,v $
  3.  * $Author: bostic $
  4.  *
  5.  * Copyright 1988 by the Massachusetts Institute of Technology.
  6.  *
  7.  * For copying and distribution information, please see the file
  8.  * <mit-copyright.h>.
  9.  *
  10.  * Miscellaneous debug printing utilities
  11.  */
  12.  
  13. #ifndef    lint
  14. static char rcsid_util_c[] =
  15. "$Header: /usr/src/kerberosIV/krb/RCS/util.c,v 4.10 91/02/25 15:31:14 bostic Exp $";
  16. #endif    lint
  17.  
  18. #include <mit-copyright.h>
  19. #include <des.h>
  20. #include <krb.h>
  21. #include <sys/types.h>
  22. #include <netinet/in.h>
  23. #include <arpa/inet.h>
  24. #include <stdio.h>
  25.  
  26. /*
  27.  * Print some of the contents of the given authenticator structure
  28.  * (AUTH_DAT defined in "krb.h").  Fields printed are:
  29.  *
  30.  * pname, pinst, prealm, netaddr, flags, cksum, timestamp, session
  31.  */
  32.  
  33. ad_print(x)
  34.     AUTH_DAT *x;
  35. {
  36.     struct in_addr add;
  37.  
  38.     /*
  39.      * Print the contents of an auth_dat struct.  We can't cast a char
  40.      * array (x->address) to a struct in_addr, so we must turn off
  41.      * lint checking here.
  42.      *
  43.      * The above was the original comment -- I don't really understand
  44.      * the problem, but gcc won't compile it the way it was.  Hope this
  45.      * works -- TK.
  46.      */
  47.     add.s_addr = x->address;
  48.     printf("\n%s %s %s %s flags %u cksum 0x%X\n\ttkt_tm 0x%X sess_key",
  49.         x->pname, x->pinst, x->prealm, inet_ntoa(add), x->k_flags,
  50.         x->checksum, x->time_sec);
  51.     printf("[8] =");
  52. #ifdef NOENCRYPTION
  53.     placebo_cblock_print(x->session);
  54. #else /* Do Encryption */
  55.     des_cblock_print_file(x->session,stdout);
  56. #endif /* NOENCRYPTION */
  57.     /* skip reply for now */
  58. }
  59.  
  60. #ifdef NOENCRYPTION
  61. /*
  62.  * Print in hex the 8 bytes of the given session key.
  63.  *
  64.  * Printed format is:  " 0x { x, x, x, x, x, x, x, x }"
  65.  */
  66.  
  67. placebo_cblock_print(x)
  68.     des_cblock x;
  69. {
  70.     unsigned char *y = (unsigned char *) x;
  71.     register int i = 0;
  72.  
  73.     printf(" 0x { ");
  74.  
  75.     while (i++ <8) {
  76.         printf("%x",*y++);
  77.         if (i<8) printf(", ");
  78.     }
  79.     printf(" }");
  80. }
  81. #endif /* NOENCRYPTION */
  82.